Skip to content

Commit

Permalink
Merge pull request #9 from nyaomaru/deno-study-7
Browse files Browse the repository at this point in the history
stydy: add test, change source directory, and refactor
  • Loading branch information
nyaomaru authored Aug 10, 2024
2 parents dc79f1f + 5715577 commit 21dcd67
Show file tree
Hide file tree
Showing 44 changed files with 346 additions and 231 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,11 @@ deno task start
```

Then you can access to http://localhost:8000/

## 🧪 Test

If you try the deno test, you could run below command.

```sh
deno test --allow-read --allow-env --allow-net
```
12 changes: 0 additions & 12 deletions components/Button.tsx

This file was deleted.

17 changes: 0 additions & 17 deletions components/Link.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"check": "deno fmt --check && deno lint && deno check **/*.ts && deno check **/*.tsx",
"cli": "echo \"import '\\$fresh/src/dev/cli.ts'\" | deno run --unstable -A -",
"manifest": "deno task cli manifest $(pwd)",
"start": "deno run -A --watch=static/,routes/ dev.ts",
"start": "deno run -A --watch=src/static/,src/routes/ src/dev.ts",
"build": "deno run -A dev.ts build",
"preview": "deno run -A main.ts",
"update": "deno run -A -r https://fresh.deno.dev/update ."
Expand Down
8 changes: 0 additions & 8 deletions dev.ts

This file was deleted.

16 changes: 0 additions & 16 deletions routes/_app.tsx

This file was deleted.

46 changes: 0 additions & 46 deletions routes/about.tsx

This file was deleted.

15 changes: 0 additions & 15 deletions routes/countdown.tsx

This file was deleted.

19 changes: 0 additions & 19 deletions routes/greet/[name].tsx

This file was deleted.

52 changes: 0 additions & 52 deletions routes/search.tsx

This file was deleted.

45 changes: 0 additions & 45 deletions routes/subscribe.tsx

This file was deleted.

22 changes: 22 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { JSX } from "preact";
import { IS_BROWSER } from "$fresh/runtime.ts";

type ButtonProps = {
color?: "primary" | "secondary";
} & JSX.HTMLAttributes<HTMLButtonElement>;

export function Button(
{ color = "primary", ...props }: ButtonProps,
) {
return (
<button
{...props}
disabled={!IS_BROWSER || props.disabled}
class={`px-2 py-1 border-2 rounded ${
color === "primary"
? "bg-black text-white hover:text-black"
: "bg-white border-gray-500"
} hover:bg-gray-200 transition-colors`}
/>
);
}
File renamed without changes.
20 changes: 20 additions & 0 deletions src/components/Link.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
type LinkProps = {
text: string;
href: string;
color?: "primary" | "secondary";
};

export function Link({ color = "primary", ...props }: LinkProps) {
return (
<a class="mx-2" href={props.href}>
<span
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 ${
color === "primary" ? "bg-gray-900 text-white" : "bg-white text-black"
} 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`}
type="button"
>
{props.text}
</span>
</a>
);
}
8 changes: 8 additions & 0 deletions src/dev.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env -S deno run -A --watch=static/,routes/

import dev from "$fresh/dev.ts";
import config from "./fresh.config.ts";

import "$std/dotenv/load.ts";

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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
37 changes: 37 additions & 0 deletions src/routes/_app.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { type PageProps } from "$fresh/server.ts";
export default function App({ Component }: PageProps) {
return (
<html>
<head>
<meta charset="utf-8" />
<meta name="author" content="nyaomaru" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="This fresh sample brought to you by nyaomaru"
/>
<meta name="og:title" content="nyaomaru-deno-sample" />
<meta property="og:locale" content="ja_JP" key="ogLocale" />
<meta
property="og:site_name"
content="nyaomaru-deno-sample"
key="ogSiteName"
/>
<meta
name="og:description"
content="This fresh sample brought to you by nyaomaru"
/>
<meta property="og:type" content="website" key="ogType" />
<meta
name="apple-mobile-web-app-title"
content="nyaomaru-deno-sample"
/>
<title>nyaomaru-deno-sample</title>
<link rel="stylesheet" href="/styles.css" />
</head>
<body>
<Component />
</body>
</html>
);
}
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 21dcd67

Please sign in to comment.