Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix(design-system): chart rendering (#40306)

kemal.earthaf98191cc079
diff --git a/apps/design-system/components/component-preview.tsx b/apps/design-system/components/component-preview.tsx
index 5a855c5f684..278dddbcfd0 100644
--- a/apps/design-system/components/component-preview.tsx
+++ b/apps/design-system/components/component-preview.tsx
@@ -11,22 +11,6 @@ import {
cn,
} from 'ui'
import { useConfig } from '@/hooks/use-config'
-import {
- // CopyButton,
- CopyWithClassNames,
-} from '@/components/copy-button'
-// import { Icons } from '@/components/icons'
-// import { StyleSwitcher } from '@/components/style-switcher'
-// import { ThemeWrapper } from '@/components/theme-wrapper'
-import {
- Tabs_Shadcn_ as Tabs,
- TabsContent_Shadcn_ as TabsContent,
- TabsList_Shadcn_ as TabsList,
- TabsTrigger_Shadcn_ as TabsTrigger,
-} from 'ui'
-
-// import { LoaderCircle } from 'lucide-react'
-
import { styles } from '@/registry/styles'
import { ChevronRight, Expand } from 'lucide-react'
@@ -63,12 +47,7 @@ export function ComponentPreview({
const [expand, setExpandState] = React.useState(false)
const Preview = React.useMemo(() => {
- // console.log('Index', Index)
- // console.log('name', name)
- // console.log('config.style', config.style)
-
const Component = Index[config.style][name]?.component
- // const Component = Index[name]?.component
if (!Component) {
return (
@@ -85,17 +64,9 @@ export function ComponentPreview({
return <Component />
}, [name, config.style])
- const codeString = React.useMemo(() => {
- if (typeof Code?.props['data-rehype-pretty-code-fragment'] !== 'undefined') {
- const [, Button] = React.Children.toArray(Code.props.children) as React.ReactElement[]
- return Button?.props?.value || Button?.props?.__rawString__ || null
- }
- }, [Code])
-
const ComponentPreview = React.useMemo(() => {
return (
<>
- {/* <ThemeWrapper defaultTheme="zinc"> */}
<div
className={cn('preview flex min-h-[350px] w-full justify-center p-10', {
'items-center': align === 'center',
@@ -105,17 +76,12 @@ export function ComponentPreview({
>
<React.Suspense
fallback={
- <div className="flex items-center text-sm text-muted-foreground">
- {/* <Icons.spinner className="mr-2 h-4 w-4 animate-spin" /> */}
- {/* <LoaderCircle className="mr-2 h-4 w-4 animate-spin" /> */}
- Loading...
- </div>
+ <div className="flex items-center text-sm text-muted-foreground">Loading...</div>
}
>
{Preview}
</React.Suspense>
</div>
- {/* </ThemeWrapper> */}
</>
)
}, [Preview, align])
@@ -179,7 +145,6 @@ export function ComponentPreview({
<div className="z-0 pointer-events-none absolute h-full w-full bg-[radial-gradient(hsla(var(--foreground-default)/0.02)_1px,transparent_1px)] [background-size:16px_16px] [mask-image:radial-gradient(ellipse_50%_50%_at_50%_50%,#000_70%,transparent_100%)]"></div>
)}
<div className="z-10 relative">{ComponentPreview}</div>
- {/* <div className="preview-grid-background"></div> */}
</div>
<Collapsible_Shadcn_>
<CollapsibleTrigger_Shadcn_
@@ -219,40 +184,4 @@ export function ComponentPreview({
</Collapsible_Shadcn_>
</div>
)
-
- return (
- <div
- className={cn('group relative my-4 flex flex-col gap-2', wideClasses, className)}
- {...props}
- >
- <Tabs defaultValue="preview" className="relative mr-auto w-full">
- <div className="flex items-center justify-between pb-3">
- <TabsList className="w-full justify-start rounded-none border-b bg-transparent p-0">
- <TabsTrigger
- value="preview"
- className="relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"
- >
- Preview
- </TabsTrigger>
- <TabsTrigger
- value="code"
- className="relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"
- >
- Code
- </TabsTrigger>
- </TabsList>
- </div>
- <TabsContent value="preview" className="relative rounded-md border bg-studio">
- {ComponentPreview}
- </TabsContent>
- <TabsContent value="code">
- <div className="flex flex-col space-y-4">
- <div className="w-full rounded-md [&_pre]:my-0 [&_pre]:max-h-[350px] [&_pre]:overflow-auto">
- {Code}
- </div>
- </div>
- </TabsContent>
- </Tabs>
- </div>
- )
}
diff --git a/apps/design-system/content/docs/fragments/logs-bar-chart.mdx b/apps/design-system/content/docs/fragments/logs-bar-chart.mdx
index 7127ecd2eac..f86b46da321 100644
--- a/apps/design-system/content/docs/fragments/logs-bar-chart.mdx
+++ b/apps/design-system/content/docs/fragments/logs-bar-chart.mdx
@@ -17,5 +17,6 @@ type LogsBarChartDatum = {
timestamp: string
ok_count: number
error_count: number
+ warning_count: number
}
```
diff --git a/apps/design-system/package.json b/apps/design-system/package.json
index 32c711e38c2..b79fa890b5f 100644
--- a/apps/design-system/package.json
+++ b/apps/design-system/package.json
@@ -19,6 +19,7 @@
"dependencies": {
"@hookform/resolvers": "^3.1.1",
"contentlayer2": "0.4.6",
+ "dayjs": "1.11.13",
"date-fns": "^2.30.0",
"eslint-config-supabase": "workspace:*",
"icons": "workspace:*",
@@ -36,7 +37,7 @@
"react-hook-form": "^7.45.0",
"react-inlinesvg": "^4.0.4",
"react-wrap-balancer": "^1.1.0",
- "recharts": "^2.12.7",
+ "recharts": "catalog:",
"rehype-autolink-headings": "^7.1.0",
"rehype-pretty-code": "^0.9.0",
"rehype-slug": "^6.0.0",
diff --git a/apps/design-system/registry/default/example/logs-bar-chart.tsx b/apps/design-system/registry/default/example/logs-bar-chart.tsx
index 2c348594f15..3b0a83db34e 100644
--- a/apps/design-system/registry/default/example/logs-bar-chart.tsx
+++ b/apps/design-system/registry/default/example/logs-bar-chart.tsx
@@ -1,3 +1,5 @@
+'use client'
+
import { LogsBarChart } from 'ui-patterns/LogsBarChart'
export default function LogsBarChartDemo() {
diff --git a/apps/studio/package.json b/apps/studio/package.json
index 73d5238afb1..eb32f9e207e 100644
--- a/apps/studio/package.json
+++ b/apps/studio/package.json
@@ -127,7 +127,7 @@
"react-simple-maps": "4.0.0-beta.6",
"react-use": "^17.5.0",
"reactflow": "^11.10.1",
- "recharts": "^2.8.0",
+ "recharts": "catalog:",
"remark-gfm": "^3.0.1",
"shared-data": "workspace:*",
"sonner": "^1.5.0",
diff --git a/apps/ui-library/package.json b/apps/ui-library/package.json
index 6ace5f764f7..fb02e5e444b 100644
--- a/apps/ui-library/package.json
+++ b/apps/ui-library/package.json
@@ -73,7 +73,7 @@
"react-hook-form": "^7.45.0",
"react-markdown": "^10.1.0",
"react-wrap-balancer": "^1.1.0",
- "recharts": "^2.8.0",
+ "recharts": "catalog:",
"rehype-autolink-headings": "^7.1.0",
"rehype-pretty-code": "^0.9.0",
"rehype-slug": "^6.0.0",
diff --git a/apps/www/package.json b/apps/www/package.json
index 0e70aaacce7..71492286b9b 100644
--- a/apps/www/package.json
+++ b/apps/www/package.json
@@ -73,7 +73,7 @@
"react-syntax-highlighter": "^15.6.6",
"react-transition-group": "^4.4.1",
"react-use": "^17.4.0",
- "recharts": "^2.8.0",
+ "recharts": "catalog:",
"rehype-slug": "^5.1.0",
"remark": "^15.0.1",
"remark-gfm": "^3.0.1",
diff --git a/packages/ui-patterns/package.json b/packages/ui-patterns/package.json
index 39e7e8f6034..0ec9860f191 100644
--- a/packages/ui-patterns/package.json
+++ b/packages/ui-patterns/package.json
@@ -635,7 +635,7 @@
"react-syntax-highlighter": "^15.6.6",
"react-tooltip": "*",
"react-use": "^17.5.0",
- "recharts": "^2.8.0",
+ "recharts": "catalog:",
"remark": "^15.0.1",
"remark-gfm": "^4.0.0",
"scroll-into-view-if-needed": "^3.1.0",
@@ -671,4 +671,4 @@
"peerDependencies": {
"next": "catalog:"
}
-}
+}
\ No newline at end of file
diff --git a/packages/ui-patterns/src/LogsBarChart/index.tsx b/packages/ui-patterns/src/LogsBarChart/index.tsx
index a7ff1985a7d..e540df49b44 100644
--- a/packages/ui-patterns/src/LogsBarChart/index.tsx
+++ b/packages/ui-patterns/src/LogsBarChart/index.tsx
@@ -1,4 +1,5 @@
'use client'
+
import dayjs from 'dayjs'
import { ReactNode, useState } from 'react'
import { Bar, Cell, BarChart as RechartBarChart, XAxis, YAxis } from 'recharts'
@@ -15,12 +16,14 @@ const CHART_COLORS = {
YELLOW_1: 'hsl(var(--warning-default))',
YELLOW_2: 'hsl(var(--warning-500))',
}
+
type LogsBarChartDatum = {
timestamp: string
error_count: number
ok_count: number
warning_count: number
}
+
export const LogsBarChart = ({
data,
onBarClick,
@@ -95,7 +98,7 @@ export const LogsBarChart = ({
content={
<ChartTooltipContent
className="text-foreground-light -mt-5"
- labelFormatter={(v) => dayjs(v).format(DateTimeFormat)}
+ labelFormatter={(v: string) => dayjs(v).format(DateTimeFormat)}
/>
}
/>
diff --git a/packages/ui/package.json b/packages/ui/package.json
index 448077706bb..713cceb7b2c 100644
--- a/packages/ui/package.json
+++ b/packages/ui/package.json
@@ -73,7 +73,7 @@
"react-medium-image-zoom": "^5.2.4",
"react-resizable-panels": "^2.1.4",
"react-syntax-highlighter": "^15.6.6",
- "recharts": "^2.12.7",
+ "recharts": "catalog:",
"sonner": "^1.5.0",
"tailwind-merge": "^1.13.2",
"tailwindcss": "catalog:",
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index b0c929109ba..45d2f69d5d9 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -36,6 +36,9 @@ catalogs:
react-dom:
specifier: ^18.3.0
version: 18.3.1
+ recharts:
+ specifier: ^2.15.4
+ version: 2.15.4
tailwindcss:
specifier: 3.4.1
version: 3.4.1
@@ -232,6 +235,9 @@ importers:
date-fns:
specifier: ^2.30.0
version: 2.30.0
+ dayjs:
+ specifier: 1.11.13
+ version: 1.11.13
eslint-config-supabase:
specifier: workspace:*
version: link:../../packages/eslint-config-supabase
@@ -281,8 +287,8 @@ importers:
specifier: ^1.1.0
version: 1.1.0([email protected])
recharts:
- specifier: ^2.12.7
+ specifier: 'catalog:'
rehype-autolink-headings:
specifier: ^7.1.0
version: 7.1.0
@@ -1045,8 +1051,8 @@ importers:
specifier: ^11.10.1
recharts:
- specifier: ^2.8.0
+ specifier: 'catalog:'
remark-gfm:
specifier: ^3.0.1
version: 3.0.1([email protected])
@@ -1427,8 +1433,8 @@ importers:
specifier: ^1.1.0
version: 1.1.0([email protected])
recharts:
- specifier: ^2.8.0
+ specifier: 'catalog:'
rehype-autolink-headings:
specifier: ^7.1.0
version: 7.1.0
@@ -1707,8 +1713,8 @@ importers:
specifier: ^17.4.0
recharts:
- specifier: ^2.8.0
+ specifier: 'catalog:'
rehype-slug:
specifier: ^5.1.0
version: 5.1.0
@@ -2345,8 +2351,8 @@ importers:
specifier: ^15.6.6
version: 15.6.6([email protected])
recharts:
- specifier: ^2.12.7
+ specifier: 'catalog:'
sonner:
specifier: ^1.5.0
@@ -2514,8 +2520,8 @@ importers:
specifier: ^17.5.0
recharts:
- specifier: ^2.8.0
+ specifier: 'catalog:'
remark:
specifier: ^15.0.1
version: 15.0.1([email protected])
@@ -17054,11 +17060,11 @@ packages:
react: ^16.8.0 || 17.x || 18.x
react-dom: ^16.8.0 || 17.x || 18.x
- resolution: {integrity: sha512-OE4hm7XqR0jNOq3Qmk9mFLyd6p2+j6bvbPJ7qlB7+oo0eNcL2l7WQzG6MBnT3EXY6xzkLMUBec3AfewJdA0J8w==}
+ resolution: {integrity: sha512-gnGKTpYwqL0Iii09gHobNolvX4Kiq4PKx6eWBCYYix+8cdw+cGo3do906l1NBPKkSWx1DghC1dlWG9L2uGd61Q==}
peerDependencies:
- react: ^16.8.0 || ^17.0.0 || ^18.0.0
- react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0
+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
resolution: {integrity: sha512-b6jSvxvVnyptAiLjbkWLE/lOnR4lfTtDAl+eUC7RZy+QQWc6wRzIV2CE6xBuMmDxc2qIihtDCZD5NPOFl7fRBQ==}
@@ -17164,12 +17170,12 @@ packages:
resolution: {integrity: sha512-kivNFO+0OcUNu7jQquLXAxz1FIwZj8nrj+YkOKc5694NbjCvcT6aSZiIzNzd2Kul4o4rTto8QVR9lMNtxD4G1w==}
- resolution: {integrity: sha512-hlLJMhPQfv4/3NBSAyq3gzGg4h2v69RJh6KU7b3pXYNNAELs9kEoXOjbkxdXpALqKBoVmVptGfLpxdaVYqjmXQ==}
+ resolution: {integrity: sha512-UT/q6fwS3c1dHbXv2uFgYJ9BMFHu3fwnd7AYZaEQhXuYQ4hgsxLvsUXzGdKeZrW5xopzDCvuA2N41WJ88I7zIw==}
engines: {node: '>=14'}
peerDependencies:
- react: ^16.0.0 || ^17.0.0 || ^18.0.0
- react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0
+ react: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
+ react-dom: ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0
resolution: {integrity: sha512-HFM8rkZ+i3zrV+4LQjwQ0W+ez98pApMGM3HUrN04j3CqzPOzl9nmP15Y8YXNm8QHGv/eacOVEjqhmWpkRV0NAw==}
@@ -38893,7 +38899,7 @@ snapshots:
react-dom: 18.3.1([email protected])
topojson-client: 3.1.0
dependencies:
fast-equals: 5.0.1
prop-types: 15.8.1
@@ -39047,15 +39053,15 @@ snapshots:
dependencies:
decimal.js-light: 2.5.1
dependencies:
clsx: 2.1.1
eventemitter3: 4.0.7
lodash: 4.17.21
react: 18.3.1
react-dom: 18.3.1([email protected])
- react-is: 16.13.1
+ react-is: 18.3.1
recharts-scale: 0.4.5
tiny-invariant: 1.3.3
victory-vendor: 36.6.11
diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml
index 5c802c6491f..42ecbcb2131 100644
--- a/pnpm-workspace.yaml
+++ b/pnpm-workspace.yaml
@@ -15,6 +15,7 @@ catalog:
next: ^15.5.2
react: ^18.3.0
react-dom: ^18.3.0
+ recharts: ^2.15.4
tailwindcss: 3.4.1
tsx: 4.20.3
typescript: ~5.9.0
@@ -54,6 +55,6 @@ overrides:
'@tanstack/directive-functions-plugin>vite': 'catalog:'
'@tanstack/react-start-plugin>vite': 'catalog:'
'vinxi>vite': 'catalog:'
- 'refractor>prismjs': ^1.30.0
+ 'refractor>prismjs': ^1.30.0
esbuild: ^0.25.2
tmp: ^0.2.4