/
preview.js
34 lines (31 loc) · 1.04 KB
/
preview.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import '@ni/nimble-tokens/source/space-mono-font-face.css';
import '@ni/nimble-tokens/source/source-sans-pro-font-face.css';
import '../dist/esm/theme-provider';
import { backgroundStates } from '../dist/esm/utilities/tests/matrix';
const [defaultBackground] = backgroundStates;
export const parameters = {
backgrounds: {
default: defaultBackground.name,
values: backgroundStates.map(({ name, value }) => ({ name, value }))
},
options: {
storySort: {
order: ['Getting Started']
}
},
controls: {
expanded: true
}
};
export const decorators = [
(story, context) => {
const background = backgroundStates.find(
({ value }) => value === context.globals?.backgrounds?.value
) ?? defaultBackground;
const tale = story();
if (typeof tale !== 'string') {
throw new Error('Expected story to render as string');
}
return `<nimble-theme-provider theme="${background.theme}">${tale}</nimble-theme-provider>`;
}
];