@@ -29,18 +29,31 @@ <h1>Basic Example</h1>
2929 }
3030 ` ;
3131
32+ const VueComponent = {
33+ functional : true ,
34+ render : function ( createElement , context ) {
35+ // Transparently pass any attributes, event listeners, children, etc.
36+ return createElement ( 'button' , context . data , context . children )
37+ }
38+ }
39+
40+ const StyledVueComponent = styled . default ( VueComponent ) ``
41+
3242 // Create a <CustomTitle> vue component that renders an <h1> which is
3343 // centered, palevioletred and sized at 1.5em
34- const CustomTitle = styled . default . h1 `
44+ const CustomTitle = styled . default ( 'h1' , { animate : Boolean } ) `
3545 font-size: 2em;
3646 text-align: center;
3747 color: ${ props => props . theme . primary } ;
38- animation: ${ animation } 2s linear infinite;
3948
4049 @supports (-webkit-text-stroke: 1px) {
4150 -webkit-text-stroke: 2px ${ props => props . theme . primary } ;
4251 color: transparent
4352 }
53+
54+ ${ props => props . animate &&
55+ `animation: ${ animation } 2s linear infinite;`
56+ }
4457 ` ;
4558
4659 const H2 = CustomTitle . withComponent ( 'h2' )
@@ -52,8 +65,8 @@ <h1>Basic Example</h1>
5265 background: ${ props => props . theme . secondary } ;
5366 ` ;
5467
55- const W2 = styled . default ( Wrapper ) `
56- color: red ;
68+ const W2 = Wrapper . extend `
69+ background: ${ props => props . theme . tertiary } ;
5770 ` ;
5871
5972 const W3 = styled . default ( W2 ) `
@@ -62,6 +75,13 @@ <h1>Basic Example</h1>
6275 }
6376 `
6477
78+ const StyledInput = styled . default . input `
79+ display: block;
80+ width: 100%;
81+ height: 60px;
82+ border: solid 1px ${ props => props . theme . primary } ;
83+ `
84+
6585 const Btn = styled . default ( 'button' , { visible : Boolean } ) `
6686 background-color: red;
6787 opacity: ${ props => props . visible ? 1 : 0 } ;
@@ -73,21 +93,42 @@ <h1>Basic Example</h1>
7393
7494 new Vue ( {
7595 el : '#container' ,
96+ data : {
97+ text : 'Hello World, this is my first styled component!'
98+ } ,
99+ methods : {
100+ input ( e ) {
101+ console . log ( e . target . value )
102+ this . text += e . target . value
103+ }
104+ } ,
76105 template : `
77106 <theme-provider :theme="{
78107 primary: 'palevioletred',
79- secondary: 'papayawhip'
108+ secondary: 'papayawhip',
109+ tertiary: 'goldenrod'
80110 }">
81- <wrapper>
82- <custom-title> Hello World, this is my first styled component! </custom-title>
111+ <wrapper color="salmon">
112+ <custom-title> {{text}} </custom-title>
113+ <styled-input
114+ v-bind:value="text"
115+ v-on:input="text = $event.target.value"
116+ />
117+ <input
118+ v-bind:value="text"
119+ v-on:input="text = $event.target.value"
120+ />
83121 <btn visible> Button </btn>
122+ <styled-vue-component>ciao</styled-vue-component>
84123 </wrapper>
85124 </theme-provider>` ,
86125 components : {
87126 'custom-title' : H2 ,
88- wrapper : W3 ,
127+ wrapper : W2 ,
89128 btn : SuperBtn ,
90- 'theme-provider' : styled . ThemeProvider
129+ StyledVueComponent,
130+ 'styled-input' : StyledInput ,
131+ 'theme-provider' : styled . ThemeProvider ,
91132 } ,
92133 } ) ;
93134 </ script >
0 commit comments