Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
57aeca0
chore(mosaic): add d3-scale and d3-shape for the bar chart primitive
austincalvelage Nov 23, 2026
fa7b8ad
feat(mosaic): port the bar chart layout, canvas, selection and tick m…
austincalvelage Nov 23, 2026
f85e0fe
feat(mosaic): add the BarChart primitive parts and tooltip
austincalvelage Nov 23, 2026
a8f5c29
test(mosaic): cover bar chart painting, resizing, pointer selection a…
austincalvelage Nov 23, 2026
352a35d
test(mosaic): add bar chart screenshot tests
austincalvelage Nov 23, 2026
98803c1
docs(mosaic): document the BarChart primitive
austincalvelage Nov 23, 2026
646c21d
docs(swingset): add the BarChart primitive page
austincalvelage Nov 23, 2026
76a860f
feat(mosaic): add BarChart.useBarChart and render the parts from its …
austincalvelage Nov 23, 2026
73a8dce
docs(mosaic): document BarChart.useBarChart, its chart object and con…
austincalvelage Nov 23, 2026
734102a
docs(swingset): move the BarChart page to useBarChart
austincalvelage Nov 23, 2026
cfab5b7
refactor(mosaic): run bar chart selection through a generic engine an…
austincalvelage Nov 23, 2026
dcbfa91
refactor(mosaic): move the shared chart parts into a Chart primitive
austincalvelage Nov 23, 2026
347e0cf
docs(mosaic,swingset): document the Chart parts and the BarChart marks
austincalvelage Nov 23, 2026
093dcf6
fix(mosaic): end a pointer or keyboard chart selection when its surfa…
austincalvelage Nov 23, 2026
037d5b1
test(mosaic): check that the bar chart repaints on theme and pixel ra…
austincalvelage Nov 23, 2026
9a78f67
docs(mosaic): note that emptied data ends a pointer or keyboard chart…
austincalvelage Nov 23, 2026
5094e68
perf(mosaic): memoize the Chart.Root context value
austincalvelage Nov 23, 2026
a536d6b
fix(mosaic): repaint bar chart when an ancestor theme or color scheme…
austincalvelage Nov 23, 2026
27cb673
refactor(mosaic): move CanvasRenderError into a module with no imports
austincalvelage Nov 23, 2026
42c7954
feat(mosaic): publish the Chart and BarChart primitives
austincalvelage Nov 23, 2026
bb9ee9d
refactor(mosaic): fold the BarChart primitive into Chart
austincalvelage Nov 23, 2026
a58720c
fix(mosaic): trace the projection fill with a concentric, crisp outline
austincalvelage Nov 23, 2026
9452a77
fix(mosaic): repaint bar chart when a theme switches through any ance…
austincalvelage Nov 23, 2026
790a13d
chore(repo): dedupe the lockfile
austincalvelage Nov 23, 2026
07e1275
fix(mosaic): paint the projection outline on the Canvas, snapped to d…
austincalvelage Nov 23, 2026
1fdc34e
docs(swingset): show Dashboard's weekly active users in the chart pri…
austincalvelage Nov 23, 2026
6a3edd9
docs(swingset): leave churn out of the week in progress, as Dashboard…
austincalvelage Nov 23, 2026
6004e42
refactor(mosaic): rename Chart.StackedBars to Chart.Bars
austincalvelage Nov 24, 2026
5670387
fix(mosaic): follow the primitive conventions in the Chart primitive
austincalvelage Nov 24, 2026
ed1f796
fix(mosaic): select only on bars, announce bar values, and split out …
austincalvelage Nov 25, 2026
9049acf
feat(mosaic): compose the chart tooltip from the Tooltip parts, and r…
austincalvelage Nov 25, 2026
8ef4ea8
fix(mosaic): center category labels under their bars unless they woul…
austincalvelage Nov 25, 2026
f32c683
feat(mosaic): mark the chart cursor when the keyboard selected its ca…
austincalvelage Nov 25, 2026
3aa491a
refactor(mosaic): render the chart tooltip as one element again
austincalvelage Nov 25, 2026
d906b2b
feat(mosaic): outline the keyboard-selected bar section, not the whol…
austincalvelage Nov 25, 2026
3977274
fix(mosaic): select the whole column under the pointer again
austincalvelage Nov 25, 2026
bd0b3c4
feat(mosaic): outline the keyboard-selected section's painted bars
austincalvelage Nov 25, 2026
7eed3a4
revert(mosaic): drop the chart's keyboard focus ring changes
austincalvelage Nov 26, 2026
fd5318b
perf(mosaic): measure the chart when it attaches, not at the first Re…
austincalvelage Nov 26, 2026
52c0462
fix(mosaic): read the restricted imports from the mosaic lint config
austincalvelage Dec 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .changeset/mosaic-chart-primitive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
'@clerk/mosaic': minor
---

Add a headless `Chart` primitive for stacked bar charts with values above and below zero. `Chart.useBarChart` lays out the bars and owns pointer and keyboard selection, `Chart.Bars` paints them on Canvas, and the shared `Chart` parts add the grid, axes, cursor and tooltip. The parts ship no styles: style `Chart.Bar` and each other part with `className` and `data-*` attributes.

```tsx
import { Chart } from '@clerk/mosaic/primitives/chart';

const chart = Chart.useBarChart({ data, series, index });

<Chart.Root chart={chart} aria-label='Weekly sign-ups'>
<Chart.Bars>
<Chart.Bar className='bar' />
</Chart.Bars>
<Chart.XAxis>{ticks => ticks.map(tick => <Chart.XTick key={tick.key} tick={tick} />)}</Chart.XAxis>
</Chart.Root>;
```

`d3-scale` and `d3-shape` are new dependencies of `@clerk/mosaic/primitives/chart`.
78 changes: 56 additions & 22 deletions packages/mosaic/oxlint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,26 @@ import noUnneededEffects from 'eslint-plugin-react-you-might-not-need-an-effect'
import { defineConfig } from 'oxlint';

const mosaicRoot = import.meta.dirname;
const restrictedImports = {
paths: [
{
message: "Please always import from '@clerk/shared/<module>' instead of '@clerk/shared'.",
name: '@clerk/shared',
},
],
patterns: [
{
group: ['!@clerk/shared/*'],
message: 'ignore this line -- eslint matching workaround to allow all imports except @clerk/shared',
},
{
group: ['@emotion/*'],
message: 'Please do not import emotion directly. Import helpers from ./design-system or ./primitives instead.',
},
],
};
const chartInternalMessage =
'The chart selection engine is for chart-type hooks. Import it only from a chart-type folder under src/primitives/chart/, such as chart/bars/.';
const SHARED = ['primitives', 'icons', 'machine', 'utils', 'hooks', 'styles', 'components', 'localization', 'root'];
const FLOW_UI = { file: { categories: { anyOf: ['view', 'controller'] } } };
const CLERK_DATA_HOOKS = [
Expand Down Expand Up @@ -298,28 +318,7 @@ export default defineConfig({
'custom-rules/no-unstable-methods': 'error',
'custom-rules/no-raw-inert': 'error',
'no-label-var': 'error',
'no-restricted-imports': [
'error',
{
paths: [
{
message: "Please always import from '@clerk/shared/<module>' instead of '@clerk/shared'.",
name: '@clerk/shared',
},
],
patterns: [
{
group: ['!@clerk/shared/*'],
message: 'ignore this line -- eslint matching workaround to allow all imports except @clerk/shared',
},
{
group: ['@emotion/*'],
message:
'Please do not import emotion directly. Import helpers from ./design-system or ./primitives instead.',
},
],
},
],
'no-restricted-imports': ['error', restrictedImports],
'react/button-has-type': 'error',
'react/jsx-boolean-value': 'error',
'react/jsx-fragments': 'error',
Expand Down Expand Up @@ -471,6 +470,41 @@ export default defineConfig({
'no-unused-vars': 'off',
},
},
{
files: ['src/**/*'],
excludeFiles: ['src/primitives/chart/**', 'src/**/__tests__/**', 'src/**/*.test.{ts,tsx}', 'src/**/*.test-d.ts'],
rules: {
'no-restricted-imports': [
'error',
{
...restrictedImports,
patterns: [
...restrictedImports.patterns,
{
group: ['**/chart/internal', '**/chart/internal/*'],
message: chartInternalMessage,
},
],
},
],
},
},
{
files: ['src/primitives/chart/*'],
excludeFiles: ['src/**/*.test.{ts,tsx}', 'src/**/*.test-d.ts'],
rules: {
'no-restricted-imports': [
'error',
{
...restrictedImports,
patterns: [
...restrictedImports.patterns,
{ group: ['./internal', './internal/*'], message: chartInternalMessage },
],
},
],
},
},
{
files: [
'src/primitives/file-upload/file-upload-dropzone.tsx',
Expand Down
11 changes: 10 additions & 1 deletion packages/mosaic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,11 @@
"import": "./dist/primitives/button.js",
"default": "./dist/primitives/button.js"
},
"./primitives/chart": {
"types": "./dist/primitives/chart.d.ts",
"import": "./dist/primitives/chart.js",
"default": "./dist/primitives/chart.js"
},
"./primitives/collapsible": {
"types": "./dist/primitives/collapsible.d.ts",
"import": "./dist/primitives/collapsible.js",
Expand Down Expand Up @@ -537,7 +542,9 @@
},
"dependencies": {
"@clerk/shared": "workspace:^",
"@floating-ui/react": "catalog:repo"
"@floating-ui/react": "catalog:repo",
"d3-scale": "4.0.2",
"d3-shape": "3.2.0"
},
"devDependencies": {
"@clerk/clerk-js": "workspace:^",
Expand All @@ -549,6 +556,8 @@
"@testing-library/jest-dom": "^6.9.1",
"@testing-library/react": "^16.3.2",
"@testing-library/user-event": "^14.6.5",
"@types/d3-scale": "4.0.9",
"@types/d3-shape": "3.1.7",
"@types/react": "catalog:react",
"@types/react-dom": "catalog:react",
"@wallet-standard/core": "catalog:module-manager",
Expand Down
Loading
Loading