@@ -75,12 +75,16 @@ <h1>Basic Example</h1>
7575 background: ${ props => props . theme . tertiary } ;
7676 ` ;
7777
78- const W3 = styled . default ( W2 ) `
79- &:hover {
80- background: ${ props => props . theme . primary } ;
81- }
78+ // Custom Wrapper
79+ const W3 = styled . default ( Wrapper , {
80+ color : String ,
81+ bg : String
82+ } ) `
83+ color: ${ props => props . color } ;
84+ background-color: ${ props => props . bg } ;
8285 `
8386
87+
8488 const StyledInput = styled . default . input `
8589 display: block;
8690 width: 100%;
@@ -106,19 +110,39 @@ <h1>Basic Example</h1>
106110 margin: 1.5em 0;
107111 background-color: ${ props => props . theme . primary } ;
108112 opacity: ${ props => props . visible ? 1 : 0 } ;
113+
114+ &:focus {
115+ outline: none;
116+ border: solid 3px ${ props => props . theme . primary } ;
117+ }
109118 `
110119
111120 const SuperBtn = styled . default ( Btn , { visible : Boolean , big : Boolean } ) `
112121 font-size: ${ props => props . big ? 0.8 : 1 } em;
113122 `
114123
124+ const CustomBtn = styled . default ( Btn , {
125+ color : String ,
126+ bg : String
127+ } ) `
128+ color: ${ props => props . color } ;
129+ background-color: ${ props => props . bg } ;
130+
131+ &:focus {
132+ outline: none;
133+ border: solid 3px ${ props => props . color } ;
134+ }
135+ `
136+
115137 new Vue ( {
116138 el : '#container' ,
117139 data : {
118140 text1 : 'Hello World, this is my first styled component!' ,
119141 text2 : 'Hello World, this is my first styled component!' ,
120142 animated1 : false ,
121- animated2 : false
143+ animated2 : false ,
144+ element : 'div' ,
145+ setElement : 'div'
122146 } ,
123147 template : `
124148 <theme-provider :theme="{
@@ -136,18 +160,44 @@ <h1>Basic Example</h1>
136160 <styled-input v-model="text2" />
137161 <super-btn visible @click="animated2 = !animated2"> An extension of Styled Button </super-btn>
138162 </w-2>
163+ <w-3
164+ bg="#c6f7e6"
165+ >
166+ <custom-title :visible="true">Change Rendered Elements with "as" prop.</custom-title>
167+ <h3>Enter any HTML element and see the element rendered by the styled component change 👇🏽</h3>
168+ <styled-input @keydown.enter="updateElement" placeholder="Enter an HTML element! Like 'button' or 'section'" v-model="element" />
169+ <custom-btn
170+ visible
171+ :as="setElement"
172+ role="button"
173+ tabindex="0"
174+ color="#42a786"
175+ bg="papayawhip"
176+ aria-label="Btn rendered as div"
177+ @keydown.space="updateElement"
178+ >
179+ I am the "btn" component rendered as a "{{ setElement }}" using the \`as\` prop! 🎉
180+ </custom-btn>
181+ </w-3>
139182 </theme-provider>` ,
140183 components : {
141184 CustomTitle,
142185 Wrapper,
143186 W2 ,
187+ W3 ,
144188 H2 ,
145189 Btn,
146190 SuperBtn,
191+ CustomBtn,
147192 SuperCustomTitle,
148193 StyledInput,
149194 'theme-provider' : styled . ThemeProvider ,
150195 } ,
196+ methods : {
197+ updateElement ( ) {
198+ this . setElement = this . element
199+ }
200+ }
151201 } ) ;
152202 </ script >
153203 </ body >
0 commit comments