11import React from "react" ;
22import { storiesOf } from "@storybook/react" ;
33
4- import TextField from "./TextField " ;
4+ import styled from "styled-components " ;
55
6- import { Button , Toolbar , Cutout } from "../" ;
6+ import { TextField , Button , Toolbar , Cutout } from "../" ;
77
88const onChange = e => console . log ( e . target . value ) ;
99
10+ const StyledCutout = styled ( Cutout ) `
11+ background: ${ ( { theme } ) => theme . canvas } ;
12+ ` ;
13+ const Wrapper = styled . div `
14+ background: ${ ( { theme } ) => theme . material } ;
15+ padding: 5rem;
16+ ` ;
1017storiesOf ( "TextField" , module )
11- . addDecorator ( story => (
12- < div
13- style = { {
14- padding : "5rem" ,
15- background : "#ced0cf"
16- } }
17- >
18- { story ( ) }
19- </ div >
20- ) )
18+ . addDecorator ( story => < Wrapper > { story ( ) } </ Wrapper > )
2119 . add ( "default" , ( ) => < TextField defaultValue = "" onChange = { onChange } /> )
2220 . add ( "controlled" , ( ) => < ControlledTextFieldExample /> )
2321 . add ( "no shadow" , ( ) => (
@@ -30,7 +28,7 @@ storiesOf("TextField", module)
3028 < TextField defaultValue = "Custom width" width = { 150 } onChange = { onChange } />
3129 ) )
3230 . add ( "flat" , ( ) => (
33- < Cutout style = { { padding : "2rem" , background : "white ", width : "300px" } } >
31+ < StyledCutout style = { { padding : "2rem" , width : "300px" } } >
3432 < p style = { { lineHeight : 1.3 } } >
3533 When you want to add input field on a light background (like scrollable
3634 content), just use the flat variant:
@@ -46,10 +44,10 @@ storiesOf("TextField", module)
4644 onChange = { onChange }
4745 />
4846 </ div >
49- </ Cutout >
47+ </ StyledCutout >
5048 ) )
5149 . add ( "flat disabled" , ( ) => (
52- < Cutout style = { { padding : "2rem" , background : "white ", width : "300px" } } >
50+ < StyledCutout style = { { padding : "2rem" , width : "300px" } } >
5351 < p style = { { lineHeight : 1.3 } } >
5452 When you want to add input field on a light background (like scrollable
5553 content), just use the flat variant:
@@ -66,7 +64,7 @@ storiesOf("TextField", module)
6664 onChange = { onChange }
6765 />
6866 </ div >
69- </ Cutout >
67+ </ StyledCutout >
7068 ) ) ;
7169
7270class ControlledTextFieldExample extends React . Component {
0 commit comments