Skip to content

Commit

Permalink
chore(demo): add StrictMode decorator (#1312)
Browse files Browse the repository at this point in the history
  • Loading branch information
jzempel committed Apr 1, 2022
1 parent 7a3308e commit 3577320
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .lintstagedrc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"*.{js,ts,tsx}": [
"stylelint",
"eslint",
"eslint --max-warnings 0 --ignore-pattern !.storybook",
"jest --config=utils/test/jest.config.js --bail --findRelatedTests",
"prettier --write"
],
Expand Down
20 changes: 18 additions & 2 deletions .storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* found at http://www.apache.org/licenses/LICENSE-2.0.
*/

import React from 'react';
import React, { StrictMode } from 'react';
import styled, { createGlobalStyle } from 'styled-components';
import { create } from '@storybook/theming/create';
import { ThemeProvider, DEFAULT_THEME } from '../packages/theming/src';
Expand Down Expand Up @@ -67,7 +67,11 @@ const withThemeProvider = (Story, context) => {
);
};

export const decorators = [withThemeProvider];
const withStrictMode = (Story, context) =>
/* eslint-disable-next-line new-cap */
context.globals.strictMode === 'enabled' ? <StrictMode>{Story()}</StrictMode> : <>{Story()}</>;

export const decorators = [withThemeProvider, withStrictMode];

export const globalTypes = {
locale: {
Expand Down Expand Up @@ -105,5 +109,17 @@ export const globalTypes = {
{ value: 'fuschia', title: 'Custom primary hue' }
]
}
},
strictMode: {
name: 'strictMode',
description: 'Strict mode',
defaultValue: 'disabled',
toolbar: {
icon: 'alert',
items: [
{ value: 'disabled', title: 'Strict mode disabled' },
{ value: 'enabled', title: 'Strict mode enabled' }
]
}
}
};

0 comments on commit 3577320

Please sign in to comment.