Skip to content

Commit e8eab83

Browse files
fix storybook
1 parent 3264c03 commit e8eab83

File tree

3 files changed

+73
-11
lines changed

3 files changed

+73
-11
lines changed

docs/storybook/stories/Color/DataVis/Charts.stories.tsx

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ export default {
1717
}
1818

1919
export const HighchartsAccentColors = () => {
20-
const data = getTokensByName(colorTokens, 'data').map(token => {
21-
console.log(token)
22-
23-
return {
24-
id: token.name,
25-
...token,
26-
}
27-
})
20+
const data = getTokensByName(colorTokens, 'data')
21+
.filter(({type}) => type === 'color')
22+
.map(token => {
23+
return {
24+
id: token.name,
25+
...token,
26+
}
27+
})
2828
return (
2929
<Table.Container>
3030
<Table.Title as="h1" id="pattern">
31-
Data visualization
31+
Data visualization colors
3232
</Table.Title>
3333
<DataTable
3434
aria-labelledby="pattern"
@@ -63,3 +63,53 @@ export const HighchartsAccentColors = () => {
6363
</Table.Container>
6464
)
6565
}
66+
67+
export const HighchartsGradients = () => {
68+
const data = getTokensByName(colorTokens, 'data')
69+
.filter(({type}) => type === 'gradient')
70+
.map(token => {
71+
console.log(token)
72+
73+
return {
74+
id: token.name,
75+
...token,
76+
}
77+
})
78+
return (
79+
<Table.Container>
80+
<Table.Title as="h1" id="pattern">
81+
Data visualization gradients
82+
</Table.Title>
83+
<DataTable
84+
aria-labelledby="pattern"
85+
data={data}
86+
columns={[
87+
{
88+
header: 'Sample',
89+
field: 'name',
90+
rowHeader: true,
91+
renderCell: row => {
92+
return <ColorTokenSwatch gradientStops={row.value} />
93+
},
94+
},
95+
{
96+
header: 'Token',
97+
field: 'name',
98+
rowHeader: true,
99+
renderCell: row => {
100+
return <InlineCode value={row.name} copyClipboard cssVar />
101+
},
102+
},
103+
{
104+
header: 'Output value',
105+
field: 'value',
106+
rowHeader: true,
107+
renderCell: row => {
108+
return <p>{row.value.map(({color, position}) => `${color} ${position * 100}%`).join(', ')}</p>
109+
},
110+
},
111+
]}
112+
/>
113+
</Table.Container>
114+
)
115+
}

docs/storybook/stories/StorybookComponents/ColorTokenSwatch/ColorTokenSwatch.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export type ColorTokenSwatchProps = {
88
shadowColor?: string
99
outlineColor?: string
1010
selectionColor?: string
11+
gradientStops?: Record<string, number>[]
12+
gradientAngle?: number
1113
size?: 'default' | 'large'
1214
}
1315

@@ -18,6 +20,8 @@ export function ColorTokenSwatch({
1820
shadowColor,
1921
outlineColor,
2022
selectionColor,
23+
gradientStops,
24+
gradientAngle = 180,
2125
size = 'default',
2226
}: ColorTokenSwatchProps) {
2327
return (
@@ -29,6 +33,14 @@ export function ColorTokenSwatch({
2933
)}
3034
{borderColor && <div style={{borderColor: `var(--${borderColor})`}} className="ColorTokenSwatch-border"></div>}
3135
{bgColor && <div style={{backgroundColor: `var(--${bgColor})`}} className="ColorTokenSwatch-bg"></div>}
36+
{gradientStops && (
37+
<div
38+
style={{
39+
background: `linear-gradient(${gradientAngle}deg, ${gradientStops.map(({color, position}) => `${color} ${position * 100}%`).join(', ')})`,
40+
}}
41+
className="ColorTokenSwatch-bg"
42+
></div>
43+
)}
3244
{shadowColor && <div style={{boxShadow: `var(--${shadowColor})`}} className="ColorTokenSwatch-shadow"></div>}
3345
{outlineColor && (
3446
<div style={{outlineColor: `var(--${outlineColor})`}} className="ColorTokenSwatch-outline"></div>

src/tokens/functional/color/data-vis.json5

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@
6060
$type: 'gradient',
6161
$value: [
6262
{
63-
color: '{data.blue.color.gradient-stop-1}',
63+
color: '{data.blue.color.gradientStop.1}',
6464
position: 0,
6565
},
6666
{
67-
color: '{data.blue.color.gradient-stop-2}',
67+
color: '{data.blue.color.gradientStop.2}',
6868
position: 1,
6969
},
7070
],

0 commit comments

Comments
 (0)