Skip to content

Commit a802336

Browse files
authored
updated the storybook to support the new themeing changes (#583)
1 parent e86e43e commit a802336

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

.storybook/preview.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ import { CssBaseline } from '@mui/material';
55
import { getSdkComponentMap } from '@pega/react-sdk-components/lib/bridge/helpers/sdk_component_map';
66
import { theme } from '../src/theme';
77

8+
import sdkConfig from '../sdk-config.json';
9+
import { themes as sbThemes } from '@storybook/theming';
10+
811
import { decorator } from '../__mocks__/react_pconnect';
912
import setPCoreMocks from '../__mocks__/pcoreMocks';
1013

@@ -16,6 +19,10 @@ if (!isConstellation) {
1619

1720
setPCoreMocks();
1821

22+
const isDark = String(sdkConfig?.theme).toLowerCase() === 'dark';
23+
24+
const CANVAS_COLOR = (theme as any).backgroundColor || (isDark ? '#060326' : 'whitesmoke');
25+
1926
const decorators = [
2027
(Story, context) => {
2128
return isConstellation ? (
@@ -40,25 +47,14 @@ const decorators = [
4047
decorator
4148
];
4249

43-
const parameters = {
50+
// 3) Set canvas and Docs chrome
51+
const parameters: Preview['parameters'] = {
4452
backgrounds: {
4553
default: 'App',
46-
values: [
47-
{
48-
name: 'App',
49-
value: WorkTheme.base.palette['app-background']
50-
},
51-
{
52-
name: 'Primary',
53-
value: WorkTheme.base.palette['primary-background']
54-
},
55-
{
56-
name: 'Secondary',
57-
value: WorkTheme.base.palette['secondary-background']
58-
}
59-
]
54+
values: [{ name: 'App', value: CANVAS_COLOR }]
6055
},
6156
docs: {
57+
theme: isDark ? sbThemes.dark : sbThemes.light,
6258
source: { type: 'code' },
6359
codePanel: true
6460
}

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"noImplicitAny": false,
1414
"allowSyntheticDefaultImports": true,
1515
"esModuleInterop": true,
16+
"resolveJsonModule": true,
1617

1718
// Need to specify typeRoots to find the types and types to constrain
1819
// where to look in @pega (to only get pcore-pconnect-typedefs)

0 commit comments

Comments
 (0)