generated from garronej/ts-ci
-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
index.tsx
369 lines (329 loc) · 11.6 KB
/
index.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
import Head from "next/head";
import { GlobalStyles } from "tss-react";
import { makeStyles, useStyles, withStyles } from "../shared/makeStyles";
import { muiCache } from "../shared/muiCache";
import { CacheProvider } from "@emotion/react";
import { styled } from "@mui/material";
import Button from "@mui/material/Button"
import { ThemeProvider as MuiThemeProvider } from "@mui/material/styles";
import { createTheme } from "@mui/material/styles";
import CssBaseline from "@mui/material/CssBaseline";
import Breadcrumbs from "@mui/material/Breadcrumbs";
const theme = createTheme({
"palette": {
"primary": {
"main": "#32CD32" //Limegreen
}
}
});
export default function Home() {
return (
<>
<Head>
<title>Create Next App</title>
<meta name="description" content="Generated by create next app" />
<link rel="icon" href="/favicon.ico" />
</Head>
<CacheProvider value={muiCache}>
<MuiThemeProvider theme={theme}>
<CssBaseline />
<Root />
</MuiThemeProvider>
</CacheProvider>
</>
);
}
function Root() {
const { css } = useStyles();
return (
<App
className={css({ "boxShadow": "10px 5px 5px teal" })}
/>
);
}
const { App } = (() => {
const useStyles = makeStyles()((theme, _params, createRef) => {
const child = {
"ref": createRef(),
"background": "blue",
"border": "1px solid black"
};
const breadcrumbs2_separator = {
"ref": createRef(),
"color": "red"
};
const childRefTest_wrapper2 = {
"border": "1px solid black",
"margin": 30,
"height": 100,
"color": "black"
} as const;
const childRefTest_wrapper1 = {
"ref": createRef(),
...childRefTest_wrapper2
} as const;
return {
"root": {
"& > h1:nth-child(2)": {
"color": theme.palette.primary.main,
}
},
"ovStyled": {
"color": "darkred"
},
"ovInternal": {
"backgroundColor": "darkblue"
},
"parent": {
"border": "1px solid black",
"padding": 30,
[`&:hover .${child.ref}`]: {
"background": "red",
}
},
child,
"breadcrumbs_className": {
"backgroundColor": "lightblue",
"& .MuiBreadcrumbs-separator": {
"color": "red"
},
"&:hover .MuiBreadcrumbs-separator": {
"color": "blue"
}
},
"breadcrumbs2_root": {
"backgroundColor": "lightblue",
[`&:hover .${breadcrumbs2_separator.ref}`]: {
"color": "blue"
}
},
breadcrumbs2_separator,
"button2_className": {
"backgroundColor": "red"
},
"button2_root": {
"backgroundColor": "red"
},
"testCx_bgYellow": {
"backgroundColor": "yellow"
},
"testCx_bgCyan": {
"backgroundColor": "cyan"
},
"childRefTest_wrapper": {
"border": "1px solid black",
[`&:hover .${childRefTest_wrapper1.ref}`]: {
"backgroundColor": "cyan"
}
},
childRefTest_wrapper1,
childRefTest_wrapper2,
"childRefTest_textColorPink": {
"color": "pink"
},
"mq": {
"height": 100,
"backgroundColor": "lightgreen",
"@media (max-width: 960px)": {
"backgroundColor": "cyan"
}
}
};
});
const H1 = styled('h1')({
"color": "yellow"
});
function App(props: { className?: string; }) {
const { className } = props;
const { classes, css, cx } = useStyles();
return (
<>
<GlobalStyles
styles={{
"body": {
"backgroundColor": "pink"
},
".foo": {
"color": "cyan"
}
}}
/>
<div className={classes.root}>
<h1>Black</h1>
<h1>Should be lime green</h1>
<h1
className={cx(
css({ "border": "1px solid black" }),
className
)}
>
Black, should have border and shadow
</h1>
<h1 className="foo">Should be cyan</h1>
<H1>Should be yellow</H1>
<H1 className={classes.ovStyled}>Should be dark red</H1>
<Button variant="contained" color="primary"> Background should be lime green </Button>
<Button
variant="contained"
color="primary"
className={classes.ovInternal}
>
Background should be dark blue
</Button>
<div className={classes.parent}>
<div className={classes.child}>
Background should turn red when mouse is hover the parent.
</div>
</div>
<Breadcrumbs
className={classes.breadcrumbs_className}
color="primary"
>
<span>background should be lightblue</span>
<span>and the separator (/) should be red except when hover, then it is blue</span>
</Breadcrumbs>
<div style={{ "height": 10 }} />
<Breadcrumbs
classes={{
"root": classes.breadcrumbs2_root,
"separator": classes.breadcrumbs2_separator
}}
color="primary"
>
<span>background should be lightblue</span>
<span>and the separator (/) should be red except when hover, then it is blue</span>
</Breadcrumbs>
<Button
variant="contained"
color="primary"
className={classes.button2_className}
>
<span>The background should be red</span>
</Button>
<Button
variant="contained"
color="primary"
classes={{ "root": classes.button2_root, }}
>
<span>The background should be red</span>
</Button>
<div className={cx(classes.testCx_bgYellow, classes.testCx_bgCyan)}>
Background should be cyan
</div>
<div className={cx(classes.testCx_bgCyan, classes.testCx_bgYellow)}>
Background should be yellow
</div>
<div className={classes.childRefTest_wrapper}>
<div className={cx(
classes.childRefTest_textColorPink,
classes.childRefTest_wrapper1
)}>
Background should turn cyan when mouse hover the parent.
Also the text should NOT be pink
</div>
<div className={cx(classes.childRefTest_wrapper2)}>
Background should NOT turn cyan when mouse hover the parent.
</div>
</div>
<div className={classes.mq}>
The background color should turn from lightgreen to cyan when the window
inner with goes below 960px
</div>
<MyComponentStyled
className={css({ "color": "red" })}
colorSmall="cyan"
/>
<MyStyledButton>
The text should turn from red to blue when the
window inner width goes below 960px
</MyStyledButton>
<br />
<MyAnchorStyled href="http://exampe.com">
Background should be red
</MyAnchorStyled>
<MyAnchorStyled href="https://exampe.com">
Background should be limegreen
</MyAnchorStyled>
<div className={cx(
css({
"@media screen and (min-width: 1px)": {
"backgroundColor": "red"
},
"height": 50
}),
css({
"&&": {
"backgroundColor": "lightgreen"
}
})
)}>
background should be lightgreen
</div>
<div className={cx(
css({
"@media screen and (min-width: 1px)": {
"backgroundColor": "red"
},
"height": 50
}),
css({
"backgroundColor": "lightgreen"
})
)}>
background should be lightgreen
</div>
</div>
</>
);
}
return { App };
})();
function MyComponent(props: { className?: string; colorSmall: string; }) {
return (
<div className={props.className}>
The background color should turn from limegreen to cyan when the window
inner with goes below 960px.
Font should be red
</div>
);
}
const MyComponentStyled = withStyles(
MyComponent,
(theme, props) => ({
"root": {
"backgroundColor": theme.palette.primary.main,
"height": 100,
"marginTop": 20
},
"@media (max-width: 960px)": {
"root": {
"backgroundColor": props.colorSmall
},
}
})
);
const MyStyledButton = withStyles(
Button,
{
"text": {
"color": "red"
},
"@media (max-width: 960px)": {
"text": {
"color": "blue"
},
}
}
);
const MyAnchorStyled = withStyles(
"a",
(theme, { href }) => ({
"root": {
"border": "1px solid black",
"backgroundColor":
href?.startsWith("https") ?
theme.palette.primary.main :
"red"
}
})
);