@@ -44,25 +44,21 @@ Recall, the render function of our `Header` component currently looks like this:
44
44
``` javascript
45
45
class Header extends React .Component {
46
46
render () {
47
- // Classes to add to the <input /> element
48
- let searchInputClasses = [" searchInput" ];
49
-
50
- // Update the class array if the state is visible
51
- if (this .state .searchVisible ) {
52
- searchInputClasses .push (" active" );
53
- }
54
-
55
47
return (
56
48
< div className= " header" >
57
- < div className= " fa fa-more" >< / div>
49
+ < div className= " menuIcon" >
50
+ < div className= " dashTop" >< / div>
51
+ < div className= " dashBottom" >< / div>
52
+ < div className= " circle" >< / div>
53
+ < / div>
58
54
59
55
< span className= " title" >
60
56
{this .props .title }
61
57
< / span>
62
58
63
59
< input
64
60
type= " text"
65
- className= { searchInputClasses . join ( ' ' )}
61
+ className= " searchInput "
66
62
placeholder= " Search ..." / >
67
63
68
64
< div className= " fa fa-search searchIcon" >< / div>
@@ -82,12 +78,20 @@ We can target the `header` by defining the styles for a `.header` class in a reg
82
78
Let's fill in the styles for the ` Header ` class names:
83
79
84
80
``` html
85
- .header {
81
+ .demo .notificationsFrame . header {
86
82
background: rgba(251, 202, 43, 1);
87
83
}
88
- .header, .fa, .title, .searchIcon {
84
+ .demo .notificationsFrame .header .searchIcon,
85
+ .demo .notificationsFrame .header .title {
89
86
color: #333333;
90
87
}
88
+
89
+ .demo .notificationsFrame .header .menuIcon .dashTop,
90
+ .demo .notificationsFrame .header .menuIcon .dashBottom,
91
+ .demo .notificationsFrame .header .menuIcon .circle {
92
+ background-color: #333333;
93
+ }
94
+
91
95
```
92
96
93
97
<div class =" demo " id =" demo2 " ></div >
@@ -113,8 +117,7 @@ Defining styles inside a component is easy using the `style` prop. All DOM eleme
113
117
For example, to add a ` color ` style to a ` <div /> ` element in JSX, this might look like:
114
118
115
119
``` javascript
116
- const style = { color: ' blue' }
117
- < div style= {style}>
120
+ < div style= {{ color: ' blue' }}>
118
121
This text will have the color blue
119
122
< / div>
120
123
```
@@ -142,27 +145,18 @@ To update our header component to use these styles instead of depending on a CSS
142
145
143
146
``` javascript
144
147
class Header extends React .Component {
145
- // ...
146
148
render () {
147
- // Classes to add to the <input /> element
148
- let searchInputClasses = [" searchInput" ];
149
-
150
- // Update the class array if the state is visible
151
- if (this .state .searchVisible ) {
152
- searchInputClasses .push (" active" );
153
- }
154
-
155
149
const wrapperStyle = {
156
- backgroundColor: ' rgba(251, 202, 43, 1)'
157
- }
150
+ backgroundColor: " rgba(251, 202, 43, 1)"
151
+ };
158
152
159
153
const titleStyle = {
160
- color: ' #111111'
161
- }
154
+ color: " #111111"
155
+ };
162
156
163
157
const menuColor = {
164
- backgroundColor: ' #111111'
165
- }
158
+ backgroundColor: " #111111"
159
+ };
166
160
167
161
return (
168
162
< div style= {wrapperStyle} className= " header" >
@@ -178,16 +172,13 @@ class Header extends React.Component {
178
172
179
173
< input
180
174
type= " text"
181
- className= {searchInputClasses .join (' ' )}
182
- placeholder= " Search ..." / >
175
+ className= " searchInput"
176
+ placeholder= " Search ..."
177
+ / >
183
178
184
- {/* Adding an onClick handler to call the showSearch button */ }
185
- < div
186
- style= {titleStyle}
187
- onClick= {this .showSearch .bind (this )}
188
- className= " fa fa-search searchIcon" >< / div>
179
+ < div style= {titleStyle} className= " fa fa-search searchIcon" >< / div>
189
180
< / div>
190
- )
181
+ );
191
182
}
192
183
}
193
184
```
0 commit comments