diff --git a/.storybook/Decorator.tsx b/.storybook/Decorator.tsx new file mode 100644 index 00000000..95ed2ba7 --- /dev/null +++ b/.storybook/Decorator.tsx @@ -0,0 +1,38 @@ +import React, { FC, ReactNode } from 'react' +import { createUseStyles } from 'react-jss' +import { ThemeType, themes } from '../src/components/assets/styles/themes' +import cn from 'classnames' +const { dark } = ThemeType + +const useStyles = createUseStyles({ + '@global': { + [`.${dark} .decorator`]: { + backgroundColor: themes[dark].background.secondary + } + }, + decorator: { + padding: '1rem' + } +}) + +export interface DecoratorProps { + children: ReactNode + classes?: string[] +} + +const Decorator: FC = ({ + children, + classes = [] +}: DecoratorProps) => { + const decoratorClasses = useStyles() + + return ( +
+ {children} +
+ ) +} + +export default Decorator diff --git a/.storybook/__tests__/Decorator.test.tsx b/.storybook/__tests__/Decorator.test.tsx new file mode 100644 index 00000000..34f5525f --- /dev/null +++ b/.storybook/__tests__/Decorator.test.tsx @@ -0,0 +1,13 @@ +import React from 'react' +import Decorator, { DecoratorProps } from '../Decorator' +import { shallow, ShallowWrapper } from 'enzyme' + +let wrapper: ShallowWrapper + +describe('Decorator', () => { + it('renders', () => { + wrapper = shallow(Decorator) + + expect(wrapper).toHaveLength(1) + }) +}) diff --git a/src/__snapshots__/storybook.test.ts.snap b/src/__snapshots__/storybook.test.ts.snap index 212c6544..c1be6a07 100644 --- a/src/__snapshots__/storybook.test.ts.snap +++ b/src/__snapshots__/storybook.test.ts.snap @@ -212,20 +212,24 @@ exports[`Storyshots Input Default 1`] = ` className="light storyWrapper-0-2-2" >
- +
+ +
`; @@ -235,20 +239,24 @@ exports[`Storyshots Input Error 1`] = ` className="light storyWrapper-0-2-2" >
- +
+ +
`; @@ -258,20 +266,24 @@ exports[`Storyshots Input Full Width 1`] = ` className="light storyWrapper-0-2-2" >
- +
+ +
`; @@ -281,16 +293,20 @@ exports[`Storyshots Input Loading 1`] = ` className="light storyWrapper-0-2-2" >
- -   - + +   + +
@@ -301,20 +317,24 @@ exports[`Storyshots Input Placeholder 1`] = ` className="light storyWrapper-0-2-2" >
- +
+ +
`; @@ -585,31 +605,31 @@ exports[`Storyshots Radio Group Loading 1`] = ` className="light storyWrapper-0-2-2" >
 
 
  @@ -712,10 +732,10 @@ exports[`Storyshots Select Default 1`] = ` className="light storyWrapper-0-2-2" >
Lorem @@ -909,10 +929,10 @@ exports[`Storyshots Select Icon 1`] = ` className="light storyWrapper-0-2-2" >
  @@ -1129,27 +1149,27 @@ exports[`Storyshots Skeleton Count 1`] = ` className="light storyWrapper-0-2-2" >           @@ -1161,7 +1181,7 @@ exports[`Storyshots Skeleton Default 1`] = ` className="light storyWrapper-0-2-2" >   diff --git a/src/components/Form/Form.stories.tsx b/src/components/Form/Form.stories.tsx index 7ebf7889..9a637a8c 100644 --- a/src/components/Form/Form.stories.tsx +++ b/src/components/Form/Form.stories.tsx @@ -1,4 +1,5 @@ import { basicOptions } from '../RadioGroup/fixtures/sample_options' +import Decorator from '../../../.storybook/Decorator' import { iconOptions } from '../Select/fixtures/sample_options' import React from 'react' import treeData from '../Tree/fixtures/0_sample_data' @@ -11,6 +12,13 @@ export default { onSubmit: { control: { disable: true } } }, component: Form, + decorators: [ + (ComponentStory: Story) => ( + + + + ) + ], parameters: { // disabled because shallow rendering gives warning, but FormTree only works with shallow render storyshots: { disable: true } diff --git a/src/components/Input/Input.stories.tsx b/src/components/Input/Input.stories.tsx index 54ea78d1..0e9a187b 100644 --- a/src/components/Input/Input.stories.tsx +++ b/src/components/Input/Input.stories.tsx @@ -1,3 +1,4 @@ +import Decorator from '../../../.storybook/Decorator' import React from 'react' import { Input, InputProps } from './index' import { Meta, Story } from '@storybook/react/types-6-0' @@ -8,6 +9,13 @@ export default { value: { control: { disable: true } } }, component: Input, + decorators: [ + (ComponentStory: Story) => ( + + + + ) + ], title: 'Input' } as Meta