● Zion Boggan
repos/Stepping App/apps/web/src/components/video-embed.tsx
zionboggan.com ↗
43 lines · tsx
History for this file →
1
"use client";
2
 
3
import { useState } from "react";
4
 
5
export function VideoEmbed({ id, title }: { id: string; title: string }) {
6
  const [play, setPlay] = useState(false);
7
 
8
  if (play) {
9
    return (
10
      <div className="aspect-video w-full overflow-hidden border border-[var(--line)]">
11
        <iframe
12
          src={`https://www.youtube-nocookie.com/embed/${id}?autoplay=1`}
13
          title={title}
14
          allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
15
          allowFullScreen
16
          className="h-full w-full"
17
        />
18
      </div>
19
    );
20
  }
21
 
22
  return (
23
    <button
24
      type="button"
25
      onClick={() => setPlay(true)}
26
      aria-label={`Play ${title}`}
27
      className="group relative block aspect-video w-full overflow-hidden border border-[var(--line)]"
28
    >
29
      <img
30
        src={`https://i.ytimg.com/vi/${id}/hqdefault.jpg`}
31
        alt=""
32
        className="h-full w-full object-cover opacity-70 transition duration-300 group-hover:opacity-100"
33
      />
34
      <span className="absolute inset-0 grid place-items-center">
35
        <span className="flex h-16 w-16 items-center justify-center rounded-full bg-gold text-stage transition group-hover:bg-gold-bright">
36
          <svg width="20" height="22" viewBox="0 0 20 22" fill="currentColor" aria-hidden="true">
37
            <path d="M0 0l20 11L0 22z" />
38
          </svg>
39
        </span>
40
      </span>
41
    </button>
42
  );
43
}