-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathindex.js
More file actions
52 lines (47 loc) · 1.12 KB
/
index.js
File metadata and controls
52 lines (47 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Selectors get tricky. You should probably avoid them altogether since
// they break component style isolation.
import React from 'react';
import { createComponent } from 'cf-style-container';
import { header, btn } from './styles.css';
const Schwifty = createComponent(() => ({
color: 'blue',
':hover': {
textDecoration: 'line-through'
}
}));
const Button = createComponent(
({ index }) => ({
backgroundColor: 'orange',
marginLeft: index > 0 ? 0 : 25,
'> span': {
fontSize: 20
}
}),
'button'
);
const ButtonGroup = ({ children }) =>
<div>
{React.Children.map(children, (child, index) =>
React.cloneElement(child, {
index: index
})
)}
</div>;
export default () =>
<article>
<h1>5. Selectors</h1>
<div className={header}>Schwifty</div>
<Schwifty>Schwifty</Schwifty>
<p>
<button className={btn}>
Button 1 <span>BIG</span>
</button>
<button className={btn}>Button 2</button>
</p>
<ButtonGroup>
<Button>
Button 1 <span>BIG</span>
</Button>
<Button>Button 2</Button>
</ButtonGroup>
</article>;