Skip to content

Commit 21dcd67

Browse files
authored
Merge pull request #9 from nyaomaru/deno-study-7
stydy: add test, change source directory, and refactor
2 parents dc79f1f + 5715577 commit 21dcd67

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+346
-231
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,11 @@ deno task start
1111
```
1212

1313
Then you can access to http://localhost:8000/
14+
15+
## 🧪 Test
16+
17+
If you try the deno test, you could run below command.
18+
19+
```sh
20+
deno test --allow-read --allow-env --allow-net
21+
```

components/Button.tsx

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

components/Link.tsx

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

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
55
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
66
"manifest": "deno task cli manifest $(pwd)",
7-
"start": "deno run -A --watch=static/,routes/ dev.ts",
7+
"start": "deno run -A --watch=src/static/,src/routes/ src/dev.ts",
88
"build": "deno run -A dev.ts build",
99
"preview": "deno run -A main.ts",
1010
"update": "deno run -A -r https://fresh.deno.dev/update ."

dev.ts

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

routes/_app.tsx

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

routes/about.tsx

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

routes/countdown.tsx

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

routes/greet/[name].tsx

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

routes/search.tsx

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

routes/subscribe.tsx

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

src/components/Button.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { JSX } from "preact";
2+
import { IS_BROWSER } from "$fresh/runtime.ts";
3+
4+
type ButtonProps = {
5+
color?: "primary" | "secondary";
6+
} & JSX.HTMLAttributes<HTMLButtonElement>;
7+
8+
export function Button(
9+
{ color = "primary", ...props }: ButtonProps,
10+
) {
11+
return (
12+
<button
13+
{...props}
14+
disabled={!IS_BROWSER || props.disabled}
15+
class={`px-2 py-1 border-2 rounded ${
16+
color === "primary"
17+
? "bg-black text-white hover:text-black"
18+
: "bg-white border-gray-500"
19+
} hover:bg-gray-200 transition-colors`}
20+
/>
21+
);
22+
}
File renamed without changes.

src/components/Link.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
type LinkProps = {
2+
text: string;
3+
href: string;
4+
color?: "primary" | "secondary";
5+
};
6+
7+
export function Link({ color = "primary", ...props }: LinkProps) {
8+
return (
9+
<a class="mx-2" href={props.href}>
10+
<span
11+
class={`align-middle select-none font-sans font-bold text-center uppercase transition-all disabled:opacity-50 disabled:shadow-none disabled:pointer-events-none text-xs py-3 px-6 rounded-lg ${
12+
color === "primary" ? "bg-gray-900 text-white" : "bg-white text-black"
13+
} shadow-md shadow-gray-900/10 hover:shadow-lg hover:shadow-gray-900/20 focus:opacity-[0.85] focus:shadow-none active:opacity-[0.85] active:shadow-none`}
14+
type="button"
15+
>
16+
{props.text}
17+
</span>
18+
</a>
19+
);
20+
}

src/dev.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env -S deno run -A --watch=static/,routes/
2+
3+
import dev from "$fresh/dev.ts";
4+
import config from "./fresh.config.ts";
5+
6+
import "$std/dotenv/load.ts";
7+
8+
await dev(import.meta.url, "./main.ts", config);
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

main.ts renamed to src/main.ts

File renamed without changes.
File renamed without changes.
File renamed without changes.

src/routes/_app.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { type PageProps } from "$fresh/server.ts";
2+
export default function App({ Component }: PageProps) {
3+
return (
4+
<html>
5+
<head>
6+
<meta charset="utf-8" />
7+
<meta name="author" content="nyaomaru" />
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
9+
<meta
10+
name="description"
11+
content="This fresh sample brought to you by nyaomaru"
12+
/>
13+
<meta name="og:title" content="nyaomaru-deno-sample" />
14+
<meta property="og:locale" content="ja_JP" key="ogLocale" />
15+
<meta
16+
property="og:site_name"
17+
content="nyaomaru-deno-sample"
18+
key="ogSiteName"
19+
/>
20+
<meta
21+
name="og:description"
22+
content="This fresh sample brought to you by nyaomaru"
23+
/>
24+
<meta property="og:type" content="website" key="ogType" />
25+
<meta
26+
name="apple-mobile-web-app-title"
27+
content="nyaomaru-deno-sample"
28+
/>
29+
<title>nyaomaru-deno-sample</title>
30+
<link rel="stylesheet" href="/styles.css" />
31+
</head>
32+
<body>
33+
<Component />
34+
</body>
35+
</html>
36+
);
37+
}
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)