refactor: move counter example to top-level (#1219)

This commit is contained in:
Asher Gomez
2023-05-30 19:51:16 +02:00
committed by GitHub
parent 96ba036c12
commit 8347eadbef
9 changed files with 3 additions and 3 deletions
-11
View File
@@ -1,11 +0,0 @@
# fresh project
### Usage
Start the project:
```
deno task start
```
This will watch the project directory and restart as necessary.
-11
View File
@@ -1,11 +0,0 @@
{
"lock": false,
"tasks": {
"start": "deno run -A --watch=static/,routes/ dev.ts"
},
"importMap": "./import_map.json",
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
}
}
-5
View File
@@ -1,5 +0,0 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/
import dev from "$fresh/dev.ts";
await dev(import.meta.url, "./main.ts");
-20
View File
@@ -1,20 +0,0 @@
// DO NOT EDIT. This file is generated by fresh.
// This file SHOULD be checked into source version control.
// This file is automatically updated during development when running `dev.ts`.
import config from "./deno.json" assert { type: "json" };
import * as $0 from "./routes/index.tsx";
import * as $$0 from "./islands/Counter.tsx";
const manifest = {
routes: {
"./routes/index.tsx": $0,
},
islands: {
"./islands/Counter.tsx": $$0,
},
baseUrl: import.meta.url,
config,
};
export default manifest;
-8
View File
@@ -1,8 +0,0 @@
{
"imports": {
"$fresh/": "../../",
"preact": "https://esm.sh/preact@10.13.1",
"preact/": "https://esm.sh/preact@10.13.1/",
"preact-render-to-string": "https://esm.sh/*preact-render-to-string@5.2.6"
}
}
-21
View File
@@ -1,21 +0,0 @@
import { useState } from "preact/hooks";
import { IS_BROWSER } from "$fresh/runtime.ts";
interface CounterProps {
start: number;
}
export default function Counter(props: CounterProps) {
const [count, setCount] = useState(props.start);
return (
<div>
<p>{count}</p>
<button onClick={() => setCount(count - 1)} disabled={!IS_BROWSER}>
-1
</button>
<button onClick={() => setCount(count + 1)} disabled={!IS_BROWSER}>
+1
</button>
</div>
);
}
-10
View File
@@ -1,10 +0,0 @@
/// <reference no-default-lib="true" />
/// <reference lib="dom" />
/// <reference lib="dom.iterable" />
/// <reference lib="dom.asynciterable" />
/// <reference lib="deno.ns" />
import { start } from "$fresh/server.ts";
import manifest from "./fresh.gen.ts";
await start(manifest);
-13
View File
@@ -1,13 +0,0 @@
import Counter from "../islands/Counter.tsx";
export default function Home() {
return (
<div>
<p>
Welcome to Fresh. Try to update this message in the ./routes/index.tsx
file, and refresh.
</p>
<Counter start={3} />
</div>
);
}