-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
7 changed files
with
140 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,83 +1,58 @@ | ||
"use client" | ||
"use client"; | ||
|
||
import { Bar, BarChart, ResponsiveContainer, XAxis, YAxis } from "recharts" | ||
import { TrendingUp } from "lucide-react"; | ||
import { Bar, BarChart, CartesianGrid, XAxis } from "recharts"; | ||
|
||
const data = [ | ||
{ | ||
name: "Jan", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Feb", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Mar", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Apr", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "May", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Jun", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Jul", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Aug", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Sep", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Oct", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Nov", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
{ | ||
name: "Dec", | ||
total: Math.floor(Math.random() * 5000) + 1000, | ||
}, | ||
] | ||
import { | ||
Card, | ||
CardContent, | ||
CardDescription, | ||
CardFooter, | ||
CardHeader, | ||
CardTitle, | ||
} from "@/components/ui/card"; | ||
import { | ||
ChartConfig, | ||
ChartContainer, | ||
ChartTooltip, | ||
ChartTooltipContent, | ||
} from "@/components/ui/chart"; | ||
const chartData = [ | ||
{ month: "January", desktop: 186, mobile: 80 }, | ||
{ month: "February", desktop: 305, mobile: 200 }, | ||
{ month: "March", desktop: 237, mobile: 120 }, | ||
{ month: "April", desktop: 73, mobile: 190 }, | ||
{ month: "May", desktop: 209, mobile: 130 }, | ||
{ month: "June", desktop: 214, mobile: 140 }, | ||
]; | ||
|
||
const chartConfig = { | ||
desktop: { | ||
label: "Desktop", | ||
color: "hsl(var(--chart-1))", | ||
}, | ||
mobile: { | ||
label: "Mobile", | ||
color: "hsl(var(--chart-2))", | ||
}, | ||
} satisfies ChartConfig; | ||
|
||
export function Overview() { | ||
return ( | ||
<ResponsiveContainer width="100%" height={350}> | ||
<BarChart data={data}> | ||
<XAxis | ||
dataKey="name" | ||
stroke="#888888" | ||
fontSize={12} | ||
tickLine={false} | ||
axisLine={false} | ||
/> | ||
<YAxis | ||
stroke="#888888" | ||
fontSize={12} | ||
tickLine={false} | ||
axisLine={false} | ||
tickFormatter={(value) => `$${value}`} | ||
/> | ||
<Bar | ||
dataKey="total" | ||
fill="currentColor" | ||
radius={[4, 4, 0, 0]} | ||
className="fill-primary" | ||
/> | ||
</BarChart> | ||
</ResponsiveContainer> | ||
) | ||
return ( | ||
<ChartContainer config={chartConfig}> | ||
<BarChart accessibilityLayer data={chartData}> | ||
<CartesianGrid vertical={false} /> | ||
<XAxis | ||
dataKey="month" | ||
tickLine={false} | ||
tickMargin={10} | ||
axisLine={false} | ||
tickFormatter={(value) => value.slice(0, 3)} | ||
/> | ||
<ChartTooltip cursor={false} content={<ChartTooltipContent indicator="dashed" />} /> | ||
<Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} /> | ||
<Bar dataKey="mobile" fill="var(--color-mobile)" radius={4} /> | ||
</BarChart> | ||
</ChartContainer> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,85 +1,46 @@ | ||
import "../styles/globals.css"; | ||
import { Inter } from "next/font/google"; | ||
import Layout from "../components/layout"; | ||
import { useEffect, useState } from "react"; | ||
import { useEffect, useMemo } from "react"; | ||
import { loadData } from "@/utils/load"; | ||
import { saveData } from "@/utils/save"; | ||
import { User } from "@/models"; | ||
import { SignUp } from "@/components/sign-up"; | ||
import { ThemeProvider } from "next-themes"; | ||
import { Toaster } from "@/components/ui/toaster"; | ||
import { UserProvider, useUser } from "@/components/UserContext"; | ||
import { CHART_THEMES, getChartThemes } from "@/lib/chart-themes"; | ||
|
||
const inter = Inter({ subsets: ["latin"] }); | ||
const chartThemes = getChartThemes(); | ||
|
||
interface MyAppProps { | ||
Component: React.ElementType; | ||
pageProps: any; | ||
} | ||
|
||
export default function MyApp({ Component, pageProps }: MyAppProps) { | ||
function MyApp({ Component, pageProps }: MyAppProps) { | ||
const { user, setUser } = useUser(); | ||
|
||
function generateCssVariables(themes: any) { | ||
let cssVariables = `:root {\n`; | ||
|
||
themes.forEach((theme: any) => { | ||
// Object.entries(theme.colors).forEach(([key, value]) => { | ||
// const variableName = `--${key}`; | ||
// cssVariables += ` ${variableName}: ${value};\n`; | ||
// }); | ||
|
||
// Object.entries(theme.colorsDark).forEach(([key, value]) => { | ||
// const variableName = `--${key}-dark`; | ||
// cssVariables += ` ${variableName}: ${value};\n`; | ||
// }); | ||
Object.entries(theme.colors).forEach(([key, value]) => { | ||
if (key.includes("chart")) { | ||
const variableName = `--${key.replace( | ||
"chart", | ||
"color" | ||
)}-${theme.name.toLowerCase()}`; | ||
cssVariables += ` ${variableName}: hsl(${value});\n`; | ||
} | ||
}); | ||
Object.entries(theme.colorsDark).forEach(([key, value]) => { | ||
if (key.includes("chart")) { | ||
const variableName = `--${key.replace( | ||
"chart", | ||
"color" | ||
)}-${theme.name.toLowerCase()}`; | ||
cssVariables += ` ${variableName}-dark: hsl(${value});\n`; | ||
} | ||
}); | ||
}); | ||
|
||
cssVariables += `}`; | ||
|
||
return cssVariables; | ||
} | ||
|
||
const cssSelectors = generateCssVariables(CHART_THEMES); | ||
console.log(cssSelectors); | ||
|
||
useEffect(() => { | ||
const data = loadData(); | ||
if (data) { | ||
setUser(data); | ||
} | ||
}, []); | ||
}, [setUser]); | ||
|
||
return ( | ||
<div className={inter.className}> | ||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem> | ||
<UserProvider> | ||
<Layout> | ||
<Component {...pageProps} /> | ||
</Layout> | ||
<Toaster /> | ||
</UserProvider> | ||
<Layout> | ||
<Component {...pageProps} /> | ||
</Layout> | ||
<Toaster /> | ||
</ThemeProvider> | ||
</div> | ||
); | ||
} | ||
|
||
export default function AppWrapper(props: MyAppProps) { | ||
return ( | ||
<UserProvider> | ||
<MyApp {...props} /> | ||
</UserProvider> | ||
); | ||
} |
Oops, something went wrong.