Skip to content
This repository has been archived by the owner on May 7, 2021. It is now read-only.

Commit

Permalink
Storybook (#1620)
Browse files Browse the repository at this point in the history
* added storybook. doesnt work

* storybook configuration

* babel-loader version

* more providers for storybook

* mdx integration

* added a start page

* reorderd start page

* fixed typo in paragraph story

* linted

* linted
  • Loading branch information
amazingphilippe committed Mar 6, 2020
1 parent 499838c commit 6195d7a
Show file tree
Hide file tree
Showing 22 changed files with 10,146 additions and 297 deletions.
15 changes: 15 additions & 0 deletions f2/.storybook/formDecorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react'
import { Form } from 'react-final-form'

const FormDecorator = storyFn => (
<Form
initialValues={''}
onSubmit={values => {
props.onSubmit(values)
}}
validate={''}
render={values => storyFn()}
/>
)

export default FormDecorator
16 changes: 16 additions & 0 deletions f2/.storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = {
stories: ['../src/**/*.stories.(js|mdx)'],
addons: [
'@storybook/preset-create-react-app',
'@storybook/addon-actions',
{
name: '@storybook/addon-docs',
options: {
configureJSX: true,
babelOptions: {},
},
},
'@storybook/addon-links',
'@storybook/addon-knobs',
],
}
6 changes: 6 additions & 0 deletions f2/.storybook/manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { addons } from '@storybook/addons'
import theme from './theme'

addons.setConfig({
theme: theme,
})
15 changes: 15 additions & 0 deletions f2/.storybook/preview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { configure, addDecorator, addParameters } from '@storybook/react'
import { DocsPage, DocsContainer } from '@storybook/addon-docs/blocks'

addParameters({
docs: {
container: DocsContainer,
page: DocsPage,
},
options: {
storySort: (a, b) =>
a[1].kind === b[1].kind
? 0
: a[1].id.localeCompare(b[1].id, undefined, { numeric: true }),
},
})
36 changes: 36 additions & 0 deletions f2/.storybook/theme.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { create } from '@storybook/theming/create'

export default create({
base: 'light',

colorPrimary: 'white',
colorSecondary: '#2C5282',

// UI
appBg: 'white',
appContentBg: 'white',
appBorderColor: '#D5D5D5',
appBorderRadius: 4,

// Typography
fontBase: '"Noto Sans", sans-serif',
fontCode: 'monospace',

// Text colors
textColor: 'black',
textInverseColor: 'rgba(255,255,255,0.9)',

// Toolbar default and active colors
barTextColor: 'black',
barSelectedColor: '#2C5282',
barBg: '#F2F2F2',

// Form colors
inputBg: 'white',
inputBorder: 'silver',
inputTextColor: 'black',
inputBorderRadius: 4,

brandTitle: 'Canada',
brandUrl: '/',
})
30 changes: 30 additions & 0 deletions f2/.storybook/themeDecorator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import { ThemeProvider, CSSReset, Box } from '@chakra-ui/core'
import theme from '../src/theme/canada'
import { Global, css } from '@emotion/core'
import { MemoryRouter } from 'react-router-dom'
import { I18nProvider, useLingui } from '@lingui/react'
import { i18n } from '@lingui/core'
import en from '../src/locales/en.json'

const ThemeDecorator = storyFn => {
i18n.load('en', en)
i18n.activate('en')
return (
<MemoryRouter>
<I18nProvider i18n={i18n}>
<ThemeProvider theme={theme}>
<CSSReset />
<Global
styles={css`
@import url('https://fonts.googleapis.com/css?family=Noto+Sans:400,400i,700,700i&display=swap');
`}
/>
{storyFn()}
</ThemeProvider>
</I18nProvider>
</MemoryRouter>
)
}

export default ThemeDecorator
Loading

0 comments on commit 6195d7a

Please sign in to comment.