@neo4j-ndl/react-charts 1.2.11 → 1.2.12

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@neo4j-ndl/react-charts",
3
- "version": "1.2.11",
3
+ "version": "1.2.12",
4
4
  "sideEffects": false,
5
5
  "description": "React implementation of charts from Neo4j Design System",
6
6
  "keywords": [
@@ -56,8 +56,8 @@
56
56
  "peerDependencies": {
57
57
  "react": ">=19.0.0",
58
58
  "react-dom": ">=19.0.0",
59
- "@neo4j-ndl/base": "^4.19.0",
60
- "@neo4j-ndl/react": "^4.20.0"
59
+ "@neo4j-ndl/react": "^4.20.1",
60
+ "@neo4j-ndl/base": "^4.19.0"
61
61
  },
62
62
  "dependencies": {
63
63
  "classnames": "2.5.1",
@@ -41,14 +41,45 @@ Use Neo4j Needle React Charts instead of hand-rolling chart components.
41
41
  exists, confirm it in the component's props here or the TypeScript types, and
42
42
  consult the ECharts option reference (https://echarts.apache.org/en/option.html)
43
43
  for supported behavior.
44
+ - **Customize via component props first.** The same escape-hatch order as
45
+ `ndl-react` applies to surrounding UI from `@neo4j-ndl/react`: component
46
+ props → `className` (verify against the stylesheet) → `htmlAttributes` for
47
+ native HTML/ARIA/`data-*` the component doesn't expose. See the `ndl-react`
48
+ skill for the full rule.
49
+ - **Tokens only.** Never hardcode `hex`, `rgb()`, `oklch()`, or arbitrary
50
+ Tailwind color values in chart options or surrounding UI. Chart colors should
51
+ reference Needle's data-viz tokens (`tokens.categorical`, `tokens.graph`) or
52
+ the semantic `--theme-color-*` custom properties so they adapt to the active
53
+ theme. For layout and surrounding UI, use `Flex`, `Box`, `Typography` from
54
+ `@neo4j-ndl/react` with typed token props rather than utility classes. See
55
+ [references/styling.md](references/styling.md) for the complete token catalog.
56
+ - **Class names are unchecked strings.** The same rule from the `ndl-react`
57
+ skill applies: verify any `n-*` utility class against
58
+ `node_modules/@neo4j-ndl/base/lib/neo4j-ds-styles.css` before using it. Prefer
59
+ `Flex`, `Box`, and `Typography` component props over utility classes.
44
60
  - Follow the accessibility guidance in each component's doc; don't strip built-in
45
61
  roles or keyboard behavior.
46
62
 
63
+ ## Reuse before you create
64
+
65
+ Before hand-rolling a chart wrapper or custom visualization, check whether the
66
+ `Chart` component already covers the need. The `Chart` component wraps Apache
67
+ ECharts and supports the full ECharts option API — confirm the capability in
68
+ `components/charts.md` before building custom rendering.
69
+
70
+ For surrounding UI (buttons, inputs, layout, feedback), reuse components from
71
+ `@neo4j-ndl/react` rather than creating new ones. See the `ndl-react` skill for
72
+ the full component catalog.
73
+
47
74
  ## How to use this skill
48
75
 
49
76
  1. Find the component in the catalog below to get its docs file and import path.
50
77
  2. Read `components/<file>` for that component's props, accessibility
51
78
  requirements, and runnable examples; prefer those examples.
79
+ 3. For styling — token names, utility class lists, prefix rules — consult
80
+ [references/styling.md](references/styling.md). It points at the shipped
81
+ stylesheet so class and token lists can't drift from what the package
82
+ actually ships.
52
83
 
53
84
  ## Components
54
85
 
@@ -0,0 +1,142 @@
1
+ # Styling reference
2
+
3
+ The stylesheet is the source of truth for which classes and custom properties
4
+ exist. **Never hardcode a class name or token value from memory** — verify it
5
+ against the shipped CSS first.
6
+
7
+ ## Where the stylesheet lives
8
+
9
+ ```
10
+ node_modules/@neo4j-ndl/base/lib/neo4j-ds-styles.css
11
+ ```
12
+
13
+ When checking whether a class or custom property exists, grep the built file —
14
+ not the source `.pcss` — because Tailwind tree-shakes classes that no source
15
+ file uses.
16
+
17
+ ### Quick verification
18
+
19
+ ```sh
20
+ CSS=node_modules/@neo4j-ndl/base/lib/neo4j-ds-styles.css
21
+ grep -qE '\.n-flex\b' "$CSS" && echo "exists" || echo "MISSING"
22
+ grep -qE -- '--space-8:' "$CSS" && echo "exists" || echo "MISSING"
23
+ ```
24
+
25
+ ## Tokens only — never raw color values
26
+
27
+ Chart colors and surrounding UI must **never** contain hardcoded `hex`,
28
+ `rgb()`, `oklch()`, or arbitrary Tailwind color values. All colors come from
29
+ Needle's token system:
30
+
31
+ ### Chart-specific tokens
32
+
33
+ For ECharts color options, import the token object and reference data-viz
34
+ tokens:
35
+
36
+ ```tsx
37
+ import { tokens } from '@neo4j-ndl/base';
38
+
39
+ // Categorical series colors
40
+ const seriesColors = Object.values(tokens.categorical);
41
+
42
+ // Graph palette
43
+ const nodeColor = tokens.graph.nodeDefault;
44
+ ```
45
+
46
+ These are raw palette values appropriate for chart series, not theme-aware
47
+ semantic colors.
48
+
49
+ ### Semantic theme tokens (for surrounding UI)
50
+
51
+ For layout, labels, and controls around the chart, use semantic custom
52
+ properties that adapt to light/dark theme:
53
+
54
+ ```css
55
+ /* ✅ Token — adapts to theme */
56
+ color: var(--theme-color-neutral-text-default);
57
+ background: var(--theme-color-primary-bg-weak);
58
+
59
+ /* ❌ Hardcoded — breaks dark mode */
60
+ color: #1a1b1d;
61
+ background: rgb(10 97 144);
62
+ ```
63
+
64
+ | Family | CSS custom property prefix |
65
+ |--------|---------------------------|
66
+ | Neutral | `--theme-color-neutral-*` |
67
+ | Primary | `--theme-color-primary-*` |
68
+ | Danger | `--theme-color-danger-*` |
69
+ | Warning | `--theme-color-warning-*` |
70
+ | Success | `--theme-color-success-*` |
71
+ | Discovery | `--theme-color-discovery-*` |
72
+
73
+ Each family provides: `text`, `icon`, `bg-weak`, `bg-strong`, `bg-status`,
74
+ `border-strong`, `border-weak` (primary/danger also have `hover-*`,
75
+ `pressed-*`).
76
+
77
+ ### Space and border-radius tokens
78
+
79
+ | Token | Value |
80
+ |-------|-------|
81
+ | `--space-2` | 2px |
82
+ | `--space-4` | 4px |
83
+ | `--space-6` | 6px |
84
+ | `--space-8` | 8px |
85
+ | `--space-12` | 12px |
86
+ | `--space-16` | 16px |
87
+ | `--space-20` | 20px |
88
+ | `--space-24` | 24px |
89
+ | `--space-32` | 32px |
90
+ | `--space-48` | 48px |
91
+ | `--space-64` | 64px |
92
+
93
+ | Token | Value |
94
+ |-------|-------|
95
+ | `--border-radius-none` | 0 |
96
+ | `--border-radius-sm` | 4px |
97
+ | `--border-radius-md` | 6px |
98
+ | `--border-radius-lg` | 8px |
99
+ | `--border-radius-xl` | 12px |
100
+ | `--border-radius-2xl` | 16px |
101
+ | `--border-radius-3xl` | 24px |
102
+ | `--border-radius-full` | 9999px |
103
+
104
+ Prefer `Flex`, `Box`, and `Typography` from `@neo4j-ndl/react` with typed token
105
+ props over raw utility classes for layout.
106
+
107
+ ## The `n-` prefix
108
+
109
+ The Tailwind preset sets `prefix: 'n-'`. With the published preset and no
110
+ override, `n-flex`, `n-gap-4`, `n-bg-primary-bg-weak` work. If the consuming
111
+ app sets its own `prefix` (including `prefix: ''`), the app's config wins.
112
+ Check the app's `tailwind.config` before assuming `n-` is correct.
113
+
114
+ ## How to verify before writing
115
+
116
+ 1. **Check component props first.** `Flex`, `Box`, `Typography` from
117
+ `@neo4j-ndl/react` accept typed token values — prefer them over classes or
118
+ `htmlAttributes`. See the customization hierarchy below.
119
+ 2. **Check the stylesheet**: grep `neo4j-ds-styles.css` for the exact class
120
+ or property.
121
+ 3. **Never copy a class from another library** (MUI, Radix, Chakra, plain
122
+ Tailwind). They won't exist in the Needle stylesheet.
123
+
124
+ ## Customization hierarchy
125
+
126
+ When adjusting surrounding UI from `@neo4j-ndl/react`, work through these in
127
+ order. Each level is more error-prone than the one before it:
128
+
129
+ 1. **Component props** — typed, token-constrained, and type-checked. Always the
130
+ first choice. Examples: `gap="8"`, `padding="12"`, `variant="danger"`,
131
+ `size="small"`, `ariaLabel`.
132
+
133
+ 2. **`className`** — for utility classes the component doesn't cover. Verify
134
+ every class against
135
+ `node_modules/@neo4j-ndl/base/lib/neo4j-ds-styles.css`. A wrong class compiles
136
+ and silently renders nothing.
137
+
138
+ 3. **`htmlAttributes`** — escape hatch for native HTML attributes, `aria-*`, and
139
+ `data-*` the component doesn't expose as props (e.g. `id` for
140
+ `aria-controls` references, `aria-haspopup` on a trigger, `type="email"` on
141
+ a `TextInput`, `href` on `Typography` with `as="a"`). Do **not** use it to
142
+ override behavior the component already provides via props, or for styling.