Skip to content

Commit f3e45f3

Browse files
committed
css-jss case
1 parent 392c723 commit f3e45f3

File tree

13 files changed

+11368
-72
lines changed

13 files changed

+11368
-72
lines changed

packages/benchmarks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"react": "^16.8.6",
1616
"react-dom": "^16.8.6",
1717
"react-fela": "^10.2.1",
18-
"react-jss": "/Users/isonen/work/cssinjs/jss/packages/react-jss/",
18+
"react-jss": "^10.0.0-alpha.20",
1919
"react-native-web": "0.11.4",
2020
"reactxp": "^1.6.0-rc.3",
2121
"styled-components": "^4.1.3",
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/* eslint-disable react/prop-types */
2+
import React from 'react';
3+
import View from './View';
4+
import css from 'css-jss';
5+
6+
const Box = ({ color, fixed = false, layout = 'column', outer = false, ...other }) => (
7+
<View
8+
{...other}
9+
className={css({
10+
...styles[`color${color}`],
11+
...(fixed && styles.fixed),
12+
...(layout === 'row' && styles.row),
13+
...(outer && styles.outer)
14+
})}
15+
/>
16+
);
17+
18+
const styles = {
19+
outer: {
20+
alignSelf: 'flex-start',
21+
padding: 4
22+
},
23+
row: {
24+
flexDirection: 'row'
25+
},
26+
color0: {
27+
backgroundColor: '#14171A'
28+
},
29+
color1: {
30+
backgroundColor: '#AAB8C2'
31+
},
32+
color2: {
33+
backgroundColor: '#E6ECF0'
34+
},
35+
color3: {
36+
backgroundColor: '#FFAD1F'
37+
},
38+
color4: {
39+
backgroundColor: '#F45D22'
40+
},
41+
color5: {
42+
backgroundColor: '#E0245E'
43+
},
44+
fixed: {
45+
width: 6,
46+
height: 6
47+
}
48+
};
49+
50+
export default Box;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/* eslint-disable react/prop-types */
2+
import React from 'react';
3+
import css from 'css-jss';
4+
5+
const Dot = ({ size, x, y, children, color }) => (
6+
<div
7+
className={css(styles.root, {
8+
borderBottomColor: color,
9+
borderRightWidth: `${size / 2}px`,
10+
borderBottomWidth: `${size / 2}px`,
11+
borderLeftWidth: `${size / 2}px`,
12+
marginLeft: `${x}px`,
13+
marginTop: `${y}px`
14+
})}
15+
>
16+
{children}
17+
</div>
18+
);
19+
20+
const styles = {
21+
root: css({
22+
position: 'absolute',
23+
cursor: 'pointer',
24+
width: 0,
25+
height: 0,
26+
borderColor: 'transparent',
27+
borderStyle: 'solid',
28+
borderTopWidth: 0,
29+
transform: 'translate(50%, 50%)'
30+
})
31+
};
32+
33+
export default Dot;
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* eslint-disable react/prop-types */
2+
import classnames from 'classnames';
3+
import React from 'react';
4+
import css from 'css-jss';
5+
6+
class View extends React.Component {
7+
render() {
8+
const { className, ...other } = this.props;
9+
return <div {...other} className={classnames(css(styles.root), className)} />;
10+
}
11+
}
12+
13+
const styles = {
14+
root: {
15+
alignItems: 'stretch',
16+
borderWidth: 0,
17+
borderStyle: 'solid',
18+
boxSizing: 'border-box',
19+
display: 'flex',
20+
flexBasis: 'auto',
21+
flexDirection: 'column',
22+
flexShrink: 0,
23+
margin: 0,
24+
padding: 0,
25+
position: 'relative',
26+
// fix flexbox bugs
27+
minHeight: 0,
28+
minWidth: 0
29+
}
30+
};
31+
32+
export default View;
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
import View from './View';
2+
export default View;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Box from './Box';
2+
import Dot from './Dot';
3+
import Provider from './Provider';
4+
import View from './View';
5+
6+
export default {
7+
Box,
8+
Dot,
9+
Provider,
10+
View
11+
};

0 commit comments

Comments
 (0)