Skip to content

Commit

Permalink
v1.1.1: Resolve #10
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos committed Jan 11, 2019
1 parent 5dc6a4a commit d5ab583
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
1 change: 0 additions & 1 deletion .storybook/addons.js

This file was deleted.

1 change: 1 addition & 0 deletions .storybook/addons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import "../src/register";
10 changes: 5 additions & 5 deletions .storybook/config.js → .storybook/config.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import {addDecorator, configure} from '@storybook/react';
import * as React from "react";
import {withThemesProvider} from "../dist/src/index";
import {addDecorator, configure} from "@storybook/react";
import {withThemesProvider} from "../src";

const defaultTheme = {
name: "DEFAULT",
backgroundColor: 'azure',
backgroundColor: "azure",
textColor: "dimgrey",
borderRadius: "30px",
};
Expand All @@ -23,7 +22,8 @@ export const getAllThemes = () => {
addDecorator(withThemesProvider(getAllThemes()));

// automatically import all files ending in *.stories.js
const req = require.context('../', true, /.stories.tsx/);
// @ts-ignore
const req = require.context("../", true, /.stories.tsx/);
function loadStories() {
req.keys().forEach((filename) => req(filename));
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storybook-addon-styled-component-theme",
"version": "1.1.0",
"version": "1.1.1",
"description": "storybook addon with styled-components theme",
"main": "dist/src/index.js",
"types": "dist/src/index.d.ts",
Expand Down
8 changes: 5 additions & 3 deletions src/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@ export const Themes = compose<BaseComponentProps, ThemeProps>(
withState("theme", "setTheme", null),
withState("themes", "setThemes", List()),
withHandlers<ThemeProps & ThemeState, ThemeHandler>({
onSelectTheme: ({channel, setTheme}) => (theme) => {
onSelectTheme: ({channel, setTheme, api}) => (theme) => {
setTheme(theme);
api.setQueryParams({theme: theme.name});
channel.emit("selectTheme", theme);
},
onReceiveThemes: ({setTheme, setThemes, channel}) => (newThemes: Theme[]) => {
onReceiveThemes: ({setTheme, setThemes, channel, api}) => (newThemes: Theme[]) => {
const themes = List(newThemes);
const themeName = api.getQueryParam("theme");
setThemes(List(themes));
if (themes.count() > 0) {
const theme = themes.first();
const theme = themes.find((t) => t.name === themeName) || themes.first();
setTheme(theme);
channel.emit("selectTheme", theme);
}
Expand Down

0 comments on commit d5ab583

Please sign in to comment.