We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FYI: how to apply theme
import styled from '../lib/styled' import React, { FC, PropsWithChildren, ComponentType } from 'react' import { ThemeProvider } from 'styled-components' import { lightTheme, darkTheme } from '../lib/styled/themes' import { Story } from '@storybook/react/types-6-0' interface ThemedWrapperProps { theme?: 'light' | 'dark' } export const ThemedWrapper: FC<ThemedWrapperProps> = ({ theme = 'light', children, }) => { return ( <ThemeProvider theme={theme === 'light' ? lightTheme : darkTheme}> <StyledBackground>{children}</StyledBackground> </ThemeProvider> ) } const StyledBackground = styled.div` position: absolute; top: 0; left: 0; right: 0; bottom: 0; padding: 10px; background-color: ${({ theme }) => theme.baseBackgroundColor}; box-sizing: border-box; ` export type ThemedStory<P> = Story< { theme: 'dark' | 'light' } & PropsWithChildren<P> > export function createThemedTemplate<P = {}>( Component: ComponentType<P> ): { Template: ThemedStory<P> themeArgType: {} } { return { Template: ({ theme, ...args }: any) => { return ( <ThemedWrapper theme={theme}> <Component {...args} /> </ThemedWrapper> ) }, themeArgType: { defaultValue: 'light', control: { type: 'inline-radio', options: ['light', 'dark'], }, }, } }
The text was updated successfully, but these errors were encountered:
rohjs
No branches or pull requests
FYI: how to apply theme
The text was updated successfully, but these errors were encountered: