From d64374d009dabfbfb1bb9ad6ffa8d1973879e8f6 Mon Sep 17 00:00:00 2001 From: shadcn Date: Mon, 4 Nov 2024 23:06:14 +0400 Subject: [PATCH] fix(www): chart colors --- .../new-york/example/cards/activity-goal.tsx | 38 +++-- .../new-york/example/cards/metric.tsx | 136 +++++++----------- .../registry/new-york/example/cards/stats.tsx | 110 +++++++------- 3 files changed, 115 insertions(+), 169 deletions(-) diff --git a/apps/www/registry/new-york/example/cards/activity-goal.tsx b/apps/www/registry/new-york/example/cards/activity-goal.tsx index 9028b08441..896598338e 100644 --- a/apps/www/registry/new-york/example/cards/activity-goal.tsx +++ b/apps/www/registry/new-york/example/cards/activity-goal.tsx @@ -15,6 +15,7 @@ import { CardHeader, CardTitle, } from "@/registry/new-york/ui/card" +import { ChartConfig, ChartContainer } from "@/registry/new-york/ui/chart" import { baseColors } from "@/registry/registry-base-colors" const data = [ @@ -59,13 +60,17 @@ const data = [ }, ] -export function CardsActivityGoal() { - const { theme: mode } = useTheme() - const [config] = useConfig() +const chartConfig = { + goal: { + label: "Goal", + theme: { + light: "black", + dark: "white", + }, + }, +} satisfies ChartConfig - const baseColor = baseColors.find( - (baseColor) => baseColor.name === config.theme - ) +export function CardsActivityGoal() { const [goal, setGoal] = React.useState(350) function onClick(adjustment: number) { @@ -108,23 +113,14 @@ export function CardsActivityGoal() {
- + - + - +
diff --git a/apps/www/registry/new-york/example/cards/metric.tsx b/apps/www/registry/new-york/example/cards/metric.tsx index e9d6e7f545..f1f84d8d9e 100644 --- a/apps/www/registry/new-york/example/cards/metric.tsx +++ b/apps/www/registry/new-york/example/cards/metric.tsx @@ -11,6 +11,12 @@ import { CardHeader, CardTitle, } from "@/registry/new-york/ui/card" +import { + ChartConfig, + ChartContainer, + ChartTooltip, + ChartTooltipContent, +} from "@/registry/new-york/ui/chart" import { baseColors } from "@/registry/registry-base-colors" const data = [ @@ -44,14 +50,18 @@ const data = [ }, ] +const chartConfig = { + today: { + label: "Today", + color: "hsl(var(--primary))", + }, + average: { + label: "Average", + color: "hsl(var(--muted-foreground))", + }, +} satisfies ChartConfig + export function CardsMetric() { - const { theme: mode } = useTheme() - const [config] = useConfig() - - const baseColor = baseColors.find( - (baseColor) => baseColor.name === config.theme - ) - return ( @@ -61,87 +71,39 @@ export function CardsMetric() { -
- - + + - { - if (active && payload && payload.length) { - return ( -
-
-
- - Average - - - {payload[0].value} - -
-
- - Today - - - {payload[1].value} - -
-
-
- ) - } - - return null - }} - /> - - -
-
-
+ /> + + } /> + +
) diff --git a/apps/www/registry/new-york/example/cards/stats.tsx b/apps/www/registry/new-york/example/cards/stats.tsx index 53e9b38963..c198191a73 100644 --- a/apps/www/registry/new-york/example/cards/stats.tsx +++ b/apps/www/registry/new-york/example/cards/stats.tsx @@ -1,16 +1,14 @@ "use client" -import { useTheme } from "next-themes" -import { Bar, BarChart, Line, LineChart, ResponsiveContainer } from "recharts" +import { Bar, BarChart, Line, LineChart } from "recharts" -import { useConfig } from "@/hooks/use-config" import { Card, CardContent, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" -import { baseColors } from "@/registry/registry-base-colors" +import { ChartConfig, ChartContainer } from "@/registry/new-york/ui/chart" const data = [ { @@ -47,14 +45,24 @@ const data = [ }, ] +const chartConfig = { + revenue: { + label: "Revenue", + theme: { + light: "black", + dark: "white", + }, + }, + subscription: { + label: "Subscriptions", + theme: { + light: "black", + dark: "white", + }, + }, +} satisfies ChartConfig + export function CardsStats() { - const { theme: mode } = useTheme() - const [config] = useConfig() - - const baseColor = baseColors.find( - (baseColor) => baseColor.name === config.theme - ) - return (
@@ -66,38 +74,28 @@ export function CardsStats() {

+20.1% from last month

-
- - + + - - - -
+ stroke="var(--color-revenue)" + /> + +
@@ -109,25 +107,15 @@ export function CardsStats() {

+180.1% from last month

-
- - - - - -
+ + + + +