Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
13 changes: 13 additions & 0 deletions samples/sampler/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ const skins = {
'Light': 'light'
};

const screenScale = {
'1': 1,
'1.2': 1.2,
'1.4': 1.4,
'1.6': 1.6,
'1.8': 1.8,
'2': 2,
'3': 3,
'4': 4,
'5': 5
};

configureActions();

if (process.env.STORYBOOK_APPLY_GA_COOKIEBANNER) {
Expand Down Expand Up @@ -91,6 +103,7 @@ export const globalTypes = {
'large text': getBooleanType('large text'),
'high contrast': getBooleanType('high contrast'),
'focus ring':getBooleanType('focus ring'),
'screen scale': getObjectType('screen scale', 1, screenScale),
'skin': getObjectType('skin', 'neutral', skins),
'background': getObjectType('background', 'default', backgrounds),
'debug aria': getBooleanType('debug aria'),
Expand Down
8 changes: 3 additions & 5 deletions samples/sampler/src/ThemeEnvironment/ThemeEnvironment.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ const PanelsBase = kind({

const Theme = ThemeDecorator({overlay: false}, PanelsBase);

const StorybookDecorator = (story, config = {}) => {
// Executing `story` here allows the story controls to register and render before the global variable below.
const sample = story();

const StorybookDecorator = (Story, config = {}) => {
const {globals} = config;

const componentName = config.kind.replace(/^([^/]+)\//, '');
Expand Down Expand Up @@ -74,13 +71,14 @@ const StorybookDecorator = (story, config = {}) => {
textSize={JSON.parse(globals['large text']) ? 'large' : 'normal'}
focusRing={JSON.parse(globals['focus ring'])}
highContrast={JSON.parse(globals['high contrast'])}
screenScale={JSON.parse(globals['screen scale'])}
style={{
'--sand-env-background': globals.background === 'default' ? '' : globals.background
}}
skin={globals.skin}
{...hasProps ? config.parameters.props : null}
>
{sample}
<Story />
</Theme>
);
};
Expand Down