Skip to content

Commit 110d2d7

Browse files
committed
Add browser extension docs
1 parent 75e5acd commit 110d2d7

14 files changed

+453
-7
lines changed

components/warning.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import type { ReactNode } from 'react';
2+
3+
interface WarningProps {
4+
children: ReactNode;
5+
title?: string;
6+
}
7+
8+
/**
9+
* A Vue-style warning component for documentation.
10+
* Displays a warning callout with a yellow accent, similar to VitePress/VuePress warning blocks.
11+
*/
12+
export function Warning({ children, title = 'WARNING' }: WarningProps) {
13+
return (
14+
<div className="my-4 rounded-lg border border-yellow-200 bg-yellow-50 dark:border-yellow-900/50 dark:bg-yellow-950/30">
15+
<div className="flex items-start gap-3 px-4 pb-4 pt-2">
16+
<div className="flex-1">
17+
<p className="mb-2 text-sm font-semibold uppercase text-yellow-700 dark:text-yellow-400">
18+
{title}
19+
</p>
20+
<div className="text-sm text-yellow-800 dark:text-yellow-200 [&>p]:m-0 [&>p:not(:last-child)]:mb-2">
21+
{children}
22+
</div>
23+
</div>
24+
</div>
25+
</div>
26+
);
27+
}
28+

components/youtube.tsx

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,72 @@
1+
'use client';
2+
3+
import { useState } from 'react';
4+
15
interface YouTubeProps {
26
id: string;
37
title?: string;
8+
splash?: string;
9+
width?: number;
10+
height?: number;
411
}
512

613
/**
714
* A YouTube embed component for documentation.
8-
* Uses lite-youtube-embed style with a thumbnail preview.
15+
* When a splash image URL is provided, shows the image with a play button overlay.
16+
* Clicking loads the YouTube player with autoplay.
917
*/
10-
export function YouTube({ id, title = 'YouTube Video' }: YouTubeProps) {
18+
export function YouTube({ id, title = 'YouTube Video', splash, width, height }: YouTubeProps) {
19+
const [playing, setPlaying] = useState(false);
20+
21+
const w = width ? Number(width) : undefined;
22+
const h = height ? Number(height) : undefined;
23+
const hasSize = w || h;
24+
const containerClass = hasSize
25+
? "relative my-4 overflow-hidden rounded-lg"
26+
: "relative my-4 aspect-video w-full overflow-hidden rounded-lg";
27+
const containerStyle = hasSize ? { width: w, height: h } : undefined;
28+
29+
if (splash && !playing) {
30+
return (
31+
<div className={containerClass} style={containerStyle}>
32+
<button
33+
type="button"
34+
className="group relative block h-full w-full cursor-pointer border-0 bg-transparent p-0"
35+
onClick={() => setPlaying(true)}
36+
aria-label={`Play ${title}`}
37+
>
38+
<img
39+
src={splash}
40+
alt={title}
41+
className="h-full w-full object-cover"
42+
/>
43+
<div className="absolute inset-0 flex items-center justify-center bg-black/5 transition-colors group-hover:bg-black/15">
44+
<svg
45+
className="h-16 w-16 text-white drop-shadow-lg transition-transform group-hover:scale-110"
46+
viewBox="0 0 68 48"
47+
fill="none"
48+
>
49+
<path
50+
d="M66.52 7.74c-.78-2.93-2.49-5.41-5.42-6.19C55.79.13 34 0 34 0S12.21.13 6.9 1.55C3.97 2.33 2.27 4.81 1.48 7.74 0.06 13.05 0 24 0 24s0.06 10.95 1.48 16.26c0.78 2.93 2.49 5.41 5.42 6.19C12.21 47.87 34 48 34 48s21.79-.13 27.1-1.55c2.93-.78 4.64-3.26 5.42-6.19C67.94 34.95 68 24 68 24s-.06-10.95-1.48-16.26z"
51+
fill="#FF0000"
52+
/>
53+
<path d="M45 24L27 14v20" fill="white" />
54+
</svg>
55+
</div>
56+
</button>
57+
</div>
58+
);
59+
}
60+
1161
return (
12-
<div className="relative my-4 aspect-video w-full overflow-hidden rounded-lg">
62+
<div className={containerClass} style={containerStyle}>
1363
<iframe
14-
className="absolute inset-0 h-full w-full"
15-
src={`https://www.youtube.com/embed/${id}`}
64+
className={hasSize ? "h-full w-full" : "absolute inset-0 h-full w-full"}
65+
src={`https://www.youtube.com/embed/${id}${splash ? '?autoplay=1' : ''}`}
1666
title={title}
1767
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
1868
allowFullScreen
1969
/>
2070
</div>
2171
);
2272
}
23-

0 commit comments

Comments
 (0)