Skip to content

Commit

Permalink
revert #3: this will broken addon
Browse files Browse the repository at this point in the history
  • Loading branch information
echoulen committed Oct 4, 2018
1 parent 838b2b4 commit 517b996
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 13 deletions.
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.0.6",
"version": "1.0.7",
"description": "storybook addon with styled-components theme",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
17 changes: 7 additions & 10 deletions src/Themes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {Theme} from "./types/Theme";
export interface ThemeProps {
channel: any;
api: any;
active: boolean;
}

interface ThemeState {
Expand All @@ -23,15 +22,13 @@ interface ThemeHandler {

type BaseComponentProps = ThemeProps & ThemeState & ThemeHandler;

const BaseComponent: React.SFC<BaseComponentProps> = ({onSelectTheme, themes, theme, active}) => (
active ? (
<div style={RowStyle}>
{themes.map((th, i) => {
const buttonStyle = th === theme ? SelectedButtonStyle : ButtonStyle;
return <div style={buttonStyle} key={i} onClick={() => onSelectTheme(th)}>{th.name}</div>;
}).toArray()}
</div>
) : (<div />)
const BaseComponent: React.SFC<BaseComponentProps> = ({onSelectTheme, themes, theme}) => (
<div style={RowStyle}>
{themes.map((th, i) => {
const buttonStyle = th === theme ? SelectedButtonStyle : ButtonStyle;
return <div style={buttonStyle} key={i} onClick={() => onSelectTheme(th)}>{th.name}</div>;
}).toArray()}
</div>
);

export const Themes = compose<BaseComponentProps, ThemeProps>(
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/Themes.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe("Themes spec", () => {
removeListener: stub(),
};

const component = mount(<Themes api={null} active={true} channel={channel} />);
const component = mount(<Themes api={null} channel={channel} />);
expect(component.render()).toMatchSnapshot();
expect(channel.on.calledOnce).toBeTruthy();
expect(channel.emit.notCalled).toBeTruthy();
Expand Down
2 changes: 1 addition & 1 deletion src/register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ addons.register("storybook/themes", (api) => {
// Also need to set a unique name to the panel.
addons.addPanel("storybook/themes/panel", {
title: "Themes",
render: ({ active }) => (<Themes channel={addons.getChannel()} api={api} active={active} />),
render: () => (<Themes channel={addons.getChannel()} api={api} />),
});
});

0 comments on commit 517b996

Please sign in to comment.