-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserve.tsx
113 lines (99 loc) · 1.86 KB
/
serve.tsx
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import React, { useEffect } from 'react';
import { createRoot } from 'react-dom/client';
import css, { OptionAliases, CSSFactory, CSSOptionProps } from './src'
type Aliases = {
m: string;
radius: number;
}
let aliases: OptionAliases<Aliases> = {
m: (val: string) => {
return {
margin: val + "px"
}
},
radius: (val: string) => {
return {
borderRadius: val + "px"
}
}
}
const App = () => {
const [count, setCount] = React.useState(0)
const _options = {
aliases,
breakpoints: {
xs: 0,
sm: 500,
md: 700,
lg: 900,
xl: 1100,
},
getValue: (p: any, v: any, _c: any,) => {
return v
},
}
const cls = css({
"&:hover": {
background: "yellow",
"& a": {
color: "red"
}
},
height: 200,
radius: 20,
background: {
xs: "orange",
sm: "red",
md: "blue",
lg: "green",
xl: "yellow",
},
}, _options)
const obj = {
name: "Test",
age: 25,
greet: function () {
return "Hello!";
},
nested: {
value: 42,
compute: function () {
return this.value * 2;
},
},
};
let length = 10000
// Plain JSON.stringify
console.time("Plain stringify");
for (let i = 0; i < length; i++) {
css({
"&:hover": {
background: "yellow",
"& a": {
color: "red"
}
},
height: 200,
radius: 20,
background: {
xs: "orange",
sm: "red",
md: "blue",
lg: "green",
xl: "yellow",
},
}, _options)
}
console.timeEnd("Plain stringify");
return (
<div>
wellcome
<button onClick={() => setCount(Math.random())}>up</button>
</div>
);
};
const rootEle = document.getElementById('root')
if (rootEle) {
const root = createRoot(rootEle);
root.render(<App />);
}