Skip to content

Commit 7a38420

Browse files
committed
chore: implement css-tests example (pt2)
1 parent 47eebe6 commit 7a38420

37 files changed

+364
-174
lines changed

examples/css-tests/src/app.css

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
11
@import "tailwindcss";
22

3-
:root {
4-
--background-rgb: 214, 219, 220;
5-
--foreground-rgb: 0, 0, 0;
3+
@theme {
4+
--color-success: var(--color-emerald-700);
5+
--color-error: var(--color-rose-700);
6+
--color-warn: var(--color-orange-500);
67
}
78

8-
body {
9-
background: rgb(var(--background-rgb));
10-
color: rgb(var(--foreground-rgb));
11-
}
9+
@layer base {
10+
body {
11+
@apply bg-gray-800 text-gray-100;
12+
}
13+
14+
a {
15+
@apply text-sky-400 underline underline-offset-4 hover:no-underline;
16+
}
1217

13-
.appStyle {
14-
background-color: seagreen;
18+
h1 {
19+
@apply text-2xl font-bold;
20+
}
1521
}

examples/css-tests/src/app.tsx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,11 @@ export default function App() {
1010
root={props => (
1111
<MetaProvider>
1212
<Title>SolidStart - CSS Tests</Title>
13-
<div class="mx-auto max-w-5xl p-10 text-gray-800">
14-
<header class="flex gap-3 underline mb-4">
15-
<a class="text-blue-800" href="/">
16-
Index
17-
</a>
18-
<a class="text-blue-800" href="/about">
19-
About
20-
</a>
13+
<div class="mx-auto max-w-5xl p-10 pt-3">
14+
<header class="flex gap-3 mb-4">
15+
<a href="/">Index</a>
16+
<a href="/empty">Empty</a>
17+
<a href="/unstyled">Unstyled</a>
2118
</header>
2219

2320
<Suspense>{props.children}</Suspense>

examples/css-tests/src/components/Counter.css

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/css-tests/src/components/Counter.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

examples/css-tests/src/components/NotFound.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import { createSignal, FlowProps, onMount } from "solid-js";
2+
import { getRequestEvent } from "solid-js/web";
3+
4+
const Badge = (props: FlowProps) => (
5+
<div class="text-base text-white bg-gray-700 rounded-lg px-2 font-medium">{props.children}</div>
6+
);
7+
8+
const Layout = (props: FlowProps<{ title: string }>) => {
9+
const [mounted, setMounted] = createSignal(false);
10+
onMount(() => setMounted(true));
11+
12+
return (
13+
<div class="flex gap-2 flex-col">
14+
<div class="flex items-center gap-2 flex-wrap">
15+
<h1>{props.title}</h1>
16+
<Badge>Environment: {import.meta.env.DEV ? "DEV" : "PROD"}</Badge>
17+
<Badge>Rendered: {!mounted() ? "Server" : "Server & Client"}</Badge>
18+
</div>
19+
20+
<div class="text-gray-500 text-sm font-medium">
21+
Agent:{" "}
22+
<span class="text-xs">
23+
{getRequestEvent()?.request.headers.get("user-agent") ?? navigator.userAgent}
24+
</span>
25+
</div>
26+
27+
<ul class="list-inside list-disc mb-4 text-gray-400 font-semibold text-xs">
28+
<li>
29+
Enable throttling & disable cache in the network tab to see eventual frames of unstyled
30+
content
31+
</li>
32+
<li>Click on routes to test client navigation</li>
33+
</ul>
34+
35+
<div class="grid grid-cols-[repeat(5,auto)] gap-4 gap-y-2">
36+
<div class="grid col-span-full grid-cols-subgrid px-4 text-gray-400 text-sm">
37+
<div>Component</div>
38+
<div>File</div>
39+
<div>Integration</div>
40+
<div>Lazy</div>
41+
<div>Comments</div>
42+
</div>
43+
44+
{props.children}
45+
</div>
46+
47+
<div class="flex justify-end gap-2 items-center text-sm uppercase font-bold text-white">
48+
<div class="grid content-center rounded-lg bg-success px-2">pass</div>
49+
<div class="grid content-center rounded-lg bg-error px-2">fail</div>
50+
<div class="grid content-center rounded-lg bg-warn px-2">not supported</div>
51+
</div>
52+
</div>
53+
);
54+
};
55+
56+
export default Layout;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import "../styles/lazy.css";
2+
3+
const Lazy = () => {
4+
return <></>
5+
}
6+
7+
export default Lazy;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import url from "../styles/lazyLink.css?url";
2+
3+
const Lazy = () => <link rel="stylesheet" href={url} />
4+
5+
export default Lazy;
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import url from "../styles/lazyLinkTmp.css?url";
2+
3+
const Lazy = () => <link rel="stylesheet" href={url} />
4+
5+
export default Lazy;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { mountAssets } from "@solidjs/start/client";
2+
import url from "../styles/lazyMountAssets.css?url";
3+
4+
const Lazy = () => {
5+
mountAssets([
6+
{
7+
tag: "link",
8+
attrs: {
9+
href: url,
10+
rel: "stylesheet"
11+
}
12+
}
13+
]);
14+
15+
return <></>
16+
}
17+
18+
export default Lazy;

0 commit comments

Comments
 (0)