Skip to content

Commit f8c1dd6

Browse files
committed
[Stream] Chapters in collapsible details
1 parent f938fdb commit f8c1dd6

File tree

1 file changed

+38
-36
lines changed

1 file changed

+38
-36
lines changed

src/components/Stream.astro

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import { z } from "astro:schema";
33
import { Badge } from "@astrojs/starlight/components";
44
import parse from "parse-duration";
5+
import Details from "./Details.astro";
56
67
type Props = z.input<typeof props>;
78
@@ -53,42 +54,43 @@ if (thumbnail) {
5354

5455
{
5556
chapters && (
56-
<p>
57-
<strong>Chapters</strong>
58-
<ul class="flex list-none gap-4 overflow-x-scroll pb-4 pl-0">
59-
{Object.entries(chapters).map(([chapter, time]) => {
60-
const totalSeconds = parse(time, "s");
61-
62-
const thumbnail = new URL(thumbnailUrl);
63-
thumbnail.searchParams.set("fit", "crop");
64-
thumbnail.searchParams.set("time", `${totalSeconds}s`);
65-
66-
return (
67-
<li class="mt-0!">
68-
<button
69-
class="flex h-full w-36 cursor-pointer flex-col rounded-sm border border-gray-200 bg-transparent p-4 dark:border-gray-700"
70-
data-chapter={chapter}
71-
data-time={totalSeconds}
72-
>
73-
<img
74-
src={thumbnail.toString()}
75-
alt={chapter}
76-
width="120"
77-
height="64"
78-
class="border-accent bg-accent/10 rounded-sm border"
79-
/>
80-
<div class="flex h-full flex-col items-center justify-between">
81-
<strong class="line-clamp-2 text-xs" title={chapter}>
82-
{chapter}
83-
</strong>
84-
<Badge text={time} variant="tip" class="w-fit" />
85-
</div>
86-
</button>
87-
</li>
88-
);
89-
})}
90-
</ul>
91-
</p>
57+
<Details header="Chapters" open={false}>
58+
<p>
59+
<ul class="flex list-none gap-4 overflow-x-scroll pb-4 pl-0">
60+
{Object.entries(chapters).map(([chapter, time]) => {
61+
const totalSeconds = parse(time, "s");
62+
63+
const thumbnail = new URL(thumbnailUrl);
64+
thumbnail.searchParams.set("fit", "crop");
65+
thumbnail.searchParams.set("time", `${totalSeconds}s`);
66+
67+
return (
68+
<li class="mt-0!">
69+
<button
70+
class="flex h-full w-36 cursor-pointer flex-col rounded-sm border border-gray-200 bg-transparent p-4 dark:border-gray-700"
71+
data-chapter={chapter}
72+
data-time={totalSeconds}
73+
>
74+
<img
75+
src={thumbnail.toString()}
76+
alt={chapter}
77+
width="120"
78+
height="64"
79+
class="border-accent bg-accent/10 rounded-sm border"
80+
/>
81+
<div class="flex h-full flex-col items-center justify-between">
82+
<strong class="line-clamp-2 text-xs" title={chapter}>
83+
{chapter}
84+
</strong>
85+
<Badge text={time} variant="tip" class="w-fit" />
86+
</div>
87+
</button>
88+
</li>
89+
);
90+
})}
91+
</ul>
92+
</p>
93+
</Details>
9294
)
9395
}
9496

0 commit comments

Comments
 (0)