Skip to content

Commit

Permalink
fixed theme not changing on certain stories
Browse files Browse the repository at this point in the history
  • Loading branch information
arturbien committed May 22, 2019
1 parent a4baaff commit d3487b8
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 99 deletions.
12 changes: 8 additions & 4 deletions src/components/Button/Button.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { withInfo } from "@storybook/addon-info";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";

import styled from "styled-components";
import styled, {ThemeProvider} from "styled-components";

import { Button, Window, WindowContent, Cutout, Toolbar } from "../";
export const actions = { onClick: action("onClick") };

const StyledCutout = styled(Cutout)`
background: ${({theme})=>theme.canvas};
`;

storiesOf("Button", module)
.addDecorator(story => (
<div
Expand Down Expand Up @@ -53,8 +57,8 @@ storiesOf("Button", module)
.add("flat button", () => (
<Window>
<WindowContent>
<Cutout
style={{ padding: "1rem", background: "white", width: "300px" }}
<StyledCutout
style={{ padding: "1rem", width: "300px" }}
>
<p style={{ lineHeight: 1.3 }}>
When you want to use Buttons on a light background (like scrollable
Expand All @@ -74,7 +78,7 @@ storiesOf("Button", module)
</Button>
</Toolbar>
</div>
</Cutout>
</StyledCutout>
</WindowContent>
</Window>
));
24 changes: 12 additions & 12 deletions src/components/Checkbox/Checkbox.stories.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from "react";
import { storiesOf } from "@storybook/react";
import styled from "styled-components";

import { Checkbox, Fieldset, Toolbar, Button, Cutout } from "../";

const StyledCutout = styled(Cutout)`
background: ${({ theme }) => theme.canvas};
`;
const Wrapper = styled.div`
background: ${({ theme }) => theme.material};
padding: 5rem;
`;
storiesOf("Checkbox", module)
.addDecorator(story => (
<div
style={{
padding: "5rem",
background: "#ced0cf"
}}
>
{story()}
</div>
))
.addDecorator(story => <Wrapper>{story()}</Wrapper>)
.add("controlled group", () => <ControlledCheckboxGroupExample />)
.add("uncontrolled", () => (
<Checkbox
Expand All @@ -22,7 +22,7 @@ storiesOf("Checkbox", module)
/>
))
.add("flat", () => (
<Cutout style={{ padding: "2rem", background: "white", width: "300px" }}>
<StyledCutout style={{ padding: "1rem", width: "300px" }}>
<p style={{ lineHeight: 1.3 }}>
When you want to add input field on a light background (like scrollable
content), just use the flat variant:
Expand All @@ -42,7 +42,7 @@ storiesOf("Checkbox", module)
disabled
/>
</div>
</Cutout>
</StyledCutout>
));

class ControlledCheckboxGroupExample extends React.Component {
Expand Down
36 changes: 19 additions & 17 deletions src/components/Cutout/Cutout.stories.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import React from "react";
import { storiesOf } from "@storybook/react";

import Cutout from "./Cutout";
import { Cutout, Window, WindowContent } from "../";

storiesOf("Cutout", module)
.addDecorator(story => (
<div
style={{
padding: "5rem",
background: "#ced0cf"
}}
>
{story()}
</div>
))
.add("default", () => (
<Cutout>
<h1>swag </h1>
</Cutout>
));
storiesOf("Cutout", module).add("default", () => (
<Window>
<WindowContent>
<Cutout style={{ width: "300px", height: "200px" }}>
<h1
style={{
fontFamily: "times new roman",
textAlign: "center",
fontSize: "3rem",
marginTop: "0.5rem"
}}
>
React95
</h1>
</Cutout>
</WindowContent>
</Window>
));
24 changes: 12 additions & 12 deletions src/components/NumberField/NumberField.stories.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React from "react";
import { storiesOf } from "@storybook/react";
import styled from "styled-components";

import { NumberField, Cutout } from "../";

const StyledCutout = styled(Cutout)`
background: ${({ theme }) => theme.canvas};
`;
const Wrapper = styled.div`
background: ${({ theme }) => theme.material};
padding: 5rem;
`;

storiesOf("NumberField", module)
.addDecorator(story => (
<div
style={{
padding: "5rem",
background: "#ced0cf"
}}
>
{story()}
</div>
))
.addDecorator(story => <Wrapper>{story()}</Wrapper>)
.add("default", () => (
<NumberField value={1991} onChange={value => console.log(value)} />
))
Expand Down Expand Up @@ -42,7 +42,7 @@ storiesOf("NumberField", module)
/>
))
.add("flat", () => (
<Cutout style={{ padding: "2rem", background: "white", width: "300px" }}>
<StyledCutout style={{ padding: "2rem", width: "300px" }}>
<p style={{ lineHeight: 1.3, marginBottom: "1rem" }}>
When you want to use NumberField on a light background (like scrollable
content), just use the flat variant:
Expand All @@ -53,5 +53,5 @@ storiesOf("NumberField", module)
value={1991}
onChange={value => console.log(value)}
/>
</Cutout>
</StyledCutout>
));
19 changes: 8 additions & 11 deletions src/components/Progress/Progress.stories.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import React from "react";
import { storiesOf } from "@storybook/react";

import Progress from "./Progress";
import styled from "styled-components";

import { Progress } from "../";

const Wrapper = styled.div`
background: ${({ theme }) => theme.material};
padding: 5rem;
`;
storiesOf("Progress", module)
.addDecorator(story => (
<div
style={{
padding: "5rem",
background: "#ced0cf"
}}
>
{story()}
</div>
))
.addDecorator(story => <Wrapper>{story()}</Wrapper>)
.add("default", () => <Progress percent={52} />)
.add("no shadow", () => <Progress percent={52} shadow={false} />);
16 changes: 6 additions & 10 deletions src/components/Select/Select.stories.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";
import styled from "styled-components";

import { Select, Window, WindowContent, Cutout } from "../";

Expand All @@ -15,18 +16,13 @@ const items = [
{ value: 6, label: "🛌🏻 Snorlax" },
{ value: 7, label: "⛰ Geodude" }
];
const Wrapper = styled.div`
background: ${({ theme }) => theme.material};
padding: 5rem;
`;
const onChange = value => console.log(value);
storiesOf("Select", module)
.addDecorator(story => (
<div
style={{
padding: "5rem",
background: "#ced0cf"
}}
>
{story()}
</div>
))
.addDecorator(story => <Wrapper>{story()}</Wrapper>)
.add("fixed width", () => (
<Select items={items} onChange={onChange} width={150} />
))
Expand Down
32 changes: 15 additions & 17 deletions src/components/TextArea/TextArea.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,20 @@ import React from "react";
import { storiesOf } from "@storybook/react";
import { action } from "@storybook/addon-actions";

import TextArea from "./TextArea";
import { Button, Cutout } from "../";
import styled from "styled-components";

const onChange = e => console.log(e.target.value);
import { TextArea, Button, Cutout } from "../";

const onChange = e => console.log(e.target.value);
const StyledCutout = styled(Cutout)`
background: ${({ theme }) => theme.canvas};
`;
const Wrapper = styled.div`
background: ${({ theme }) => theme.material};
padding: 5rem;
`;
storiesOf("TextArea", module)
.addDecorator(story => (
<div
style={{
padding: "5rem",
background: "#ced0cf"
}}
>
{story()}
</div>
))
.addDecorator(story => <Wrapper>{story()}</Wrapper>)
.add("default", () => (
<TextArea
defaultValue="User ReactGirl was the first one to find 🐛 here."
Expand All @@ -42,7 +40,7 @@ storiesOf("TextArea", module)
<TextArea shadow={false} placeholder="Type in here.." onChange={onChange} />
))
.add("flat", () => (
<Cutout style={{ padding: "2rem", background: "white", width: "300px" }}>
<StyledCutout style={{ padding: "2rem", width: "300px" }}>
<p style={{ lineHeight: 1.3 }}>
When you want to add text area on a light background (like scrollable
content), just use the flat variant:
Expand All @@ -56,10 +54,10 @@ storiesOf("TextArea", module)
onChange={onChange}
/>
</div>
</Cutout>
</StyledCutout>
))
.add("flat disabled", () => (
<Cutout style={{ padding: "2rem", background: "white", width: "300px" }}>
<StyledCutout style={{ padding: "2rem", width: "300px" }}>
<p style={{ lineHeight: 1.3 }}>
When you want to add text area on a light background (like scrollable
content), just use the flat variant:
Expand All @@ -74,7 +72,7 @@ storiesOf("TextArea", module)
onChange={onChange}
/>
</div>
</Cutout>
</StyledCutout>
));
class ControlledTextAreaExample extends React.Component {
state = {
Expand Down
30 changes: 14 additions & 16 deletions src/components/TextField/TextField.stories.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
import React from "react";
import { storiesOf } from "@storybook/react";

import TextField from "./TextField";
import styled from "styled-components";

import { Button, Toolbar, Cutout } from "../";
import { TextField, Button, Toolbar, Cutout } from "../";

const onChange = e => console.log(e.target.value);

const StyledCutout = styled(Cutout)`
background: ${({ theme }) => theme.canvas};
`;
const Wrapper = styled.div`
background: ${({ theme }) => theme.material};
padding: 5rem;
`;
storiesOf("TextField", module)
.addDecorator(story => (
<div
style={{
padding: "5rem",
background: "#ced0cf"
}}
>
{story()}
</div>
))
.addDecorator(story => <Wrapper>{story()}</Wrapper>)
.add("default", () => <TextField defaultValue="" onChange={onChange} />)
.add("controlled", () => <ControlledTextFieldExample />)
.add("no shadow", () => (
Expand All @@ -30,7 +28,7 @@ storiesOf("TextField", module)
<TextField defaultValue="Custom width" width={150} onChange={onChange} />
))
.add("flat", () => (
<Cutout style={{ padding: "2rem", background: "white", width: "300px" }}>
<StyledCutout style={{ padding: "2rem", width: "300px" }}>
<p style={{ lineHeight: 1.3 }}>
When you want to add input field on a light background (like scrollable
content), just use the flat variant:
Expand All @@ -46,10 +44,10 @@ storiesOf("TextField", module)
onChange={onChange}
/>
</div>
</Cutout>
</StyledCutout>
))
.add("flat disabled", () => (
<Cutout style={{ padding: "2rem", background: "white", width: "300px" }}>
<StyledCutout style={{ padding: "2rem", width: "300px" }}>
<p style={{ lineHeight: 1.3 }}>
When you want to add input field on a light background (like scrollable
content), just use the flat variant:
Expand All @@ -66,7 +64,7 @@ storiesOf("TextField", module)
onChange={onChange}
/>
</div>
</Cutout>
</StyledCutout>
));

class ControlledTextFieldExample extends React.Component {
Expand Down

0 comments on commit d3487b8

Please sign in to comment.