Skip to content

Commit 6212171

Browse files
committed
chore: implement css-tests example
1 parent d72927f commit 6212171

23 files changed

Lines changed: 335 additions & 0 deletions

examples/css-tests/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# SolidStart
2+
3+
Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);
4+
5+
## Creating a project
6+
7+
```bash
8+
# create a new project in the current directory
9+
npm init solid@latest
10+
11+
# create a new project in my-app
12+
npm init solid@latest my-app
13+
```
14+
15+
## Developing
16+
17+
Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
18+
19+
```bash
20+
npm run dev
21+
22+
# or start the server and open the app in a new browser tab
23+
npm run dev -- --open
24+
```
25+
26+
## Building
27+
28+
Solid apps are built with _presets_, which optimise your project for deployment to different environments.
29+
30+
By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different preset, add it to the `devDependencies` in `package.json` and specify in your `app.config.js`.

examples/css-tests/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "example-css-tests",
3+
"type": "module",
4+
"scripts": {
5+
"dev": "vite dev",
6+
"build": "vite build",
7+
"start": "node .output/server/index.mjs"
8+
},
9+
"dependencies": {
10+
"@solidjs/meta": "^0.29.4",
11+
"@solidjs/router": "^0.15.0",
12+
"@solidjs/start": "file:../../packages/start",
13+
"solid-js": "^1.9.5",
14+
"vite": "7.1.3"
15+
},
16+
"engines": {
17+
"node": ">=22"
18+
},
19+
"devDependencies": {
20+
"@tailwindcss/vite": "^4.1.12",
21+
"tailwindcss": "^4.1.12"
22+
}
23+
}
664 Bytes
Binary file not shown.

examples/css-tests/src/app.css

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@import "tailwindcss";
2+
3+
:root {
4+
--background-rgb: 214, 219, 220;
5+
--foreground-rgb: 0, 0, 0;
6+
}
7+
8+
body {
9+
background: rgb(var(--background-rgb));
10+
color: rgb(var(--foreground-rgb));
11+
}
12+
13+
.appStyle {
14+
background-color: seagreen;
15+
}

examples/css-tests/src/app.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { MetaProvider, Title } from "@solidjs/meta";
2+
import { Router } from "@solidjs/router";
3+
import { FileRoutes } from "@solidjs/start/router";
4+
import { Suspense } from "solid-js";
5+
import "./app.css";
6+
7+
export default function App() {
8+
return (
9+
<Router
10+
root={props => (
11+
<MetaProvider>
12+
<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>
21+
</header>
22+
23+
<Suspense>{props.children}</Suspense>
24+
</div>
25+
</MetaProvider>
26+
)}
27+
>
28+
<FileRoutes />
29+
</Router>
30+
);
31+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
.increment {
2+
font-family: inherit;
3+
font-size: inherit;
4+
padding: 1em 2em;
5+
color: #335d92;
6+
background-color: rgba(68, 107, 158, 0.1);
7+
border-radius: 2em;
8+
border: 2px solid rgba(68, 107, 158, 0);
9+
outline: none;
10+
width: 200px;
11+
font-variant-numeric: tabular-nums;
12+
cursor: pointer;
13+
}
14+
15+
.increment:focus {
16+
border: 2px solid #335d92;
17+
}
18+
19+
.increment:active {
20+
background-color: rgba(68, 107, 158, 0.2);
21+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { createSignal } from "solid-js";
2+
import stylesUrl from "./stylesWithUrlLazy.css?url";
3+
4+
export default function Counter() {
5+
const [count, setCount] = createSignal(0);
6+
return (
7+
<>
8+
<link rel="stylesheet" href={stylesUrl} />
9+
<button
10+
class="w-[200px] rounded-full bg-gray-100 border-2 border-gray-300 focus:border-gray-400 active:border-gray-400 px-[2rem] py-[1rem]"
11+
onClick={() => setCount(count() + 1)}
12+
>
13+
Clicks: {count()}
14+
</button>
15+
</>
16+
);
17+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Title } from "@solidjs/meta";
2+
import { mountAssets } from "@solidjs/start/client";
3+
import url from "./notFound.css?url";
4+
5+
const NotFound = () => {
6+
mountAssets([
7+
{
8+
tag: "link",
9+
attrs: {
10+
href: url,
11+
rel: "stylesheet"
12+
}
13+
}
14+
]);
15+
16+
return (
17+
<>
18+
<Title>Not Found</Title>
19+
<h1>Page Not Found</h1>
20+
<p>
21+
Visit{" "}
22+
<a href="https://start.solidjs.com" target="_blank">
23+
start.solidjs.com
24+
</a>{" "}
25+
to learn how to build SolidStart apps.
26+
</p>
27+
</>
28+
);
29+
};
30+
31+
export default NotFound;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
body {
2+
background-color: orangered;
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.urlStyle--lazy {
2+
background-color: crimson;
3+
}

0 commit comments

Comments
 (0)