@@ -6,7 +6,7 @@ Every React component gets an inbuilt javascript constructor for functional logi
6
6
7
7
``` jsx
8
8
import React from ' react' ;
9
- import css from ' css-constructor' ;
9
+ import css from ' css-constructor' ; // πΆ Super tiny: only 1.2K gzipped!
10
10
11
11
export default class Hello extends React .Component {
12
12
@@ -15,42 +15,33 @@ export default class Hello extends React.Component {
15
15
super (props);
16
16
}
17
17
18
- /* css constructor */
19
- @css`
20
- /* π Isolated and co-located */
18
+ /* css constructor */
19
+ @css` // π Isolated and co-located
20
+ font-size: 16px;
21
+ text-align: center; // π Supports the entirety of CSS
21
22
22
- /* π Supports the entirety of CSS */
23
- font-size: 16px;
24
- text-align: center;
23
+ color: {this.props.color}; // π₯ Use props in css
25
24
26
- /* π₯ Use props in css */
27
- color: {this.props.color};
25
+ display: flex; // π» Built in vendor prefixing
28
26
29
- /* π» Built in vendor prefixing */
30
- display: flex;
31
-
32
- /* π Pseudo selectors */
33
- &:hover {
27
+ &:hover { // π Pseudo selectors
34
28
color: #FFF;
35
29
}
36
30
37
- /* πͺ Nested css */
38
- img {
31
+ img { // πͺ Nested css
39
32
border-radius: 50%;
40
33
}
41
34
#handle {
42
35
margin-top: 20px;
43
36
}
44
37
45
- /* π± Media queries support */
46
- @media (max-width: 600px) {
38
+ @media (max-width: 600px) { // π± Media queries support
47
39
& {font-size: 18px;}
48
40
}
49
41
`
50
42
51
43
render () {
52
- /* πΌ Attaches styles to the highest element in your component */
53
- return (< div>
44
+ return (< div> // πΌ Attaches styles to the highest element in your component
54
45
< img src= " https://github.com/siddharthkp.png" / >
55
46
< div id= " handle" > @siddharthkp< / div>
56
47
< / div> )
0 commit comments