Skip to content

Commit 77155b8

Browse files
authored
Merge pull request #2 from BuildCanada/feat/buildcanada-components
Add @buildcanada/components package with Chromatic visual testing
2 parents 3f53674 + 4a3c7ab commit 77155b8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+7094
-20
lines changed

.github/workflows/ci.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,34 @@ jobs:
5959
name: storybook-static
6060
path: storybook-static/
6161
retention-days: 7
62+
63+
chromatic:
64+
runs-on: ubuntu-latest
65+
needs: build
66+
steps:
67+
- name: Clone repository
68+
uses: actions/checkout@v5
69+
with:
70+
fetch-depth: 0
71+
72+
- name: Setup Bun
73+
uses: oven-sh/setup-bun@v2
74+
with:
75+
bun-version: latest
76+
77+
- name: Install dependencies
78+
run: bun install --frozen-lockfile
79+
80+
- name: Download Storybook artifact
81+
uses: actions/download-artifact@v4
82+
with:
83+
name: storybook-static
84+
path: storybook-static/
85+
86+
- name: Run Chromatic
87+
uses: chromaui/action@latest
88+
with:
89+
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
90+
storybookBuildDir: storybook-static
91+
exitZeroOnChanges: true
92+
onlyChanged: true

.storybook/helpers/grapherStateFactory.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export function createStorybookGrapherState(
2020
): GrapherState {
2121
return LifeExpectancyGrapher({
2222
bounds: new Bounds(0, 0, 1100, 660),
23+
selectedEntityNames: ["Canada", "United States", "Germany", "Japan"],
2324
...overrides,
2425
})
2526
}
@@ -33,6 +34,7 @@ export function createLineChartState(
3334
return LifeExpectancyGrapher({
3435
bounds: new Bounds(0, 0, 1100, 660),
3536
chartTypes: [GRAPHER_CHART_TYPES.LineChart],
37+
selectedEntityNames: ["Canada", "United States", "Germany", "Japan"],
3638
...overrides,
3739
})
3840
}
@@ -46,6 +48,16 @@ export function createDiscreteBarChartState(
4648
return LifeExpectancyGrapher({
4749
bounds: new Bounds(0, 0, 1100, 660),
4850
chartTypes: [GRAPHER_CHART_TYPES.DiscreteBar],
51+
selectedEntityNames: [
52+
"Japan",
53+
"Canada",
54+
"Germany",
55+
"United States",
56+
"Brazil",
57+
"China",
58+
"India",
59+
"Nigeria",
60+
],
4961
...overrides,
5062
})
5163
}
@@ -59,6 +71,7 @@ export function createStackedAreaChartState(
5971
return LifeExpectancyGrapher({
6072
bounds: new Bounds(0, 0, 1100, 660),
6173
chartTypes: [GRAPHER_CHART_TYPES.StackedArea],
74+
selectedEntityNames: ["Canada", "United States", "Germany", "Japan", "Brazil"],
6275
...overrides,
6376
})
6477
}
@@ -72,6 +85,7 @@ export function createStackedBarChartState(
7285
return LifeExpectancyGrapher({
7386
bounds: new Bounds(0, 0, 1100, 660),
7487
chartTypes: [GRAPHER_CHART_TYPES.StackedBar],
88+
selectedEntityNames: ["Canada", "United States", "Germany", "Japan", "Brazil"],
7589
...overrides,
7690
})
7791
}
@@ -85,6 +99,7 @@ export function createSlopeChartState(
8599
return LifeExpectancyGrapher({
86100
bounds: new Bounds(0, 0, 1100, 660),
87101
chartTypes: [GRAPHER_CHART_TYPES.SlopeChart],
102+
selectedEntityNames: ["Canada", "United States", "Germany", "Japan", "Brazil", "China"],
88103
...overrides,
89104
})
90105
}
@@ -98,6 +113,7 @@ export function createScatterPlotState(
98113
return LifeExpectancyGrapher({
99114
bounds: new Bounds(0, 0, 1100, 660),
100115
chartTypes: [GRAPHER_CHART_TYPES.ScatterPlot],
116+
selectedEntityNames: ["Canada", "United States", "Germany", "Japan", "Brazil", "China", "India"],
101117
...overrides,
102118
})
103119
}

.storybook/main.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,19 @@ const config: StorybookConfig = {
66
"./docs/**/*.mdx",
77
"../packages/charts/src/**/*.stories.@(ts|tsx)",
88
"../packages/colours/src/**/*.stories.@(ts|tsx)",
9+
"../packages/components/src/**/*.stories.@(ts|tsx)",
910
],
10-
addons: ["@storybook/addon-docs"],
11+
addons: ["@storybook/addon-docs", "@storybook/addon-interactions"],
1112
framework: {
1213
name: "@storybook/react-vite",
1314
options: {},
1415
},
16+
staticDirs: [
17+
{
18+
from: "../packages/components/src/assets",
19+
to: "/assets",
20+
},
21+
],
1522
typescript: {
1623
// Disable react-docgen because the codebase uses MobX decorators
1724
// (@observer before export) which aren't compatible with react-docgen
@@ -75,7 +82,10 @@ const config: StorybookConfig = {
7582
css: {
7683
preprocessorOptions: {
7784
scss: {
78-
includePaths: ["./packages/charts/src"],
85+
includePaths: [
86+
"./packages/charts/src",
87+
"./packages/components/src",
88+
],
7989
silenceDeprecations: ["import"],
8090
},
8191
},

.storybook/preview.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { Preview } from "@storybook/react"
33
import { ChartsDecorator } from "./decorators/ChartsDecorator"
44

55
import "../packages/charts/src/styles/charts.scss"
6+
import "../packages/components/src/styles/main.scss"
67

78
const preview: Preview = {
89
decorators: [ChartsDecorator],
@@ -14,10 +15,12 @@ const preview: Preview = {
1415
},
1516
},
1617
backgrounds: {
17-
default: "light",
18+
default: "linen",
1819
values: [
19-
{ name: "light", value: "#ffffff" },
20+
{ name: "linen", value: "#F6ECE3" },
21+
{ name: "white", value: "#ffffff" },
2022
{ name: "gray", value: "#f5f5f5" },
23+
{ name: "charcoal", value: "#272727" },
2124
{ name: "dark", value: "#1a1a1a" },
2225
],
2326
},

0 commit comments

Comments
 (0)