Skip to content
New issue

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

Readme gif #19

Merged
merged 2 commits into from
Feb 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Greatly inspired by [@storybook/addon-backgrounds](https://github.com/storybooks

This Storybook Theme Decorator can be used to add a custom HTML class or classes to the the preview in [Storybook](https://storybook.js.org).

![Demo](media/demo.gif)

## Compatibility

This version is compatible with storybook version `5.3.x`.
Expand Down
Binary file added media/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions src/decorators/react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Props {

export const ThemeDecorator: React.FC<Props> = (props) => {
const { children, config, store } = props;
const channel = addons.getChannel();

const [storeTheme, setTheme] = useState<string>(store.get('theme'));
const themeName = storeTheme || getSelectedTheme(config.list);
Expand All @@ -29,13 +30,11 @@ export const ThemeDecorator: React.FC<Props> = (props) => {

useEffect(() => {
const updateStore = (theme: string) => store.set('theme', theme);
const channel = addons.getChannel();
channel.on(CHANGE, updateStore);
return () => channel.removeListener(CHANGE, updateStore);
}, [store]);

useEffect(() => {
const channel = addons.getChannel();
channel.emit(THEME, themeName);
}, [themeName]);

Expand Down
1 change: 0 additions & 1 deletion src/hooks/index.ts

This file was deleted.

16 changes: 0 additions & 16 deletions src/hooks/useTheme.ts

This file was deleted.