Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added SolidStart #24

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions solidstart-ssr/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

dist
.solid
.output
.vercel
.netlify
netlify

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/

# Temp
gitignore

# System Files
.DS_Store
Thumbs.db
30 changes: 30 additions & 0 deletions solidstart-ssr/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SolidStart

Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);

## Creating a project

```bash
# create a new project in the current directory
npm init solid@latest

# create a new project in my-app
npm init solid@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

Solid apps are built with _adapters_, which optimise your project for deployment to different environments.

By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.
27 changes: 27 additions & 0 deletions solidstart-ssr/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "solidstart",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
},
"type": "module",
"devDependencies": {
"@types/node": "^18.11.18",
"esbuild": "^0.14.54",
"postcss": "^8.4.21",
"solid-start-node": "^0.2.19",
"typescript": "^4.9.4",
"vite": "^4.1.4"
},
"dependencies": {
"@solidjs/meta": "^0.28.2",
"@solidjs/router": "^0.8.2",
"solid-js": "^1.7.2",
"solid-start": "^0.2.26",
"undici": "^5.15.1"
},
"engines": {
"node": ">=16.8"
}
}
Binary file added solidstart-ssr/public/favicon.ico
Binary file not shown.
20 changes: 20 additions & 0 deletions solidstart-ssr/src/components/Counter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.increment {
font-family: inherit;
font-size: inherit;
padding: 1em 2em;
color: #335d92;
background-color: rgba(68, 107, 158, 0.1);
border-radius: 2em;
border: 2px solid rgba(68, 107, 158, 0);
outline: none;
width: 200px;
font-variant-numeric: tabular-nums;
}

.increment:focus {
border: 2px solid #335d92;
}

.increment:active {
background-color: rgba(68, 107, 158, 0.2);
}
11 changes: 11 additions & 0 deletions solidstart-ssr/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createSignal } from "solid-js";
import "./Counter.css";

export default function Counter() {
const [count, setCount] = createSignal(0);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
</button>
);
}
3 changes: 3 additions & 0 deletions solidstart-ssr/src/entry-client.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { mount, StartClient } from "solid-start/entry-client";

mount(() => <StartClient />, document);
9 changes: 9 additions & 0 deletions solidstart-ssr/src/entry-server.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {
createHandler,
renderAsync,
StartServer,
} from "solid-start/entry-server";

export default createHandler(
renderAsync((event) => <StartServer event={event} />)
);
40 changes: 40 additions & 0 deletions solidstart-ssr/src/root.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
body {
font-family: Gordita, Roboto, Oxygen, Ubuntu, Cantarell,
'Open Sans', 'Helvetica Neue', sans-serif;
}

a {
margin-right: 1rem;
}

main {
text-align: center;
padding: 1em;
margin: 0 auto;
}

h1 {
color: #335d92;
text-transform: uppercase;
font-size: 4rem;
font-weight: 100;
line-height: 1.1;
margin: 4rem auto;
max-width: 14rem;
}

p {
max-width: 14rem;
margin: 2rem auto;
line-height: 1.35;
}

@media (min-width: 480px) {
h1 {
max-width: none;
}

p {
max-width: none;
}
}
39 changes: 39 additions & 0 deletions solidstart-ssr/src/root.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// @refresh reload
import { Suspense } from "solid-js";
import {
A,
Body,
ErrorBoundary,
FileRoutes,
Head,
Html,
Meta,
Routes,
Scripts,
Title,
} from "solid-start";
import "./root.css";

export default function Root() {
return (
<Html lang="en">
<Head>
<Title>SolidStart - Bare</Title>
<Meta charset="utf-8" />
<Meta name="viewport" content="width=device-width, initial-scale=1" />
</Head>
<Body>
<Suspense>
<ErrorBoundary>
<A href="/">Index</A>
<A href="/about">About</A>
<Routes>
<FileRoutes />
</Routes>
</ErrorBoundary>
</Suspense>
<Scripts />
</Body>
</Html>
);
}
19 changes: 19 additions & 0 deletions solidstart-ssr/src/routes/[...404].tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Title } from "solid-start";
import { HttpStatusCode } from "solid-start/server";

export default function NotFound() {
return (
<main>
<Title>Not Found</Title>
<HttpStatusCode code={404} />
<h1>Page Not Found</h1>
<p>
Visit{" "}
<a href="https://start.solidjs.com" target="_blank">
start.solidjs.com
</a>{" "}
to learn how to build SolidStart apps.
</p>
</main>
);
}
19 changes: 19 additions & 0 deletions solidstart-ssr/src/routes/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Title } from "solid-start";
import Counter from "~/components/Counter";

export default function Home() {
return (
<main>
<Title>Hello World</Title>
<h1>Hello world!</h1>
<Counter />
<p>
Visit{" "}
<a href="https://start.solidjs.com" target="_blank">
start.solidjs.com
</a>{" "}
to learn how to build SolidStart apps.
</p>
</main>
);
}
17 changes: 17 additions & 0 deletions solidstart-ssr/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
"esModuleInterop": true,
"target": "ESNext",
"module": "ESNext",
"moduleResolution": "node",
"jsxImportSource": "solid-js",
"jsx": "preserve",
"strict": true,
"types": ["solid-start/env"],
"baseUrl": "./",
"paths": {
"~/*": ["./src/*"]
}
}
}
6 changes: 6 additions & 0 deletions solidstart-ssr/vite.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import solid from "solid-start/vite";
import { defineConfig } from "vite";

export default defineConfig({
plugins: [solid()],
});
24 changes: 24 additions & 0 deletions solidstart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

dist
.solid
.output
.vercel
.netlify
netlify

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
*.launch
.settings/

# Temp
gitignore

# System Files
.DS_Store
Thumbs.db
30 changes: 30 additions & 0 deletions solidstart/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SolidStart

Everything you need to build a Solid project, powered by [`solid-start`](https://start.solidjs.com);

## Creating a project

```bash
# create a new project in the current directory
npm init solid@latest

# create a new project in my-app
npm init solid@latest my-app
```

## Developing

Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:

```bash
npm run dev

# or start the server and open the app in a new browser tab
npm run dev -- --open
```

## Building

Solid apps are built with _adapters_, which optimise your project for deployment to different environments.

By default, `npm run build` will generate a Node app that you can run with `npm start`. To use a different adapter, add it to the `devDependencies` in `package.json` and specify in your `vite.config.js`.
27 changes: 27 additions & 0 deletions solidstart/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"name": "solidstart",
"scripts": {
"dev": "solid-start dev",
"build": "solid-start build",
"start": "solid-start start"
},
"type": "module",
"devDependencies": {
"@types/node": "^18.11.18",
"esbuild": "^0.14.54",
"postcss": "^8.4.21",
"solid-start-node": "^0.2.19",
"typescript": "^4.9.4",
"vite": "^4.1.4"
},
"dependencies": {
"@solidjs/meta": "^0.28.2",
"@solidjs/router": "^0.8.2",
"solid-js": "^1.7.2",
"solid-start": "^0.2.26",
"undici": "^5.15.1"
},
"engines": {
"node": ">=16.8"
}
}
Binary file added solidstart/public/favicon.ico
Binary file not shown.
20 changes: 20 additions & 0 deletions solidstart/src/components/Counter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.increment {
font-family: inherit;
font-size: inherit;
padding: 1em 2em;
color: #335d92;
background-color: rgba(68, 107, 158, 0.1);
border-radius: 2em;
border: 2px solid rgba(68, 107, 158, 0);
outline: none;
width: 200px;
font-variant-numeric: tabular-nums;
}

.increment:focus {
border: 2px solid #335d92;
}

.increment:active {
background-color: rgba(68, 107, 158, 0.2);
}
11 changes: 11 additions & 0 deletions solidstart/src/components/Counter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { createSignal } from "solid-js";
import "./Counter.css";

export default function Counter() {
const [count, setCount] = createSignal(0);
return (
<button class="increment" onClick={() => setCount(count() + 1)}>
Clicks: {count()}
</button>
);
}
Loading