From 77c6a1604052d382d819d84f2b4986a2efcc7cc4 Mon Sep 17 00:00:00 2001 From: zernonia <59365435+zernonia@users.noreply.github.com> Date: Wed, 1 May 2024 11:34:58 +0800 Subject: [PATCH] feat: Charts (#166) * chore: update unovis deps * chore: update color to use the themePrimary * docs: use gradient for overview component * docs: add themePopover to MainLayout * docs: enable global theme on every page * feat: introduce area, line, bar, donut chart * feat: add more props * fix: revert old pipeline * fix: patch @unovis/vue deps * fix: patch @unovis/vue deps again * chore: revert unovis/ts to 1.2.1 * chore: wip * docs: add alpha tag, fix tooltipo styling * docs: add charts installations step * feat: use generic, add better color * chore: build registry * feat: improve generic props * chore: build registry * docs: add alpha label * fix: collapsible not open correctly * docs: add badge to mobile nav * chore: better types * chore: run registry * chore: wip * fix: crosshair issue * chore: fix type, import missing error * chore: build registry * chore: arrange interface, expose margin, slot * chore: build registry * docs: guide page feat: add prop to barchart * chore: fix pnpm-lock * chore: add feature * chore: run build registry * refactor: change color var * feat: codegen * chore: add meta tables * feat: add line, area example * feat: bar and donut examples * docs: codege * chore: build registry * docs: improve chart doc * chore: fix missing icon package --- .../.vitepress/theme/components/APITable.vue | 26 ++ .../.vitepress/theme/components/MobileNav.vue | 18 +- .../theme/components/ThemePopover.vue | 47 +++ apps/www/.vitepress/theme/components/index.ts | 1 + .../theme/components/theming/Theming.vue | 4 +- .../theme/components/theming/utils/data.ts | 30 ++ apps/www/.vitepress/theme/config/docs.ts | 61 +--- .../.vitepress/theme/layout/DocsLayout.vue | 15 +- .../.vitepress/theme/layout/MainLayout.vue | 3 + apps/www/.vitepress/theme/style.css | 17 +- apps/www/.vitepress/theme/styles/vp-doc.css | 4 +- apps/www/__registry__/index.ts | 210 +++++++++++++ apps/www/package.json | 9 +- apps/www/scripts/autogen.ts | 150 +++++++++ apps/www/src/content/docs/charts.md | 107 +++++++ apps/www/src/content/docs/charts/area.md | 46 +++ apps/www/src/content/docs/charts/bar.md | 50 +++ apps/www/src/content/docs/charts/donut.md | 52 ++++ apps/www/src/content/docs/charts/line.md | 46 +++ apps/www/src/content/docs/components/toast.md | 2 +- apps/www/src/content/meta/AreaChart.md | 116 +++++++ apps/www/src/content/meta/BarChart.md | 116 +++++++ apps/www/src/content/meta/ChartCrosshair.md | 29 ++ apps/www/src/content/meta/ChartLegend.md | 22 ++ .../src/content/meta/ChartSingleTooltip.md | 43 +++ apps/www/src/content/meta/ChartTooltip.md | 16 + apps/www/src/content/meta/DonutChart.md | 82 +++++ apps/www/src/content/meta/LineChart.md | 109 +++++++ .../dashboard/components/Overview.vue | 28 +- .../example/AreaChartCustomTooltip.vue | 23 ++ .../default/example/AreaChartDemo.vue | 17 ++ .../default/example/AreaChartSparkline.vue | 33 ++ .../default/example/BarChartCustomTooltip.vue | 28 ++ .../registry/default/example/BarChartDemo.vue | 26 ++ .../default/example/BarChartRounded.vue | 27 ++ .../default/example/BarChartStacked.vue | 27 ++ .../registry/default/example/CardStats.vue | 11 +- .../default/example/Cards/ActivityGoal.vue | 11 +- .../registry/default/example/Cards/Metric.vue | 7 +- .../default/example/CustomChartTooltip.vue | 26 ++ .../default/example/DonutChartColor.vue | 24 ++ .../example/DonutChartCustomTooltip.vue | 22 ++ .../default/example/DonutChartDemo.vue | 20 ++ .../default/example/DonutChartPie.vue | 21 ++ .../example/LineChartCustomTooltip.vue | 281 +++++++++++++++++ .../default/example/LineChartDemo.vue | 279 +++++++++++++++++ .../default/example/LineChartSparkline.vue | 285 ++++++++++++++++++ .../lib/registry/default/ui/button/index.ts | 1 + .../default/ui/chart-area/AreaChart.vue | 135 +++++++++ .../registry/default/ui/chart-area/index.ts | 1 + .../default/ui/chart-bar/BarChart.vue | 114 +++++++ .../registry/default/ui/chart-bar/index.ts | 1 + .../default/ui/chart-donut/DonutChart.vue | 99 ++++++ .../registry/default/ui/chart-donut/index.ts | 1 + .../default/ui/chart-line/LineChart.vue | 104 +++++++ .../registry/default/ui/chart-line/index.ts | 1 + .../default/ui/chart/ChartCrosshair.vue | 44 +++ .../registry/default/ui/chart/ChartLegend.vue | 50 +++ .../default/ui/chart/ChartSingleTooltip.vue | 63 ++++ .../default/ui/chart/ChartTooltip.vue | 40 +++ .../lib/registry/default/ui/chart/index.ts | 18 ++ .../registry/default/ui/chart/interface.ts | 64 ++++ .../example/AreaChartCustomTooltip.vue | 23 ++ .../new-york/example/AreaChartDemo.vue | 17 ++ .../new-york/example/AreaChartSparkline.vue | 33 ++ .../example/BarChartCustomTooltip.vue | 28 ++ .../new-york/example/BarChartDemo.vue | 26 ++ .../new-york/example/BarChartRounded.vue | 27 ++ .../new-york/example/BarChartStacked.vue | 27 ++ .../registry/new-york/example/CardStats.vue | 77 ++--- .../new-york/example/Cards/ActivityGoal.vue | 8 +- .../new-york/example/Cards/Metric.vue | 7 +- .../new-york/example/CustomChartTooltip.vue | 26 ++ .../new-york/example/DonutChartColor.vue | 24 ++ .../example/DonutChartCustomTooltip.vue | 22 ++ .../new-york/example/DonutChartDemo.vue | 23 ++ .../new-york/example/DonutChartPie.vue | 21 ++ .../example/LineChartCustomTooltip.vue | 281 +++++++++++++++++ .../new-york/example/LineChartDemo.vue | 279 +++++++++++++++++ .../new-york/example/LineChartSparkline.vue | 285 ++++++++++++++++++ .../lib/registry/new-york/ui/button/index.ts | 1 + .../new-york/ui/chart-area/AreaChart.vue | 135 +++++++++ .../registry/new-york/ui/chart-area/index.ts | 1 + .../new-york/ui/chart-bar/BarChart.vue | 115 +++++++ .../registry/new-york/ui/chart-bar/index.ts | 1 + .../new-york/ui/chart-donut/DonutChart.vue | 99 ++++++ .../registry/new-york/ui/chart-donut/index.ts | 1 + .../new-york/ui/chart-line/LineChart.vue | 104 +++++++ .../registry/new-york/ui/chart-line/index.ts | 1 + .../new-york/ui/chart/ChartCrosshair.vue | 44 +++ .../new-york/ui/chart/ChartLegend.vue | 51 ++++ .../new-york/ui/chart/ChartSingleTooltip.vue | 63 ++++ .../new-york/ui/chart/ChartTooltip.vue | 40 +++ .../lib/registry/new-york/ui/chart/index.ts | 18 ++ .../registry/new-york/ui/chart/interface.ts | 64 ++++ apps/www/src/lib/registry/registry.ts | 1 + apps/www/src/public/registry/colors/gray.json | 2 +- .../www/src/public/registry/colors/index.json | 2 +- apps/www/src/public/registry/colors/lime.json | 2 +- .../src/public/registry/colors/neutral.json | 2 +- .../www/src/public/registry/colors/slate.json | 2 +- .../www/src/public/registry/colors/stone.json | 2 +- apps/www/src/public/registry/colors/zinc.json | 2 +- apps/www/src/public/registry/index.json | 89 ++++++ .../registry/styles/default/accordion.json | 2 +- .../registry/styles/default/alert-dialog.json | 2 +- .../public/registry/styles/default/alert.json | 2 +- .../registry/styles/default/area-chart.json | 19 ++ .../registry/styles/default/aspect-ratio.json | 2 +- .../registry/styles/default/avatar.json | 2 +- .../public/registry/styles/default/badge.json | 2 +- .../registry/styles/default/breadcrumb.json | 2 +- .../registry/styles/default/button.json | 4 +- .../public/registry/styles/default/card.json | 2 +- .../registry/styles/default/carousel.json | 2 +- .../registry/styles/default/chart-area.json | 23 ++ .../registry/styles/default/chart-bar.json | 23 ++ .../registry/styles/default/chart-donut.json | 23 ++ .../registry/styles/default/chart-line.json | 23 ++ .../public/registry/styles/default/chart.json | 39 +++ .../registry/styles/default/checkbox.json | 2 +- .../registry/styles/default/collapsible.json | 2 +- .../registry/styles/default/command.json | 2 +- .../registry/styles/default/context-menu.json | 2 +- .../registry/styles/default/dialog.json | 2 +- .../registry/styles/default/drawer.json | 2 +- .../styles/default/dropdown-menu.json | 2 +- .../public/registry/styles/default/form.json | 2 +- .../registry/styles/default/hover-card.json | 2 +- .../public/registry/styles/default/input.json | 2 +- .../public/registry/styles/default/label.json | 2 +- .../registry/styles/default/menubar.json | 2 +- .../styles/default/navigation-menu.json | 2 +- .../registry/styles/default/pagination.json | 2 +- .../registry/styles/default/pin-input.json | 2 +- .../registry/styles/default/popover.json | 2 +- .../registry/styles/default/progress.json | 2 +- .../registry/styles/default/radio-group.json | 2 +- .../registry/styles/default/resizable.json | 2 +- .../registry/styles/default/scroll-area.json | 2 +- .../registry/styles/default/select.json | 2 +- .../registry/styles/default/separator.json | 2 +- .../public/registry/styles/default/sheet.json | 2 +- .../registry/styles/default/skeleton.json | 2 +- .../registry/styles/default/slider.json | 2 +- .../registry/styles/default/sonner.json | 2 +- .../registry/styles/default/switch.json | 2 +- .../public/registry/styles/default/table.json | 2 +- .../public/registry/styles/default/tabs.json | 2 +- .../registry/styles/default/tags-input.json | 2 +- .../registry/styles/default/textarea.json | 2 +- .../public/registry/styles/default/toast.json | 2 +- .../registry/styles/default/toggle-group.json | 2 +- .../registry/styles/default/toggle.json | 2 +- .../registry/styles/default/tooltip.json | 2 +- .../registry/styles/default/v-calendar.json | 2 +- .../www/src/public/registry/styles/index.json | 2 +- .../registry/styles/new-york/accordion.json | 2 +- .../styles/new-york/alert-dialog.json | 2 +- .../registry/styles/new-york/alert.json | 2 +- .../registry/styles/new-york/area-chart.json | 19 ++ .../styles/new-york/aspect-ratio.json | 2 +- .../registry/styles/new-york/avatar.json | 2 +- .../registry/styles/new-york/badge.json | 2 +- .../registry/styles/new-york/breadcrumb.json | 2 +- .../registry/styles/new-york/button.json | 4 +- .../public/registry/styles/new-york/card.json | 2 +- .../registry/styles/new-york/carousel.json | 2 +- .../registry/styles/new-york/chart-area.json | 23 ++ .../registry/styles/new-york/chart-bar.json | 23 ++ .../registry/styles/new-york/chart-donut.json | 23 ++ .../registry/styles/new-york/chart-line.json | 23 ++ .../registry/styles/new-york/chart.json | 39 +++ .../registry/styles/new-york/checkbox.json | 2 +- .../registry/styles/new-york/collapsible.json | 2 +- .../registry/styles/new-york/command.json | 2 +- .../styles/new-york/context-menu.json | 2 +- .../registry/styles/new-york/dialog.json | 2 +- .../registry/styles/new-york/drawer.json | 2 +- .../styles/new-york/dropdown-menu.json | 2 +- .../registry/styles/new-york/hover-card.json | 2 +- .../registry/styles/new-york/input.json | 2 +- .../registry/styles/new-york/label.json | 2 +- .../registry/styles/new-york/menubar.json | 2 +- .../styles/new-york/navigation-menu.json | 2 +- .../registry/styles/new-york/pagination.json | 2 +- .../registry/styles/new-york/pin-input.json | 2 +- .../registry/styles/new-york/popover.json | 2 +- .../registry/styles/new-york/progress.json | 2 +- .../registry/styles/new-york/radio-group.json | 2 +- .../registry/styles/new-york/resizable.json | 2 +- .../registry/styles/new-york/scroll-area.json | 2 +- .../registry/styles/new-york/select.json | 2 +- .../registry/styles/new-york/separator.json | 2 +- .../registry/styles/new-york/sheet.json | 2 +- .../registry/styles/new-york/skeleton.json | 2 +- .../registry/styles/new-york/slider.json | 2 +- .../registry/styles/new-york/sonner.json | 2 +- .../registry/styles/new-york/switch.json | 2 +- .../registry/styles/new-york/table.json | 2 +- .../public/registry/styles/new-york/tabs.json | 2 +- .../registry/styles/new-york/tags-input.json | 2 +- .../registry/styles/new-york/textarea.json | 2 +- .../registry/styles/new-york/toast.json | 2 +- .../styles/new-york/toggle-group.json | 2 +- .../registry/styles/new-york/toggle.json | 2 +- .../registry/styles/new-york/tooltip.json | 2 +- .../registry/styles/new-york/v-calendar.json | 2 +- apps/www/src/stores/config.ts | 5 +- pnpm-lock.yaml | 90 ++++++ 210 files changed, 5753 insertions(+), 269 deletions(-) create mode 100644 apps/www/.vitepress/theme/components/APITable.vue create mode 100644 apps/www/.vitepress/theme/components/ThemePopover.vue create mode 100644 apps/www/scripts/autogen.ts create mode 100644 apps/www/src/content/docs/charts.md create mode 100644 apps/www/src/content/docs/charts/area.md create mode 100644 apps/www/src/content/docs/charts/bar.md create mode 100644 apps/www/src/content/docs/charts/donut.md create mode 100644 apps/www/src/content/docs/charts/line.md create mode 100644 apps/www/src/content/meta/AreaChart.md create mode 100644 apps/www/src/content/meta/BarChart.md create mode 100644 apps/www/src/content/meta/ChartCrosshair.md create mode 100644 apps/www/src/content/meta/ChartLegend.md create mode 100644 apps/www/src/content/meta/ChartSingleTooltip.md create mode 100644 apps/www/src/content/meta/ChartTooltip.md create mode 100644 apps/www/src/content/meta/DonutChart.md create mode 100644 apps/www/src/content/meta/LineChart.md create mode 100644 apps/www/src/lib/registry/default/example/AreaChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/default/example/AreaChartDemo.vue create mode 100644 apps/www/src/lib/registry/default/example/AreaChartSparkline.vue create mode 100644 apps/www/src/lib/registry/default/example/BarChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/default/example/BarChartDemo.vue create mode 100644 apps/www/src/lib/registry/default/example/BarChartRounded.vue create mode 100644 apps/www/src/lib/registry/default/example/BarChartStacked.vue create mode 100644 apps/www/src/lib/registry/default/example/CustomChartTooltip.vue create mode 100644 apps/www/src/lib/registry/default/example/DonutChartColor.vue create mode 100644 apps/www/src/lib/registry/default/example/DonutChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/default/example/DonutChartDemo.vue create mode 100644 apps/www/src/lib/registry/default/example/DonutChartPie.vue create mode 100644 apps/www/src/lib/registry/default/example/LineChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/default/example/LineChartDemo.vue create mode 100644 apps/www/src/lib/registry/default/example/LineChartSparkline.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart-area/index.ts create mode 100644 apps/www/src/lib/registry/default/ui/chart-bar/BarChart.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart-bar/index.ts create mode 100644 apps/www/src/lib/registry/default/ui/chart-donut/DonutChart.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart-donut/index.ts create mode 100644 apps/www/src/lib/registry/default/ui/chart-line/LineChart.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart-line/index.ts create mode 100644 apps/www/src/lib/registry/default/ui/chart/ChartCrosshair.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart/ChartLegend.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart/ChartSingleTooltip.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart/ChartTooltip.vue create mode 100644 apps/www/src/lib/registry/default/ui/chart/index.ts create mode 100644 apps/www/src/lib/registry/default/ui/chart/interface.ts create mode 100644 apps/www/src/lib/registry/new-york/example/AreaChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/new-york/example/AreaChartDemo.vue create mode 100644 apps/www/src/lib/registry/new-york/example/AreaChartSparkline.vue create mode 100644 apps/www/src/lib/registry/new-york/example/BarChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/new-york/example/BarChartDemo.vue create mode 100644 apps/www/src/lib/registry/new-york/example/BarChartRounded.vue create mode 100644 apps/www/src/lib/registry/new-york/example/BarChartStacked.vue create mode 100644 apps/www/src/lib/registry/new-york/example/CustomChartTooltip.vue create mode 100644 apps/www/src/lib/registry/new-york/example/DonutChartColor.vue create mode 100644 apps/www/src/lib/registry/new-york/example/DonutChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/new-york/example/DonutChartDemo.vue create mode 100644 apps/www/src/lib/registry/new-york/example/DonutChartPie.vue create mode 100644 apps/www/src/lib/registry/new-york/example/LineChartCustomTooltip.vue create mode 100644 apps/www/src/lib/registry/new-york/example/LineChartDemo.vue create mode 100644 apps/www/src/lib/registry/new-york/example/LineChartSparkline.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-area/AreaChart.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-area/index.ts create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-bar/BarChart.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-bar/index.ts create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-donut/DonutChart.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-donut/index.ts create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-line/LineChart.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart-line/index.ts create mode 100644 apps/www/src/lib/registry/new-york/ui/chart/ChartCrosshair.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart/ChartLegend.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart/ChartSingleTooltip.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart/ChartTooltip.vue create mode 100644 apps/www/src/lib/registry/new-york/ui/chart/index.ts create mode 100644 apps/www/src/lib/registry/new-york/ui/chart/interface.ts create mode 100644 apps/www/src/public/registry/styles/default/area-chart.json create mode 100644 apps/www/src/public/registry/styles/default/chart-area.json create mode 100644 apps/www/src/public/registry/styles/default/chart-bar.json create mode 100644 apps/www/src/public/registry/styles/default/chart-donut.json create mode 100644 apps/www/src/public/registry/styles/default/chart-line.json create mode 100644 apps/www/src/public/registry/styles/default/chart.json create mode 100644 apps/www/src/public/registry/styles/new-york/area-chart.json create mode 100644 apps/www/src/public/registry/styles/new-york/chart-area.json create mode 100644 apps/www/src/public/registry/styles/new-york/chart-bar.json create mode 100644 apps/www/src/public/registry/styles/new-york/chart-donut.json create mode 100644 apps/www/src/public/registry/styles/new-york/chart-line.json create mode 100644 apps/www/src/public/registry/styles/new-york/chart.json diff --git a/apps/www/.vitepress/theme/components/APITable.vue b/apps/www/.vitepress/theme/components/APITable.vue new file mode 100644 index 00000000..c128797d --- /dev/null +++ b/apps/www/.vitepress/theme/components/APITable.vue @@ -0,0 +1,26 @@ + + + diff --git a/apps/www/.vitepress/theme/components/MobileNav.vue b/apps/www/.vitepress/theme/components/MobileNav.vue index 8de06dd2..1d1c1819 100644 --- a/apps/www/.vitepress/theme/components/MobileNav.vue +++ b/apps/www/.vitepress/theme/components/MobileNav.vue @@ -5,6 +5,7 @@ import Logo from './Logo.vue' import { Sheet, SheetContent, SheetTrigger } from '@/lib/registry/default/ui/sheet' import { Button } from '@/lib/registry/default/ui/button' import { ScrollArea } from '@/lib/registry/default/ui/scroll-area' +import { Badge } from '@/lib/registry/new-york/ui/badge' const open = ref(false) @@ -63,17 +64,26 @@ const open = ref(false)
-

- {{ items.title }} -

+
+

+ {{ items.title }} +

+ + {{ items.label }} + +
{{ item.title }} + + + {{ item.label }} +
diff --git a/apps/www/.vitepress/theme/components/ThemePopover.vue b/apps/www/.vitepress/theme/components/ThemePopover.vue new file mode 100644 index 00000000..d862ec98 --- /dev/null +++ b/apps/www/.vitepress/theme/components/ThemePopover.vue @@ -0,0 +1,47 @@ + + + diff --git a/apps/www/.vitepress/theme/components/index.ts b/apps/www/.vitepress/theme/components/index.ts index 8e6df429..ec426bc3 100644 --- a/apps/www/.vitepress/theme/components/index.ts +++ b/apps/www/.vitepress/theme/components/index.ts @@ -1,5 +1,6 @@ export { default as CodeWrapper } from './CodeWrapper' export { default as ComponentPreview } from './ComponentPreview.vue' +export { default as APITable } from './APITable.vue' export { default as TabPreview } from './TabPreview.vue' export { default as TabMarkdown } from './TabMarkdown.vue' export { default as TabsMarkdown } from './TabsMarkdown.vue' diff --git a/apps/www/.vitepress/theme/components/theming/Theming.vue b/apps/www/.vitepress/theme/components/theming/Theming.vue index bf3b949e..e4d36786 100644 --- a/apps/www/.vitepress/theme/components/theming/Theming.vue +++ b/apps/www/.vitepress/theme/components/theming/Theming.vue @@ -18,9 +18,7 @@ import Metric from '@/lib/registry/new-york/example/Cards/Metric.vue' import DataTable from '@/lib/registry/new-york/example/Cards/DataTable.vue' import CardStats from '@/lib/registry/new-york/example/CardStats.vue' -import { - Card, -} from '@/lib/registry/new-york/ui/card' +import { Card } from '@/lib/registry/new-york/ui/card' import { RangeCalendar } from '@/lib/registry/new-york/ui/range-calendar' const now = today(getLocalTimeZone()) diff --git a/apps/www/.vitepress/theme/components/theming/utils/data.ts b/apps/www/.vitepress/theme/components/theming/utils/data.ts index 3da4424d..1ef53ce0 100644 --- a/apps/www/.vitepress/theme/components/theming/utils/data.ts +++ b/apps/www/.vitepress/theme/components/theming/utils/data.ts @@ -2,6 +2,36 @@ import { CreditCard } from 'lucide-vue-next' import RiAppleFill from '~icons/ri/apple-fill' import RiPaypalFill from '~icons/ri/paypal-fill' +type Color = + | 'zinc' + | 'slate' + | 'stone' + | 'gray' + | 'neutral' + | 'red' + | 'rose' + | 'orange' + | 'green' + | 'blue' + | 'yellow' + | 'violet' + +// Create an array of color values +export const allColors: Color[] = [ + 'zinc', + 'rose', + 'blue', + 'green', + 'orange', + 'red', + 'slate', + 'stone', + 'gray', + 'neutral', + 'yellow', + 'violet', +] + interface Payment { status: string email: string diff --git a/apps/www/.vitepress/theme/config/docs.ts b/apps/www/.vitepress/theme/config/docs.ts index e0907468..1f211383 100644 --- a/apps/www/.vitepress/theme/config/docs.ts +++ b/apps/www/.vitepress/theme/config/docs.ts @@ -12,7 +12,7 @@ export type SidebarNavItem = NavItem & { } export type NavItemWithChildren = NavItem & { - items: NavItemWithChildren[] + items?: NavItemWithChildren[] } interface DocsConfig { @@ -55,22 +55,18 @@ export const docsConfig: DocsConfig = { { title: 'Introduction', href: '/docs/introduction', - items: [], }, { title: 'Installation', href: '/docs/installation', - items: [], }, { title: 'components.json', href: '/docs/components-json', - items: [], }, { title: 'Theming', href: '/docs/theming', - items: [], }, { title: 'Dark Mode', @@ -80,27 +76,22 @@ export const docsConfig: DocsConfig = { { title: 'CLI', href: '/docs/cli', - items: [], }, { title: 'Typography', href: '/docs/typography', - items: [], }, { title: 'Figma', href: '/docs/figma', - items: [], }, { title: 'Changelog', href: '/docs/changelog', - items: [], }, { title: 'About', href: '/docs/about', - items: [], }, { title: 'Contribution', @@ -115,22 +106,18 @@ export const docsConfig: DocsConfig = { { title: 'Vite', href: '/docs/installation/vite', - items: [], }, { title: 'Nuxt', href: '/docs/installation/nuxt', - items: [], }, { title: 'Astro', href: '/docs/installation/astro', - items: [], }, { title: 'Laravel', href: '/docs/installation/laravel', - items: [], }, ], }, @@ -142,6 +129,12 @@ export const docsConfig: DocsConfig = { href: '/docs/components/auto-form', items: [], }, + { + title: 'Charts', + href: '/docs/charts', + label: 'Alpha', + items: [], + }, ], }, { @@ -150,32 +143,26 @@ export const docsConfig: DocsConfig = { { title: 'Accordion', href: '/docs/components/accordion', - items: [], }, { title: 'Alert', href: '/docs/components/alert', - items: [], }, { title: 'Alert Dialog', href: '/docs/components/alert-dialog', - items: [], }, { title: 'Aspect Ratio', href: '/docs/components/aspect-ratio', - items: [], }, { title: 'Avatar', href: '/docs/components/avatar', - items: [], }, { title: 'Badge', href: '/docs/components/badge', - items: [], }, { title: 'Breadcrumb', @@ -185,7 +172,6 @@ export const docsConfig: DocsConfig = { { title: 'Button', href: '/docs/components/button', - items: [], }, { title: 'Calendar', @@ -196,7 +182,6 @@ export const docsConfig: DocsConfig = { { title: 'Card', href: '/docs/components/card', - items: [], }, { title: 'Carousel', @@ -206,32 +191,26 @@ export const docsConfig: DocsConfig = { { title: 'Checkbox', href: '/docs/components/checkbox', - items: [], }, { title: 'Collapsible', href: '/docs/components/collapsible', - items: [], }, { title: 'Combobox', href: '/docs/components/combobox', - items: [], }, { title: 'Command', href: '/docs/components/command', - items: [], }, { title: 'Context Menu', href: '/docs/components/context-menu', - items: [], }, { title: 'Data Table', href: '/docs/components/data-table', - items: [], }, { title: 'Date Picker', @@ -242,7 +221,6 @@ export const docsConfig: DocsConfig = { { title: 'Dialog', href: '/docs/components/dialog', - items: [], }, { title: 'Drawer', @@ -252,42 +230,34 @@ export const docsConfig: DocsConfig = { { title: 'Dropdown Menu', href: '/docs/components/dropdown-menu', - items: [], }, { title: 'Form', href: '/docs/components/form', - items: [], }, { title: 'Hover Card', href: '/docs/components/hover-card', - items: [], }, { title: 'Input', href: '/docs/components/input', - items: [], }, { title: 'Label', href: '/docs/components/label', - items: [], }, { title: 'Menubar', href: '/docs/components/menubar', - items: [], }, { title: 'Navigation Menu', href: '/docs/components/navigation-menu', - items: [], }, { title: 'Pagination', href: '/docs/components/pagination', - items: [], }, { title: 'Pin Input', @@ -297,17 +267,14 @@ export const docsConfig: DocsConfig = { { title: 'Popover', href: '/docs/components/popover', - items: [], }, { title: 'Progress', href: '/docs/components/progress', - items: [], }, { title: 'Radio Group', href: '/docs/components/radio-group', - items: [], }, { title: 'Range Calendar', @@ -323,32 +290,26 @@ export const docsConfig: DocsConfig = { { title: 'Scroll Area', href: '/docs/components/scroll-area', - items: [], }, { title: 'Select', href: '/docs/components/select', - items: [], }, { title: 'Separator', href: '/docs/components/separator', - items: [], }, { title: 'Sheet', href: '/docs/components/sheet', - items: [], }, { title: 'Skeleton', href: '/docs/components/skeleton', - items: [], }, { title: 'Slider', href: '/docs/components/slider', - items: [], }, { title: 'Sonner', @@ -358,17 +319,14 @@ export const docsConfig: DocsConfig = { { title: 'Switch', href: '/docs/components/switch', - items: [], }, { title: 'Table', href: '/docs/components/table', - items: [], }, { title: 'Tabs', href: '/docs/components/tabs', - items: [], }, { title: 'Tags Input', @@ -378,27 +336,22 @@ export const docsConfig: DocsConfig = { { title: 'Textarea', href: '/docs/components/textarea', - items: [], }, { title: 'Toast', href: '/docs/components/toast', - items: [], }, { title: 'Toggle', href: '/docs/components/toggle', - items: [], }, { title: 'Toggle Group', href: '/docs/components/toggle-group', - items: [], }, { title: 'Tooltip', href: '/docs/components/tooltip', - items: [], }, ], }, diff --git a/apps/www/.vitepress/theme/layout/DocsLayout.vue b/apps/www/.vitepress/theme/layout/DocsLayout.vue index b0c0b559..195c5db7 100644 --- a/apps/www/.vitepress/theme/layout/DocsLayout.vue +++ b/apps/www/.vitepress/theme/layout/DocsLayout.vue @@ -27,6 +27,10 @@ const sourceLink = 'https://github.com/radix-vue/shadcn-vue/tree/dev/' class="mb-1 rounded-md px-2 py-1 text-sm font-semibold" > {{ docsGroup.title }} + + + {{ docsGroup.label }} +
-

- {{ frontmatter.title }} -

+
+

+ {{ frontmatter.title }} +

+ + {{ frontmatter.label }} + +

{{ frontmatter.description }}

diff --git a/apps/www/.vitepress/theme/layout/MainLayout.vue b/apps/www/.vitepress/theme/layout/MainLayout.vue index 4f21004b..13ebeaf7 100644 --- a/apps/www/.vitepress/theme/layout/MainLayout.vue +++ b/apps/www/.vitepress/theme/layout/MainLayout.vue @@ -8,6 +8,7 @@ import MobileNav from '../components/MobileNav.vue' import CodeConfigCustomizer from '../components/CodeConfigCustomizer.vue' import Kbd from '../components/Kbd.vue' +import ThemePopover from '../components/ThemePopover.vue' import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator } from '@/lib/registry/default/ui/command' import { Button } from '@/lib/registry/default/ui/button' @@ -133,6 +134,8 @@ watch(() => $route.path, (n) => {
@@ -91,7 +86,7 @@ const lineY = (d: Data) => d.revenue :x="lineX" :y="(d: Data) => d.subscription" :bar-padding="0.1" - :rounded-corners="0" color="var(--theme-primary)" + :rounded-corners="0" color="hsl(var(--primary))" /> diff --git a/apps/www/src/lib/registry/default/example/Cards/ActivityGoal.vue b/apps/www/src/lib/registry/default/example/Cards/ActivityGoal.vue index f2445fa8..40a994c7 100644 --- a/apps/www/src/lib/registry/default/example/Cards/ActivityGoal.vue +++ b/apps/www/src/lib/registry/default/example/Cards/ActivityGoal.vue @@ -16,10 +16,6 @@ import { import { themes } from '@/lib/registry/themes' import { useConfigStore } from '@/stores/config' -const { isDark } = useData() -const cfg = useConfigStore() -const theme = computed(() => themes.find(theme => theme.name === cfg.config.value.theme)) - const goal = ref(350) type Data = typeof data[number] @@ -84,16 +80,13 @@ const data = [ :data="data" height="60px" :style="{ - 'opacity': 0.2, - '--theme-primary': `hsl(${ - theme?.cssVars[isDark ? 'dark' : 'light'].primary - })`, + opacity: 0.2, }" > diff --git a/apps/www/src/lib/registry/default/example/Cards/Metric.vue b/apps/www/src/lib/registry/default/example/Cards/Metric.vue index c734edb2..457a2a26 100644 --- a/apps/www/src/lib/registry/default/example/Cards/Metric.vue +++ b/apps/www/src/lib/registry/default/example/Cards/Metric.vue @@ -10,8 +10,6 @@ import { } from '@/lib/registry/default/ui/card' import { useConfigStore } from '@/stores/config' -const { themePrimary } = useConfigStore() - type Data = typeof data[number] const data = [ { average: 400, today: 240 }, @@ -74,15 +72,14 @@ function computeLineOpacity(val: any, index: number) { bottom: 0, }" :style="{ - '--theme-primary': themePrimary, '--vis-tooltip-padding': '0px', '--vis-tooltip-background-color': 'transparent', '--vis-tooltip-border-color': 'transparent', }" > - - + + diff --git a/apps/www/src/lib/registry/default/example/CustomChartTooltip.vue b/apps/www/src/lib/registry/default/example/CustomChartTooltip.vue new file mode 100644 index 00000000..86f72173 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/CustomChartTooltip.vue @@ -0,0 +1,26 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/DonutChartColor.vue b/apps/www/src/lib/registry/default/example/DonutChartColor.vue new file mode 100644 index 00000000..0ae5b157 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/DonutChartColor.vue @@ -0,0 +1,24 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/DonutChartCustomTooltip.vue b/apps/www/src/lib/registry/default/example/DonutChartCustomTooltip.vue new file mode 100644 index 00000000..2e927858 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/DonutChartCustomTooltip.vue @@ -0,0 +1,22 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/DonutChartDemo.vue b/apps/www/src/lib/registry/default/example/DonutChartDemo.vue new file mode 100644 index 00000000..ad8b9844 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/DonutChartDemo.vue @@ -0,0 +1,20 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/DonutChartPie.vue b/apps/www/src/lib/registry/default/example/DonutChartPie.vue new file mode 100644 index 00000000..cf3de170 --- /dev/null +++ b/apps/www/src/lib/registry/default/example/DonutChartPie.vue @@ -0,0 +1,21 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/LineChartCustomTooltip.vue b/apps/www/src/lib/registry/default/example/LineChartCustomTooltip.vue new file mode 100644 index 00000000..fbd20dfa --- /dev/null +++ b/apps/www/src/lib/registry/default/example/LineChartCustomTooltip.vue @@ -0,0 +1,281 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/LineChartDemo.vue b/apps/www/src/lib/registry/default/example/LineChartDemo.vue new file mode 100644 index 00000000..f5a2714b --- /dev/null +++ b/apps/www/src/lib/registry/default/example/LineChartDemo.vue @@ -0,0 +1,279 @@ + + + diff --git a/apps/www/src/lib/registry/default/example/LineChartSparkline.vue b/apps/www/src/lib/registry/default/example/LineChartSparkline.vue new file mode 100644 index 00000000..6aa2ef6c --- /dev/null +++ b/apps/www/src/lib/registry/default/example/LineChartSparkline.vue @@ -0,0 +1,285 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/button/index.ts b/apps/www/src/lib/registry/default/ui/button/index.ts index e18f26bb..1b00c326 100644 --- a/apps/www/src/lib/registry/default/ui/button/index.ts +++ b/apps/www/src/lib/registry/default/ui/button/index.ts @@ -19,6 +19,7 @@ export const buttonVariants = cva( }, size: { default: 'h-10 px-4 py-2', + xs: 'h-7 rounded px-2', sm: 'h-9 rounded-md px-3', lg: 'h-11 rounded-md px-8', icon: 'h-10 w-10', diff --git a/apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue b/apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue new file mode 100644 index 00000000..5d3bf2ae --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-area/AreaChart.vue @@ -0,0 +1,135 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart-area/index.ts b/apps/www/src/lib/registry/default/ui/chart-area/index.ts new file mode 100644 index 00000000..81345fd8 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-area/index.ts @@ -0,0 +1 @@ +export { default as AreaChart } from './AreaChart.vue' diff --git a/apps/www/src/lib/registry/default/ui/chart-bar/BarChart.vue b/apps/www/src/lib/registry/default/ui/chart-bar/BarChart.vue new file mode 100644 index 00000000..31cd512f --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-bar/BarChart.vue @@ -0,0 +1,114 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart-bar/index.ts b/apps/www/src/lib/registry/default/ui/chart-bar/index.ts new file mode 100644 index 00000000..805149a5 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-bar/index.ts @@ -0,0 +1 @@ +export { default as BarChart } from './BarChart.vue' diff --git a/apps/www/src/lib/registry/default/ui/chart-donut/DonutChart.vue b/apps/www/src/lib/registry/default/ui/chart-donut/DonutChart.vue new file mode 100644 index 00000000..9ab5f652 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-donut/DonutChart.vue @@ -0,0 +1,99 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart-donut/index.ts b/apps/www/src/lib/registry/default/ui/chart-donut/index.ts new file mode 100644 index 00000000..b42413a0 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-donut/index.ts @@ -0,0 +1 @@ +export { default as DonutChart } from './DonutChart.vue' diff --git a/apps/www/src/lib/registry/default/ui/chart-line/LineChart.vue b/apps/www/src/lib/registry/default/ui/chart-line/LineChart.vue new file mode 100644 index 00000000..05025f49 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-line/LineChart.vue @@ -0,0 +1,104 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart-line/index.ts b/apps/www/src/lib/registry/default/ui/chart-line/index.ts new file mode 100644 index 00000000..5d827c88 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart-line/index.ts @@ -0,0 +1 @@ +export { default as LineChart } from './LineChart.vue' diff --git a/apps/www/src/lib/registry/default/ui/chart/ChartCrosshair.vue b/apps/www/src/lib/registry/default/ui/chart/ChartCrosshair.vue new file mode 100644 index 00000000..4440c5ee --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart/ChartCrosshair.vue @@ -0,0 +1,44 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart/ChartLegend.vue b/apps/www/src/lib/registry/default/ui/chart/ChartLegend.vue new file mode 100644 index 00000000..9a959b56 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart/ChartLegend.vue @@ -0,0 +1,50 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart/ChartSingleTooltip.vue b/apps/www/src/lib/registry/default/ui/chart/ChartSingleTooltip.vue new file mode 100644 index 00000000..23ce7a70 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart/ChartSingleTooltip.vue @@ -0,0 +1,63 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart/ChartTooltip.vue b/apps/www/src/lib/registry/default/ui/chart/ChartTooltip.vue new file mode 100644 index 00000000..8f2be084 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart/ChartTooltip.vue @@ -0,0 +1,40 @@ + + + diff --git a/apps/www/src/lib/registry/default/ui/chart/index.ts b/apps/www/src/lib/registry/default/ui/chart/index.ts new file mode 100644 index 00000000..e2d64c17 --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart/index.ts @@ -0,0 +1,18 @@ +export { default as ChartTooltip } from './ChartTooltip.vue' +export { default as ChartSingleTooltip } from './ChartSingleTooltip.vue' +export { default as ChartLegend } from './ChartLegend.vue' +export { default as ChartCrosshair } from './ChartCrosshair.vue' + +export function defaultColors(count: number = 3) { + const quotient = Math.floor(count / 2) + const remainder = count % 2 + + const primaryCount = quotient + remainder + const secondaryCount = quotient + return [ + ...Array.from(Array(primaryCount).keys()).map(i => `hsl(var(--vis-primary-color) / ${1 - (1 / primaryCount) * i})`), + ...Array.from(Array(secondaryCount).keys()).map(i => `hsl(var(--vis-secondary-color) / ${1 - (1 / secondaryCount) * i})`), + ] +} + +export * from './interface' diff --git a/apps/www/src/lib/registry/default/ui/chart/interface.ts b/apps/www/src/lib/registry/default/ui/chart/interface.ts new file mode 100644 index 00000000..c3838afc --- /dev/null +++ b/apps/www/src/lib/registry/default/ui/chart/interface.ts @@ -0,0 +1,64 @@ +import type { Spacing } from '@unovis/ts' + +type KeyOf> = Extract + +export interface BaseChartProps> { + /** + * The source data, in which each entry is a dictionary. + */ + data: T[] + /** + * Select the categories from your data. Used to populate the legend and toolip. + */ + categories: KeyOf[] + /** + * Sets the key to map the data to the axis. + */ + index: KeyOf + /** + * Change the default colors. + */ + colors?: string[] + /** + * Margin of each the container + */ + margin?: Spacing + /** + * Change the opacity of the non-selected field + * @default 0.2 + */ + filterOpacity?: number + /** + * Function to format X label + */ + xFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string + /** + * Function to format Y label + */ + yFormatter?: (tick: number | Date, i: number, ticks: number[] | Date[]) => string + /** + * Controls the visibility of the X axis. + * @default true + */ + showXAxis?: boolean + /** + * Controls the visibility of the Y axis. + * @default true + */ + showYAxis?: boolean + /** + * Controls the visibility of tooltip. + * @default true + */ + showTooltip?: boolean + /** + * Controls the visibility of legend. + * @default true + */ + showLegend?: boolean + /** + * Controls the visibility of gridline. + * @default true + */ + showGridLine?: boolean +} diff --git a/apps/www/src/lib/registry/new-york/example/AreaChartCustomTooltip.vue b/apps/www/src/lib/registry/new-york/example/AreaChartCustomTooltip.vue new file mode 100644 index 00000000..80e76039 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AreaChartCustomTooltip.vue @@ -0,0 +1,23 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/AreaChartDemo.vue b/apps/www/src/lib/registry/new-york/example/AreaChartDemo.vue new file mode 100644 index 00000000..105be1cb --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AreaChartDemo.vue @@ -0,0 +1,17 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/AreaChartSparkline.vue b/apps/www/src/lib/registry/new-york/example/AreaChartSparkline.vue new file mode 100644 index 00000000..96e557db --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/AreaChartSparkline.vue @@ -0,0 +1,33 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/BarChartCustomTooltip.vue b/apps/www/src/lib/registry/new-york/example/BarChartCustomTooltip.vue new file mode 100644 index 00000000..0e514127 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/BarChartCustomTooltip.vue @@ -0,0 +1,28 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/BarChartDemo.vue b/apps/www/src/lib/registry/new-york/example/BarChartDemo.vue new file mode 100644 index 00000000..0d68f9b3 --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/BarChartDemo.vue @@ -0,0 +1,26 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/BarChartRounded.vue b/apps/www/src/lib/registry/new-york/example/BarChartRounded.vue new file mode 100644 index 00000000..e5e4280d --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/BarChartRounded.vue @@ -0,0 +1,27 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/BarChartStacked.vue b/apps/www/src/lib/registry/new-york/example/BarChartStacked.vue new file mode 100644 index 00000000..c139d47c --- /dev/null +++ b/apps/www/src/lib/registry/new-york/example/BarChartStacked.vue @@ -0,0 +1,27 @@ + + + diff --git a/apps/www/src/lib/registry/new-york/example/CardStats.vue b/apps/www/src/lib/registry/new-york/example/CardStats.vue index e95ebb2c..cfb00c9f 100644 --- a/apps/www/src/lib/registry/new-york/example/CardStats.vue +++ b/apps/www/src/lib/registry/new-york/example/CardStats.vue @@ -1,10 +1,8 @@