@codinggorilla/storybook-theme-changer
Version:
A Storybook addon to change the emotion theme
37 lines (27 loc) • 839 B
Markdown
A Storybook react addon to change the theme used by an Emotion theme provider.
```typescript
// main.ts
import '@codinggorilla/storybook-theme-changer/dist/register';
export default {
addons: ['@codinggorilla/storybook-theme-changer/dist']
}
```
```typescript
// preview.tsx
import { Theme } from '@emotion/react';
import { Story, StoryContext } from '@storybook/react';
import { WithThemesProvider } from '@codinggorilla/storybook-theme-changer';
// Themes
import standardTheme from '../themes/standard';
import darkTheme from '../themes/dark';
function ThemeDecorator(Story: Story, Context: StoryContext) {
const themes: Theme[] = [
standardTheme,
darkTheme
]
return WithThemesProvider(themes, Story, Context);
}
export const decorators = [ThemeDecorator];
```