@prioticket/design-system-charts 1.8.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +137 -0
- package/dist/r/chart.json +15 -0
- package/dist/r/index.json +21 -0
- package/dist/r/registry.json +21 -0
- package/dist/shadcn.css +64 -0
- package/package.json +39 -0
- package/registry.json +21 -0
package/README.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
# Prioticket Design System Charts
|
|
2
|
+
|
|
3
|
+
Charts for Prioticket React apps, built on [shadcn/ui charts](https://ui.shadcn.com/docs/components/chart) (Recharts v3) and themed by the Prioticket design tokens.
|
|
4
|
+
|
|
5
|
+
This package ships **no chart components**. shadcn's chart wrapper is one file that lands in your app, and every chart is a Recharts composition you write in your page, so there is nothing per chart type to maintain here. What this package adds is the theme:
|
|
6
|
+
|
|
7
|
+
- `shadcn.css` · a bridge stylesheet that points shadcn's chart variables at the Prioticket design tokens. Every value is a `var()` reference, so charts follow `initialize()` and `applyTheme()` live, with no re-render and no copied colours.
|
|
8
|
+
- a shadcn **registry item**, `@prioticket/chart`, that installs shadcn's own chart wrapper into your app together with this package in one command.
|
|
9
|
+
|
|
10
|
+
## Requirements
|
|
11
|
+
|
|
12
|
+
- A React app with **Tailwind CSS v4** and shadcn/ui initialised (`npx shadcn@latest init`). The wrapper is styled with Tailwind utilities, and the bridge relies on shadcn's current variable scheme where variables hold full colours (`@theme inline`). The older Tailwind v3 scheme wraps variables in `hsl()` and cannot take the hex tokens.
|
|
13
|
+
- `@prioticket/design-system-web` at the same version, with its theme stylesheet on the page. The bridge references its tokens.
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
1. Register the Prioticket registry in `components.json`. The registry is static JSON published inside this npm package; the URL below is a CDN view of the package, nothing is hosted anywhere else. Pin a version (`...design-system-charts@1.8.0/dist/...`) if you want installs to be reproducible.
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{
|
|
21
|
+
"registries": {
|
|
22
|
+
"@prioticket": "https://cdn.jsdelivr.net/npm/@prioticket/design-system-charts/dist/r/{name}.json"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Without a URL you can also add the item from the installed package:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
npm install @prioticket/design-system-charts @prioticket/design-system-web
|
|
31
|
+
npx shadcn@latest add ./node_modules/@prioticket/design-system-charts/dist/r/chart.json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
2. Add the chart:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
npx shadcn@latest add @prioticket/chart
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
This copies shadcn's `components/ui/chart.tsx` into your app, installs `recharts` and the two Prioticket packages.
|
|
41
|
+
|
|
42
|
+
3. Import the theme stylesheet and the bridge once, after your Tailwind globals (in `app/layout.tsx` for Next.js, `main.tsx` for Vite):
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
import './globals.css';
|
|
46
|
+
import '@prioticket/design-system-web/theme-with-fonts.css';
|
|
47
|
+
import '@prioticket/design-system-charts/shadcn.css';
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Use
|
|
51
|
+
|
|
52
|
+
Colour series through the palette, in fixed order, never with hardcoded colours:
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts';
|
|
56
|
+
import {
|
|
57
|
+
ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, type ChartConfig
|
|
58
|
+
} from '@/components/ui/chart';
|
|
59
|
+
|
|
60
|
+
const config = {
|
|
61
|
+
online: { label: 'Online', color: 'var(--chart-1)' },
|
|
62
|
+
boxOffice: { label: 'Box office', color: 'var(--chart-2)' }
|
|
63
|
+
} satisfies ChartConfig;
|
|
64
|
+
|
|
65
|
+
export function TicketsPerDay({ data }: { data: Array<{ day: string; online: number; boxOffice: number }> }) {
|
|
66
|
+
return (
|
|
67
|
+
<ChartContainer config={config} className="h-64 w-full">
|
|
68
|
+
<BarChart data={data}>
|
|
69
|
+
<CartesianGrid vertical={false} />
|
|
70
|
+
<XAxis dataKey="day" tickLine={false} axisLine={false} />
|
|
71
|
+
<ChartTooltip content={<ChartTooltipContent />} />
|
|
72
|
+
<ChartLegend content={<ChartLegendContent />} />
|
|
73
|
+
<Bar dataKey="online" fill="var(--color-online)" radius={4} />
|
|
74
|
+
<Bar dataKey="boxOffice" fill="var(--color-boxOffice)" radius={4} />
|
|
75
|
+
</BarChart>
|
|
76
|
+
</ChartContainer>
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Rules that keep charts readable for everyone:
|
|
82
|
+
|
|
83
|
+
- Six series slots, `var(--chart-1)` to `var(--chart-6)`, assigned in order and never cycled. A seventh category folds into "Other".
|
|
84
|
+
- Two or more series always get a legend. Series 3, 4 and 5 sit below 3:1 contrast on the surface by design, so every chart carries visible labels or a table view; colour never carries meaning alone.
|
|
85
|
+
- One y axis per chart. Two measures of different scale become two charts.
|
|
86
|
+
- Give `ChartContainer` a height (`h-64`, `min-h-*` or `aspect-*`).
|
|
87
|
+
|
|
88
|
+
## Dynamic theming
|
|
89
|
+
|
|
90
|
+
The palette lives in the web package as `--pd-chart-1` to `--pd-chart-6`. Series 1 is `var(--md-sys-color-primary)`, so a client rebrand recolours it automatically; the rest are fixed house colours that clients can override:
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { applyTheme, resetTheme } from '@prioticket/design-system-web/theming';
|
|
94
|
+
|
|
95
|
+
applyTheme({ colorPrimary: '#166534' }); // series 1 follows
|
|
96
|
+
applyTheme({ colorChart2: '#b45309' }); // set a fixed series
|
|
97
|
+
resetTheme(); // back to the stylesheet palette
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Charts that are already on screen pick the new colours up immediately, because the SVG marks read `var()` references.
|
|
101
|
+
|
|
102
|
+
## What the bridge maps
|
|
103
|
+
|
|
104
|
+
| shadcn variable | Prioticket token | Scope |
|
|
105
|
+
|---|---|---|
|
|
106
|
+
| `--chart-1` … `--chart-6` | `--pd-chart-1` … `--pd-chart-6` | global (`html:root`) |
|
|
107
|
+
| `--background`, `--popover` | `--md-sys-color-surface` | inside `[data-slot="chart"]` |
|
|
108
|
+
| `--foreground`, `--popover-foreground` | `--md-sys-color-on-surface` | inside `[data-slot="chart"]` |
|
|
109
|
+
| `--border` | `--md-sys-color-outline-variant` | inside `[data-slot="chart"]` |
|
|
110
|
+
| `--muted` (active-bar cursor) | `--md-sys-color-on-surface-hover` | inside `[data-slot="chart"]` |
|
|
111
|
+
| `--muted-foreground` (ticks, legend) | `--md-sys-color-on-surface-variant` | inside `[data-slot="chart"]` |
|
|
112
|
+
| `--radius` | `--md-sys-shape-corner-small` | inside `[data-slot="chart"]` |
|
|
113
|
+
| `color` (legend and inherited text) | `--md-sys-color-on-surface` | inside `[data-slot="chart"]` |
|
|
114
|
+
| `font-family` | `--md-sys-typescale-body-small-font` | inside `[data-slot="chart"]` |
|
|
115
|
+
| axis tick `fill` | `--md-sys-color-on-surface-variant` | direct rule on `.recharts-*-tick-value` inside the chart |
|
|
116
|
+
|
|
117
|
+
The tick rule exists because shadcn's wrapper styles ticks through `.recharts-cartesian-axis-tick text`, a class Recharts 3.8 no longer renders, so a fresh shadcn install shows ticks in Recharts' default grey. Both resolve to the same token, so the rule stays harmless once upstream catches up.
|
|
118
|
+
|
|
119
|
+
The surface, ink, border and radius overrides are scoped to the chart container so the rest of your shadcn UI keeps its own theme. The palette is global so legends and KPI tiles outside a chart can use it too. The design system ships one light theme; the palette therefore also wins over an app's `.dark` block.
|
|
120
|
+
|
|
121
|
+
## Working with Claude
|
|
122
|
+
|
|
123
|
+
Add the shadcn MCP server to the project so Claude can browse and install from the Prioticket registry:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"mcpServers": {
|
|
128
|
+
"shadcn": { "command": "npx", "args": ["shadcn@latest", "mcp"] }
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
Then ask for what you need in plain words, for example "add @prioticket/chart and build a bar chart of tickets per day, online versus box office". The registry item prints the three rules above after installing, and the `color: 'var(--chart-N)'` convention is what AI-written shadcn code already uses.
|
|
134
|
+
|
|
135
|
+
## Not for PHP or vanilla pages
|
|
136
|
+
|
|
137
|
+
Recharts is React only. A vanilla or PHP page that needs a chart uses the same `--pd-chart-N` tokens with a framework-agnostic library such as ECharts or Chart.js.
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry-item.json",
|
|
3
|
+
"name": "chart",
|
|
4
|
+
"type": "registry:ui",
|
|
5
|
+
"title": "Prioticket chart",
|
|
6
|
+
"description": "shadcn's Recharts chart wrapper, themed by the Prioticket design tokens and re-themed live by applyTheme(). Colour series with var(--chart-1) to var(--chart-6).",
|
|
7
|
+
"dependencies": [
|
|
8
|
+
"@prioticket/design-system-charts@^1.8.0-beta.4",
|
|
9
|
+
"@prioticket/design-system-web@^1.8.0-beta.4"
|
|
10
|
+
],
|
|
11
|
+
"registryDependencies": [
|
|
12
|
+
"chart"
|
|
13
|
+
],
|
|
14
|
+
"docs": "Prioticket chart installed.\n\n1. Import the bridge once, after your Tailwind globals:\n import '@prioticket/design-system-web/theme-with-fonts.css';\n import '@prioticket/design-system-charts/shadcn.css';\n2. Colour series through the palette, in fixed order, never hardcoded:\n { online: { label: 'Online', color: 'var(--chart-1)' } }\n3. Give every chart a legend (two or more series), direct labels or a table view, and one y axis.\n\nSeries 1 follows colorPrimary; colorChart1 to colorChart6 are settable through applyTheme().\nGuide: node_modules/@prioticket/design-system-charts/README.md"
|
|
15
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
3
|
+
"name": "prioticket",
|
|
4
|
+
"homepage": "https://gitlab.prioticket.dev/innovation/prioticket-design-system-web",
|
|
5
|
+
"items": [
|
|
6
|
+
{
|
|
7
|
+
"name": "chart",
|
|
8
|
+
"type": "registry:ui",
|
|
9
|
+
"title": "Prioticket chart",
|
|
10
|
+
"description": "shadcn's Recharts chart wrapper, themed by the Prioticket design tokens and re-themed live by applyTheme(). Colour series with var(--chart-1) to var(--chart-6).",
|
|
11
|
+
"dependencies": [
|
|
12
|
+
"@prioticket/design-system-charts@^1.8.0-beta.4",
|
|
13
|
+
"@prioticket/design-system-web@^1.8.0-beta.4"
|
|
14
|
+
],
|
|
15
|
+
"registryDependencies": [
|
|
16
|
+
"chart"
|
|
17
|
+
],
|
|
18
|
+
"docs": "Prioticket chart installed.\n\n1. Import the bridge once, after your Tailwind globals:\n import '@prioticket/design-system-web/theme-with-fonts.css';\n import '@prioticket/design-system-charts/shadcn.css';\n2. Colour series through the palette, in fixed order, never hardcoded:\n { online: { label: 'Online', color: 'var(--chart-1)' } }\n3. Give every chart a legend (two or more series), direct labels or a table view, and one y axis.\n\nSeries 1 follows colorPrimary; colorChart1 to colorChart6 are settable through applyTheme().\nGuide: node_modules/@prioticket/design-system-charts/README.md"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
3
|
+
"name": "prioticket",
|
|
4
|
+
"homepage": "https://gitlab.prioticket.dev/innovation/prioticket-design-system-web",
|
|
5
|
+
"items": [
|
|
6
|
+
{
|
|
7
|
+
"name": "chart",
|
|
8
|
+
"type": "registry:ui",
|
|
9
|
+
"title": "Prioticket chart",
|
|
10
|
+
"description": "shadcn's Recharts chart wrapper, themed by the Prioticket design tokens and re-themed live by applyTheme(). Colour series with var(--chart-1) to var(--chart-6).",
|
|
11
|
+
"dependencies": [
|
|
12
|
+
"@prioticket/design-system-charts@^1.8.0-beta.4",
|
|
13
|
+
"@prioticket/design-system-web@^1.8.0-beta.4"
|
|
14
|
+
],
|
|
15
|
+
"registryDependencies": [
|
|
16
|
+
"chart"
|
|
17
|
+
],
|
|
18
|
+
"docs": "Prioticket chart installed.\n\n1. Import the bridge once, after your Tailwind globals:\n import '@prioticket/design-system-web/theme-with-fonts.css';\n import '@prioticket/design-system-charts/shadcn.css';\n2. Colour series through the palette, in fixed order, never hardcoded:\n { online: { label: 'Online', color: 'var(--chart-1)' } }\n3. Give every chart a legend (two or more series), direct labels or a table view, and one y axis.\n\nSeries 1 follows colorPrimary; colorChart1 to colorChart6 are settable through applyTheme().\nGuide: node_modules/@prioticket/design-system-charts/README.md"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|
package/dist/shadcn.css
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prioticket bridge for shadcn/ui charts.
|
|
3
|
+
*
|
|
4
|
+
* shadcn's chart wrapper (Recharts v3, Tailwind v4, the current shadcn CSS-variable scheme) paints
|
|
5
|
+
* from the app's shadcn variables: --background, --foreground, --border, --muted, --muted-foreground
|
|
6
|
+
* and --radius, and colours each series through var(--chart-N). This file points those names at the
|
|
7
|
+
* Prioticket design tokens. Every value is a var() reference, so nothing is copied and every chart
|
|
8
|
+
* follows initialize() / applyTheme() at runtime without a re-render.
|
|
9
|
+
*
|
|
10
|
+
* Requirements
|
|
11
|
+
* - The Prioticket theme stylesheet is on the page (theme-only.css or theme-with-fonts.css); the
|
|
12
|
+
* tokens referenced here come from it.
|
|
13
|
+
* - Tailwind v4 with shadcn's `@theme inline` block, where variables hold full colours and utilities
|
|
14
|
+
* read them as var(--x). The older Tailwind v3 scheme wraps them in hsl() and cannot take hex.
|
|
15
|
+
*
|
|
16
|
+
* Import once, after the Tailwind/shadcn globals so the series palette wins on source order:
|
|
17
|
+
* import '@prioticket/design-system-charts/shadcn.css';
|
|
18
|
+
*
|
|
19
|
+
* Scope
|
|
20
|
+
* - The series palette is global: legends, KPI tiles and custom marks outside a chart may use
|
|
21
|
+
* var(--chart-N) too. The `html:root` selector outranks the app's `:root` and `.dark` blocks
|
|
22
|
+
* whatever the import order. The design system ships one light theme, so charts stay on it.
|
|
23
|
+
* - Surface, ink, border, radius and typeface apply only inside the chart container
|
|
24
|
+
* ([data-slot="chart"]), so the rest of the app's shadcn UI keeps its own theme.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
html:root {
|
|
28
|
+
--chart-1: var(--pd-chart-1);
|
|
29
|
+
--chart-2: var(--pd-chart-2);
|
|
30
|
+
--chart-3: var(--pd-chart-3);
|
|
31
|
+
--chart-4: var(--pd-chart-4);
|
|
32
|
+
--chart-5: var(--pd-chart-5);
|
|
33
|
+
--chart-6: var(--pd-chart-6);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
[data-slot="chart"] {
|
|
37
|
+
/* tooltip card and legend ink */
|
|
38
|
+
--background: var(--md-sys-color-surface);
|
|
39
|
+
--foreground: var(--md-sys-color-on-surface);
|
|
40
|
+
--popover: var(--md-sys-color-surface);
|
|
41
|
+
--popover-foreground: var(--md-sys-color-on-surface);
|
|
42
|
+
/* grid lines, tooltip border, dashed indicator */
|
|
43
|
+
--border: var(--md-sys-color-outline-variant);
|
|
44
|
+
/* active-bar cursor fill: the design system's hover state, not a flat grey */
|
|
45
|
+
--muted: var(--md-sys-color-on-surface-hover);
|
|
46
|
+
/* axis tick labels, legend labels, tooltip names */
|
|
47
|
+
--muted-foreground: var(--md-sys-color-on-surface-variant);
|
|
48
|
+
--radius: var(--md-sys-shape-corner-small);
|
|
49
|
+
/* legend labels and anything else that inherits its ink, instead of the app's body colour */
|
|
50
|
+
color: var(--md-sys-color-on-surface);
|
|
51
|
+
font-family: var(--md-sys-typescale-body-small-font), sans-serif;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* Axis tick labels. shadcn's wrapper paints them through `.recharts-cartesian-axis-tick text`, a
|
|
56
|
+
* class Recharts 3.8 no longer renders (ticks are `.recharts-cartesian-axis-tick-value` inside
|
|
57
|
+
* `.recharts-cartesian-axis-tick-label`), so without this rule ticks stay Recharts grey (#666).
|
|
58
|
+
* Harmless once upstream catches up: both resolve to the same token.
|
|
59
|
+
*/
|
|
60
|
+
[data-slot="chart"] .recharts-cartesian-axis-tick-value,
|
|
61
|
+
[data-slot="chart"] .recharts-polar-angle-axis-tick-value,
|
|
62
|
+
[data-slot="chart"] .recharts-polar-radius-axis-tick-value {
|
|
63
|
+
fill: var(--md-sys-color-on-surface-variant);
|
|
64
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prioticket/design-system-charts",
|
|
3
|
+
"version": "1.8.0-beta.4",
|
|
4
|
+
"description": "shadcn/ui chart registry item plus the CSS bridge that themes shadcn charts with the Prioticket design tokens",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
"./shadcn.css": "./dist/shadcn.css",
|
|
8
|
+
"./r/*": "./dist/r/*",
|
|
9
|
+
"./registry.json": "./registry.json",
|
|
10
|
+
"./package.json": "./package.json"
|
|
11
|
+
},
|
|
12
|
+
"files": [
|
|
13
|
+
"dist",
|
|
14
|
+
"registry.json",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
17
|
+
"sideEffects": [
|
|
18
|
+
"./dist/shadcn.css"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "node ../../scripts/build-charts-registry.mjs"
|
|
22
|
+
},
|
|
23
|
+
"peerDependencies": {
|
|
24
|
+
"@prioticket/design-system-web": "^1.8.0-beta.4"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"prioticket",
|
|
28
|
+
"design-system",
|
|
29
|
+
"charts",
|
|
30
|
+
"shadcn",
|
|
31
|
+
"recharts",
|
|
32
|
+
"react"
|
|
33
|
+
],
|
|
34
|
+
"author": "Prioticket",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public"
|
|
38
|
+
}
|
|
39
|
+
}
|
package/registry.json
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://ui.shadcn.com/schema/registry.json",
|
|
3
|
+
"name": "prioticket",
|
|
4
|
+
"homepage": "https://gitlab.prioticket.dev/innovation/prioticket-design-system-web",
|
|
5
|
+
"items": [
|
|
6
|
+
{
|
|
7
|
+
"name": "chart",
|
|
8
|
+
"type": "registry:ui",
|
|
9
|
+
"title": "Prioticket chart",
|
|
10
|
+
"description": "shadcn's Recharts chart wrapper, themed by the Prioticket design tokens and re-themed live by applyTheme(). Colour series with var(--chart-1) to var(--chart-6).",
|
|
11
|
+
"dependencies": [
|
|
12
|
+
"@prioticket/design-system-charts@{{version}}",
|
|
13
|
+
"@prioticket/design-system-web@{{version}}"
|
|
14
|
+
],
|
|
15
|
+
"registryDependencies": [
|
|
16
|
+
"chart"
|
|
17
|
+
],
|
|
18
|
+
"docs": "Prioticket chart installed.\n\n1. Import the bridge once, after your Tailwind globals:\n import '@prioticket/design-system-web/theme-with-fonts.css';\n import '@prioticket/design-system-charts/shadcn.css';\n2. Colour series through the palette, in fixed order, never hardcoded:\n { online: { label: 'Online', color: 'var(--chart-1)' } }\n3. Give every chart a legend (two or more series), direct labels or a table view, and one y axis.\n\nSeries 1 follows colorPrimary; colorChart1 to colorChart6 are settable through applyTheme().\nGuide: node_modules/@prioticket/design-system-charts/README.md"
|
|
19
|
+
}
|
|
20
|
+
]
|
|
21
|
+
}
|