-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwrapper.jsx
More file actions
59 lines (53 loc) · 2.01 KB
/
Copy pathwrapper.jsx
File metadata and controls
59 lines (53 loc) · 2.01 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
53
54
55
56
57
58
59
import React from 'react';
function joinCSSClasses(...classStrs) {
//This function takes a series of class strings and joins them together in a single string.
//For another option, check out the awesome classnames package: https://www.npmjs.com/package/classnames
return classStrs
.filter(classStr => classStr)
.join(' ');
}
export default class wrapper extends React.Component {
constructor() {
super();
this.state = { tick: 0 };
}
render() {
const tickMod = this.state.tick % 3;
const attrs = {
h1: {
className: joinCSSClasses(
//The following initially returns: "A B C D E F"
PreStyle`
@include overflow-text-boundry(); //<- Using a Sass mixin from our _vars Sass partial
font-weight: bold;
text-align: center;
transition: color .35s ease-in;
`,
(tickMod === 0 && PreStyle`color: $color1;`), //Initially returns: "G"; $color1 is in our _vars Sass partial
(tickMod === 1 && PreStyle`color: $color2;`), //Initially returns: "H"; $color2 is in our _vars Sass partial
(tickMod === 2 && PreStyle`color: $color3;`) //Initially returns: "I"; $color3 is in our _vars Sass partial
)
},
h2: {
//The following initially returns "D E", because we've already used these properties before. Your properties are completely reusable without bloating the resulting CSS file or JS files... Pre-Style just strips out unused styles.
className: PreStyle`
font-weight: bold;
text-align: center;
`
}
};
return (<main>
<h1 {...attrs.h1}>Hello World!</h1>
<h2 {...attrs.h2}>This is a React + Pre-Style + Webpack + Hot Module Reloading demo</h2>
</main>);
}
componentDidMount() {
this.loadInterval = setInterval(() => {
this.setState({ tick: this.state.tick + 1 });
}, 1000);
}
componentWillUnmount () {
if (this.loadInterval) clearInterval(this.loadInterval);
this.loadInterval = false;
}
}