Skip to content

Commit c5cd559

Browse files
committed
Add tailwindcss to simplify future css.
1 parent 75b8744 commit c5cd559

9 files changed

+823
-55
lines changed

head.ts

+6-14
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,13 @@ export default function Head({ pageTitle, styles }: { pageTitle?: string, styles
33
<meta charset="UTF-8">
44
<meta name="viewport" content="width=device-width, initial-scale=1.0">
55
<title>${ pageTitle || "MyTube App"}</title>
6+
<link rel="stylesheet" href="/static/main.build.css" />
67
<style>
7-
#dropzone {
8-
width: 75%;
9-
height: 10px;
10-
transition: height 100ms ease-out;
11-
}
12-
#dropzone.active {
13-
height: 25px;
14-
border: 4px dashed red;
15-
}
16-
body {
17-
background: black;
18-
color: white;
19-
}
20-
${styles || ""}
8+
body {
9+
background: black;
10+
color: white;
11+
}
12+
${styles || ""}
2113
</style>
2214
<script src="https://unpkg.com/[email protected]"></script>
2315
<script type="module" src="/static/MyTube.js"></script>

home-controller.ts

+27-10
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,33 @@ import Player from "./player/player.ts";
33
import Head from "./head.ts";
44
import Html from "./html.ts";
55
import { compressResponse } from "./utils.ts";
6+
import { YT_API_KEY } from "./.env.json";
67

78
export default async function HomeController(request: Request): Promise<Response> {
8-
const html = Html({
9-
head: Head({
10-
pageTitle: "MyTube Home Page",
11-
}),
12-
body: Player(),
13-
})
14-
const res: Response = compressResponse(html, request, {
15-
headers: { [Headers.ContentType]: ContentTypes.Html }
16-
});
17-
return res;
9+
let url = `https://www.googleapis.com/youtube/v3/videos?key=${YT_API_KEY}&part=snippet,statistics&chart=mostPopular`;
10+
11+
try {
12+
const ytResponse = await fetch(url);
13+
if (!ytResponse.ok) throw new Error("Response status: " + ytResponse.status);
14+
15+
const json = await ytResponse.json();
16+
17+
const html = Html({
18+
head: Head({
19+
pageTitle: "MyTube Home Page",
20+
}),
21+
body: Player(json),
22+
})
23+
const res: Response = compressResponse(html, request, {
24+
headers: { [Headers.ContentType]: ContentTypes.Html }
25+
});
26+
return res;
27+
28+
} catch (error) {
29+
return new Response(`<pre>${error}\n${error.stack}</pre>`, {
30+
headers: {
31+
[Headers.ContentType]: ContentTypes.Html,
32+
},
33+
});
34+
}
1835
}

package.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
{
22
"name": "todo",
33
"version": "1.0.0",
4-
"description": "Todo app made simply",
4+
"author": "Darren Dub",
55
"main": "index.tsx",
6+
"devDependencies": {
7+
"@types/bun": "^1.1.6",
8+
"tailwindcss": "^3.4.4"
9+
},
10+
"description": "Todo app made simply",
11+
"license": "ISC",
612
"scripts": {
713
"start": "bun run --hot index.ts",
14+
"tailwind:build": "bun run tailwindcss -i ./static/main.css -o ./static/main.build.css --watch",
815
"debug": "bun run --inspect index.ts"
9-
},
10-
"author": "Darren Dub",
11-
"license": "ISC",
12-
"devDependencies": {
13-
"@types/bun": "^1.1.6"
1416
}
1517
}

player/player.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export default function Player() {
1+
export default function Player(data) {
22
return (`
33
<div id="player"></div>
44
<script type="module" src="./player/static/scripts.js"></script>

search.ts

+34-24
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,40 @@ type SearchResource = {
55
channelId: string;
66
playlistId?: string;
77
},
8-
snippet: {
9-
publishedAt: Date;
10-
channelId: string;
11-
title: string;
12-
description: string;
13-
thumbnails: {
14-
default?: {
15-
url: string;
16-
width: number;
17-
height: number;
18-
},
19-
medium?: {
20-
url: string;
21-
width: number;
22-
height: number;
23-
},
24-
high?: {
25-
url: string;
26-
width: number;
27-
height: number;
28-
},
29-
};
30-
channelTitle: string;
31-
}
8+
snippet?: Snippet;
9+
statistics?: Statistics;
10+
}
11+
12+
type Snippet = {
13+
publishedAt: Date;
14+
channelId: string;
15+
title: string;
16+
description: string;
17+
thumbnails: {
18+
default?: {
19+
url: string;
20+
width: number;
21+
height: number;
22+
},
23+
medium?: {
24+
url: string;
25+
width: number;
26+
height: number;
27+
},
28+
high?: {
29+
url: string;
30+
width: number;
31+
height: number;
32+
},
33+
};
34+
channelTitle: string;
35+
}
36+
37+
type Statistics = {
38+
viewCount: number;
39+
likeCount: number;
40+
favoriteCount: number;
41+
commentCount: number;
3242
}
3343

3444
type SearchResponse = {

0 commit comments

Comments
 (0)