├── .devcontainer
├── devcontainer.json
└── icon.svg
├── .gitignore
├── .vscode
└── launch.json
├── LICENSE
├── README.md
├── index.html
├── jsconfig.json
├── package.json
├── public
└── vite.svg
├── src
├── assets
│ └── preact.svg
├── components
│ └── Header.jsx
├── index.jsx
├── pages
│ ├── Home
│ │ ├── index.jsx
│ │ └── style.css
│ └── _404.jsx
└── style.css
└── vite.config.js
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | {
2 | "image": "mcr.microsoft.com/devcontainers/universal:2",
3 | "hostRequirements": {
4 | "cpus": 4
5 | },
6 | "waitFor": "onCreateCommand",
7 | "updateContentCommand": "npm install",
8 | "postCreateCommand": "",
9 | "postAttachCommand": {
10 | "server": "npm run dev"
11 | },
12 | "customizations": {
13 | "codespaces": {
14 | "openFiles": [
15 | "src/index.jsx"
16 | ]
17 | }
18 | },
19 | "portsAttributes": {
20 | "5173": {
21 | "label": "Application",
22 | "onAutoForward": "openPreview"
23 | }
24 | },
25 | "forwardPorts": [5173]
26 | }
27 |
--------------------------------------------------------------------------------
/.devcontainer/icon.svg:
--------------------------------------------------------------------------------
1 |
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 | yarn-debug.log*
6 | yarn-error.log*
7 | pnpm-debug.log*
8 | lerna-debug.log*
9 |
10 | node_modules
11 | dist
12 | dist-ssr
13 | *.local
14 |
15 | # Editor directories and files
16 | .vscode/*
17 | !.vscode/extensions.json
18 | .idea
19 | .DS_Store
20 | *.suo
21 | *.ntvs*
22 | *.njsproj
23 | *.sln
24 | *.sw?
25 |
--------------------------------------------------------------------------------
/.vscode/launch.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "0.2.0",
3 | "configurations": [
4 | {
5 | "name": "Run application",
6 | "type": "node",
7 | "request": "launch",
8 | "cwd": "${workspaceFolder}",
9 | "console": "integratedTerminal",
10 | "runtimeExecutable": "npm",
11 | "runtimeArgs": [
12 | "run",
13 | "dev"
14 | ],
15 | "skipFiles": [
16 | "/**"
17 | ]
18 | }
19 | ]
20 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2022 GitHub
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GitHub Codespaces ♥️ Preact
2 |
3 | [Try Preact in a codespace](https://github.com/codespaces/new?template=preact)
4 |
5 | Welcome to your shiny new Codespace running Preact! We've got everything fired up and running for you to explore Preact.
6 |
7 | You've got a blank canvas to work on from a git perspective as well. There's a single initial commit with the what you're seeing right now - where you go from here is up to you!
8 |
9 | Everything you do here is contained within this one codespace. There is no repository on GitHub yet. If and when you’re ready you can click "Publish Branch" and we’ll create your repository and push up your project. If you were just exploring then and have no further need for this code then you can simply delete your codespace and it's gone forever.
10 |
11 | ## CLI Commands
12 |
13 | ```bash
14 | # Install dependencies
15 | npm install
16 |
17 | # Start a development server at localhost:5173
18 | npm run dev
19 |
20 | # Create a production build
21 | npm run build
22 |
23 | # Preview your production build locally at localhost:5173
24 | npm run preview
25 | ```
26 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Vite + Preact
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/jsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "ES2020",
4 | "module": "ESNext",
5 | "moduleResolution": "bundler",
6 | "noEmit": true,
7 | "allowJs": true,
8 | "checkJs": true,
9 | "jsx": "react-jsx",
10 | "jsxImportSource": "preact"
11 | },
12 | "include": ["node_modules/vite/client.d.ts", "**/*"]
13 | }
14 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "private": true,
3 | "type": "module",
4 | "scripts": {
5 | "dev": "vite",
6 | "build": "vite build",
7 | "preview": "vite preview --port 5173"
8 | },
9 | "dependencies": {
10 | "preact": "^10.13.1",
11 | "preact-iso": "^2.3.1",
12 | "preact-render-to-string": "^6.2.0"
13 | },
14 | "devDependencies": {
15 | "@preact/preset-vite": "^2.5.0",
16 | "vite": "^4.3.2"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/public/vite.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/assets/preact.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/components/Header.jsx:
--------------------------------------------------------------------------------
1 | import { useLocation } from 'preact-iso';
2 |
3 | export function Header() {
4 | const { url } = useLocation();
5 |
6 | return (
7 |
17 | );
18 | }
19 |
--------------------------------------------------------------------------------
/src/index.jsx:
--------------------------------------------------------------------------------
1 | import { render } from 'preact';
2 | import { LocationProvider, Router, Route } from 'preact-iso';
3 |
4 | import { Header } from './components/Header.jsx';
5 | import { Home } from './pages/Home/index.jsx';
6 | import { NotFound } from './pages/_404.jsx';
7 | import './style.css';
8 |
9 | export function App() {
10 | return (
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | );
21 | }
22 |
23 | render(, document.getElementById('app'));
24 |
--------------------------------------------------------------------------------
/src/pages/Home/index.jsx:
--------------------------------------------------------------------------------
1 | import preactLogo from '../../assets/preact.svg';
2 | import './style.css';
3 |
4 | export function Home() {
5 | return (
6 |
7 |
8 |
9 |
10 |
Get Started building Vite-powered Preact Apps
11 |
28 |
29 | );
30 | }
31 |
32 | function Resource(props) {
33 | return (
34 |
35 | {props.title}
36 | {props.description}
37 |
38 | );
39 | }
40 |
--------------------------------------------------------------------------------
/src/pages/Home/style.css:
--------------------------------------------------------------------------------
1 | img {
2 | margin-bottom: 1.5rem;
3 | }
4 |
5 | img:hover {
6 | filter: drop-shadow(0 0 2em #673ab8aa);
7 | }
8 |
9 | .home section {
10 | margin-top: 5rem;
11 | display: grid;
12 | grid-template-columns: repeat(3, 1fr);
13 | column-gap: 1.5rem;
14 | }
15 |
16 | .resource {
17 | padding: 0.75rem 1.5rem;
18 | border-radius: 0.5rem;
19 | text-align: left;
20 | text-decoration: none;
21 | color: #222;
22 | background-color: #f1f1f1;
23 | border: 1px solid transparent;
24 | }
25 |
26 | .resource:hover {
27 | border: 1px solid #000;
28 | box-shadow: 0 25px 50px -12px #673ab888;
29 | }
30 |
31 | @media (max-width: 639px) {
32 | .home section {
33 | margin-top: 5rem;
34 | grid-template-columns: 1fr;
35 | row-gap: 1rem;
36 | }
37 | }
38 |
39 | @media (prefers-color-scheme: dark) {
40 | .resource {
41 | color: #ccc;
42 | background-color: #161616;
43 | }
44 | .resource:hover {
45 | border: 1px solid #bbb;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/pages/_404.jsx:
--------------------------------------------------------------------------------
1 | export function NotFound() {
2 | return (
3 |
4 | 404: Not Found
5 | It's gone :(
6 |
7 | );
8 | }
9 |
--------------------------------------------------------------------------------
/src/style.css:
--------------------------------------------------------------------------------
1 | :root {
2 | font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
3 | line-height: 1.5;
4 | font-weight: 400;
5 |
6 | color: #222;
7 | background-color: #ffffff;
8 |
9 | font-synthesis: none;
10 | text-rendering: optimizeLegibility;
11 | -webkit-font-smoothing: antialiased;
12 | -moz-osx-font-smoothing: grayscale;
13 | -webkit-text-size-adjust: 100%;
14 | }
15 |
16 | body {
17 | margin: 0;
18 | }
19 |
20 | #app {
21 | display: flex;
22 | flex-direction: column;
23 | min-height: 100vh;
24 | }
25 |
26 | header {
27 | display: flex;
28 | justify-content: flex-end;
29 | background-color: #673ab8;
30 | }
31 |
32 | header nav {
33 | display: flex;
34 | }
35 |
36 | header a {
37 | color: #fff;
38 | padding: 0.75rem;
39 | text-decoration: none;
40 | }
41 |
42 | header a.active {
43 | background-color: #0005;
44 | }
45 |
46 | header a:hover {
47 | background-color: #0008;
48 | }
49 |
50 | main {
51 | flex: auto;
52 | display: flex;
53 | align-items: center;
54 | max-width: 1280px;
55 | margin: 0 auto;
56 | text-align: center;
57 | }
58 |
59 | @media (max-width: 639px) {
60 | main {
61 | margin: 2rem;
62 | }
63 | }
64 |
65 | @media (prefers-color-scheme: dark) {
66 | :root {
67 | color: #ccc;
68 | background-color: #1a1a1a;
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/vite.config.js:
--------------------------------------------------------------------------------
1 | import { defineConfig } from 'vite';
2 | import preact from '@preact/preset-vite';
3 |
4 | // https://vitejs.dev/config/
5 | export default defineConfig({
6 | plugins: [preact()],
7 | });
8 |
--------------------------------------------------------------------------------