2021-03-04 01:21:14 +03:00
|
|
|
import 'inter-ui'
|
2021-02-17 01:33:55 +03:00
|
|
|
import { Story } from '@storybook/react/types-6-0'
|
2021-03-04 01:21:14 +03:00
|
|
|
import { createWeb3ReactRoot, Web3ReactProvider } from '@web3-react/core'
|
2021-02-17 01:33:55 +03:00
|
|
|
import React from 'react'
|
2021-03-04 01:21:14 +03:00
|
|
|
import { Provider as StoreProvider } from 'react-redux'
|
|
|
|
import { ThemeProvider as SCThemeProvider } from 'styled-components'
|
2021-05-18 18:31:22 +03:00
|
|
|
import { NetworkContextName } from '../src/constants/misc'
|
2021-03-04 01:21:14 +03:00
|
|
|
import store from '../src/state'
|
2021-02-17 01:33:55 +03:00
|
|
|
import { FixedGlobalStyle, theme, ThemedGlobalStyle } from '../src/theme'
|
2021-03-04 01:21:14 +03:00
|
|
|
import getLibrary from '../src/utils/getLibrary'
|
2021-02-17 01:33:55 +03:00
|
|
|
import * as storybookThemes from './theme'
|
|
|
|
|
|
|
|
export const parameters = {
|
|
|
|
actions: { argTypesRegex: '^on[A-Z].*' },
|
|
|
|
dependencies: {
|
|
|
|
withStoriesOnly: true,
|
2021-03-04 01:21:14 +03:00
|
|
|
hideEmpty: true,
|
2021-02-17 01:33:55 +03:00
|
|
|
},
|
|
|
|
docs: {
|
2021-03-04 01:21:14 +03:00
|
|
|
theme: storybookThemes.light,
|
2021-02-17 01:33:55 +03:00
|
|
|
},
|
|
|
|
viewport: {
|
|
|
|
viewports: {
|
|
|
|
mobile: {
|
|
|
|
name: 'iPhone X',
|
|
|
|
styles: {
|
|
|
|
width: '375px',
|
2021-03-04 01:21:14 +03:00
|
|
|
height: '812px',
|
|
|
|
},
|
2021-02-17 01:33:55 +03:00
|
|
|
},
|
|
|
|
tablet: {
|
|
|
|
name: 'iPad',
|
|
|
|
styles: {
|
|
|
|
width: '768px',
|
2021-03-04 01:21:14 +03:00
|
|
|
height: '1024px',
|
|
|
|
},
|
2021-02-17 01:33:55 +03:00
|
|
|
},
|
|
|
|
laptop: {
|
|
|
|
name: 'Laptop',
|
|
|
|
styles: {
|
|
|
|
width: '1024px',
|
2021-03-04 01:21:14 +03:00
|
|
|
height: '768px',
|
|
|
|
},
|
2021-02-17 01:33:55 +03:00
|
|
|
},
|
|
|
|
desktop: {
|
|
|
|
name: 'Desktop',
|
|
|
|
styles: {
|
|
|
|
width: '1440px',
|
2021-03-04 01:21:14 +03:00
|
|
|
height: '1024px',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
2021-02-17 01:33:55 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
export const globalTypes = {
|
|
|
|
theme: {
|
|
|
|
name: 'Theme',
|
|
|
|
description: 'Global theme for components',
|
|
|
|
defaultValue: 'light',
|
|
|
|
toolbar: {
|
|
|
|
icon: 'circlehollow',
|
2021-03-04 01:21:14 +03:00
|
|
|
items: ['light', 'dark'],
|
|
|
|
},
|
|
|
|
},
|
2021-02-17 01:33:55 +03:00
|
|
|
}
|
|
|
|
|
2021-03-04 01:21:14 +03:00
|
|
|
const Web3ProviderNetwork = createWeb3ReactRoot(NetworkContextName)
|
|
|
|
|
2021-02-17 01:33:55 +03:00
|
|
|
const withProviders = (Component: Story, context: Record<string, any>) => {
|
|
|
|
const THEME = theme(context.globals.theme === 'dark')
|
|
|
|
return (
|
|
|
|
<>
|
2021-03-04 01:21:14 +03:00
|
|
|
<Web3ReactProvider getLibrary={getLibrary}>
|
|
|
|
<Web3ProviderNetwork getLibrary={getLibrary}>
|
|
|
|
<StoreProvider store={store}>
|
|
|
|
<SCThemeProvider theme={THEME}>
|
|
|
|
<FixedGlobalStyle />
|
|
|
|
<ThemedGlobalStyle />
|
|
|
|
<main>
|
|
|
|
<Component />
|
|
|
|
</main>
|
|
|
|
</SCThemeProvider>
|
|
|
|
</StoreProvider>
|
|
|
|
</Web3ProviderNetwork>
|
|
|
|
</Web3ReactProvider>
|
2021-02-17 01:33:55 +03:00
|
|
|
</>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export const decorators = [withProviders]
|