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/package-lock.json b/package-lock.json index a3f601fd..f476b85b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,10 @@ { "name": "@dassana-io/web-components", +<<<<<<< HEAD "version": "0.5.1", +======= + "version": "0.5.0", +>>>>>>> v0.4.0 -> v0.5.0 (#105) "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/src/__snapshots__/storybook.test.ts.snap b/src/__snapshots__/storybook.test.ts.snap index 787b492c..08d32b62 100644 --- a/src/__snapshots__/storybook.test.ts.snap +++ b/src/__snapshots__/storybook.test.ts.snap @@ -3,6 +3,77 @@ exports[`Storyshots Avatar Default 1`] = `
+ + + D + + +
+`; + +exports[`Storyshots Avatar Icon 1`] = ` +
+ + + dassana.svg + + +
+`; + +exports[`Storyshots Button Default 1`] = ` +
+ +
+`; + +exports[`Storyshots Button Disabled 1`] = ` +
+ +
+`; + exports[`Storyshots Button Loading 1`] = `
>>>>>> v0.4.0 -> v0.5.0 (#105) "fontSize": 16, } } @@ -212,6 +325,7 @@ exports[`Storyshots Input Default 1`] = ` className="storyWrapper-0-2-2" >
+======= + className="decorator-0-2-6 decorator" + > +
+ +
+>>>>>>> v0.4.0 -> v0.5.0 (#105)
`; @@ -235,6 +369,7 @@ exports[`Storyshots Input Error 1`] = ` className="storyWrapper-0-2-2" >
+======= + className="decorator-0-2-6 decorator" + > +
+ +
+>>>>>>> v0.4.0 -> v0.5.0 (#105)
`; @@ -258,6 +413,7 @@ exports[`Storyshots Input Full Width 1`] = ` className="storyWrapper-0-2-2" >
+======= + className="decorator-0-2-6 decorator" + > +
+ +
+>>>>>>> v0.4.0 -> v0.5.0 (#105)
`; @@ -281,6 +457,7 @@ exports[`Storyshots Input Loading 1`] = ` className="storyWrapper-0-2-2" >
  +======= + className="decorator-0-2-6 decorator" + > +
+
+ +   + +
+>>>>>>> v0.4.0 -> v0.5.0 (#105)
@@ -301,6 +494,7 @@ exports[`Storyshots Input Placeholder 1`] = ` className="storyWrapper-0-2-2" >
+======= + className="decorator-0-2-6 decorator" + > +
+ +
+>>>>>>> v0.4.0 -> v0.5.0 (#105)
`; @@ -552,6 +766,7 @@ exports[`Storyshots Radio Group Default 1`] = ` +>>>>>>> v0.4.0 -> v0.5.0 (#105) `; @@ -712,10 +953,17 @@ exports[`Storyshots Select Default 1`] = ` className="storyWrapper-0-2-2" >
+
>>>>>> v0.4.0 -> v0.5.0 (#105) data-test="select" onBlur={[Function]} onFocus={[Function]} @@ -808,10 +1056,17 @@ exports[`Storyshots Select Full Width 1`] = ` className="storyWrapper-0-2-2" >
+
>>>>>> v0.4.0 -> v0.5.0 (#105) data-test="select" onBlur={[Function]} onFocus={[Function]} @@ -858,7 +1113,11 @@ exports[`Storyshots Select Full Width 1`] = ` className="ant-select-selection-item" >
>>>>>> v0.4.0 -> v0.5.0 (#105) > Lorem @@ -909,10 +1168,17 @@ exports[`Storyshots Select Icon 1`] = ` className="storyWrapper-0-2-2" >
+
>>>>>> v0.4.0 -> v0.5.0 (#105) data-test="select" onBlur={[Function]} onFocus={[Function]} @@ -959,10 +1225,17 @@ exports[`Storyshots Select Icon 1`] = ` className="ant-select-selection-item" >
+ >>>>>> v0.4.0 -> v0.5.0 (#105) >
+
>>>>>> v0.4.0 -> v0.5.0 (#105) data-test="select" onBlur={[Function]} onFocus={[Function]} @@ -1117,7 +1397,11 @@ exports[`Storyshots Skeleton Circle 1`] = ` className="storyWrapper-0-2-2" > >>>>>> v0.4.0 -> v0.5.0 (#105) >   @@ -1129,27 +1413,47 @@ exports[`Storyshots Skeleton Count 1`] = ` className="storyWrapper-0-2-2" > >>>>>> v0.4.0 -> v0.5.0 (#105) >   >>>>>> v0.4.0 -> v0.5.0 (#105) >   >>>>>> v0.4.0 -> v0.5.0 (#105) >   >>>>>> v0.4.0 -> v0.5.0 (#105) >   >>>>>> v0.4.0 -> v0.5.0 (#105) >   @@ -1161,7 +1465,11 @@ exports[`Storyshots Skeleton Default 1`] = ` className="storyWrapper-0-2-2" > >>>>>> v0.4.0 -> v0.5.0 (#105) >   @@ -1200,6 +1508,24 @@ exports[`Storyshots Tag Colored Preset 1`] = ` Blue
+<<<<<<< HEAD +`; + +exports[`Storyshots Tag Default 1`] = ` +
+ + Default + +======= `; exports[`Storyshots Tag Default 1`] = ` @@ -1219,6 +1545,31 @@ exports[`Storyshots Tag Default 1`] = `
`; +exports[`Storyshots Toggle Checked Disabled 1`] = ` +
+ +>>>>>>> v0.4.0 -> v0.5.0 (#105) +
+`; + exports[`Storyshots Toggle Default 1`] = `
( + + + + ) + ], 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 diff --git a/src/components/Input/index.tsx b/src/components/Input/index.tsx index 84ac83b7..a099b3be 100644 --- a/src/components/Input/index.tsx +++ b/src/components/Input/index.tsx @@ -69,7 +69,7 @@ export const Input: FC = (props: InputProps) => { const inputClasses: string = cn( { - [componentClasses.error]: error + error }, classes )