|
| 1 | +import React from 'react'; |
| 2 | +import { Global, ThemeProvider, css } from '@emotion/react'; |
| 3 | +import { Root, Fonts, defaultTheme } from '@csssr/core-design'; |
| 4 | +import { getTransformSource } from './utils/getTransformSource'; |
| 5 | + |
| 6 | +import { Grid } from '../components/Grid'; |
| 7 | + |
| 8 | +import stylesBody from '../components/Post/Body/Body.styles'; |
| 9 | +import stylesLayout from '../components/Layout/Layout.styles'; |
| 10 | + |
| 11 | +const customViewports = { |
| 12 | + mobile: { |
| 13 | + name: 'mobile.all 360px', |
| 14 | + styles: { |
| 15 | + width: '360px', |
| 16 | + height: '640px', |
| 17 | + }, |
| 18 | + }, |
| 19 | + tablet: { |
| 20 | + name: 'tablet.all 1024px', |
| 21 | + styles: { |
| 22 | + width: '1024px', |
| 23 | + height: '768px', |
| 24 | + }, |
| 25 | + }, |
| 26 | + desktopM: { |
| 27 | + name: 'desktop.m 1360px', |
| 28 | + styles: { |
| 29 | + width: '1360px', |
| 30 | + height: '1000px', |
| 31 | + }, |
| 32 | + }, |
| 33 | + desktopL: { |
| 34 | + name: 'desktop.l 1920px', |
| 35 | + styles: { |
| 36 | + width: '1920px', |
| 37 | + height: '1000px', |
| 38 | + }, |
| 39 | + }, |
| 40 | +}; |
| 41 | + |
| 42 | +export const parameters = { |
| 43 | + viewport: { viewports: customViewports }, |
| 44 | + actions: { argTypesRegex: '^on[A-Z].*' }, |
| 45 | + controls: { |
| 46 | + matchers: { |
| 47 | + color: /(background|color)$/i, |
| 48 | + date: /Date$/, |
| 49 | + }, |
| 50 | + }, |
| 51 | + docs: { |
| 52 | + transformSource: (_src, storyContext) => { |
| 53 | + const { args, kind } = storyContext; |
| 54 | + return getTransformSource(kind, args); |
| 55 | + }, |
| 56 | + }, |
| 57 | +}; |
| 58 | +export const decorators = [ |
| 59 | + (Story) => ( |
| 60 | + <Root> |
| 61 | + <ThemeProvider theme={defaultTheme}> |
| 62 | + <Grid> |
| 63 | + <Fonts preset="blog" /> |
| 64 | + <Story /> |
| 65 | + <Global styles={stylesLayout} /> |
| 66 | + <Global styles={(theme) => stylesBody({ theme })} /> |
| 67 | + {/* Для переопределения стилей блога, иначе код code source в одну строку */} |
| 68 | + <Global styles={css`code { |
| 69 | + white-space: pre; |
| 70 | + }`}/> |
| 71 | + </Grid> |
| 72 | + </ThemeProvider> |
| 73 | + </Root> |
| 74 | + ), |
| 75 | +]; |
0 commit comments