|
2 | 2 | import { ArrowLeft, Eye, Github, Twitter, Linkedin } from "lucide-react";
|
3 | 3 | import Link from "next/link";
|
4 | 4 | import React, { useEffect, useRef, useState } from "react";
|
| 5 | +import Image from "next/image"; |
5 | 6 |
|
6 | 7 | type Props = {
|
7 |
| - project: { |
8 |
| - url?: string; |
9 |
| - title: string; |
10 |
| - description: string; |
11 |
| - repository?: string; |
12 |
| - }; |
| 8 | + project: { |
| 9 | + url?: string; |
| 10 | + title: string; |
| 11 | + description: string; |
| 12 | + repository?: string; |
| 13 | + media?: string; |
| 14 | + }; |
13 | 15 | };
|
14 |
| -export const Header: React.FC<Props> = ({ project}) => { |
15 |
| - const ref = useRef<HTMLElement>(null); |
16 |
| - const [isIntersecting, setIntersecting] = useState(true); |
| 16 | +export const Header: React.FC<Props> = ({ project }) => { |
| 17 | + const ref = useRef<HTMLElement>(null); |
| 18 | + const [isIntersecting, setIntersecting] = useState(true); |
17 | 19 |
|
18 |
| - const links: { label: string; href: string }[] = []; |
19 |
| - if (project.repository) { |
20 |
| - links.push({ |
21 |
| - label: "GitHub", |
22 |
| - href: `https://github.com/${project.repository}`, |
23 |
| - }); |
24 |
| - } |
25 |
| - if (project.url) { |
26 |
| - links.push({ |
27 |
| - label: "Website", |
28 |
| - href: project.url, |
29 |
| - }); |
30 |
| - } |
31 |
| - useEffect(() => { |
32 |
| - if (!ref.current) return; |
33 |
| - const observer = new IntersectionObserver(([entry]) => |
34 |
| - setIntersecting(entry.isIntersecting), |
35 |
| - ); |
| 20 | + const links: { label: string; href: string }[] = []; |
| 21 | + if (project.repository) { |
| 22 | + links.push({ |
| 23 | + label: "GitHub", |
| 24 | + href: `https://github.com/${project.repository}`, |
| 25 | + }); |
| 26 | + } |
| 27 | + if (project.url) { |
| 28 | + links.push({ |
| 29 | + label: "Website", |
| 30 | + href: project.url, |
| 31 | + }); |
| 32 | + } |
| 33 | + useEffect(() => { |
| 34 | + if (!ref.current) return; |
| 35 | + const observer = new IntersectionObserver(([entry]) => |
| 36 | + setIntersecting(entry.isIntersecting) |
| 37 | + ); |
36 | 38 |
|
37 |
| - observer.observe(ref.current); |
38 |
| - return () => observer.disconnect(); |
39 |
| - }, []); |
| 39 | + observer.observe(ref.current); |
| 40 | + return () => observer.disconnect(); |
| 41 | + }, []); |
40 | 42 |
|
41 |
| - return ( |
42 |
| - <header |
43 |
| - ref={ref} |
44 |
| - className="relative isolate overflow-hidden bg-gradient-to-tl from-black via-zinc-900 to-black" |
45 |
| - > |
46 |
| - <div |
47 |
| - className={`fixed inset-x-0 top-0 z-50 backdrop-blur lg:backdrop-blur-none duration-200 border-b lg:bg-transparent ${ |
48 |
| - isIntersecting |
49 |
| - ? "bg-zinc-900/0 border-transparent" |
50 |
| - : "bg-white/10 border-zinc-200 lg:border-transparent" |
51 |
| - }`} |
52 |
| - > |
53 |
| - <div className="container flex flex-row-reverse items-center justify-between p-6 mx-auto"> |
54 |
| - <div className="flex justify-between gap-8"> |
55 |
| - <span |
56 |
| - title="View counter for this page" |
57 |
| - className={`duration-200 hover:font-medium flex items-center gap-1 ${ |
58 |
| - isIntersecting |
59 |
| - ? " text-zinc-400 hover:text-zinc-100" |
60 |
| - : "text-zinc-600 hover:text-zinc-900" |
61 |
| - } `} |
62 |
| - > |
63 |
| - </span> |
64 |
| - <Link target="_blank" href="https://www.linkedin.com/in/thomas-o-brien-47078b165/?originalSubdomain=au"> |
65 |
| - <Linkedin |
66 |
| - className={`w-6 h-6 duration-200 hover:font-medium ${ |
67 |
| - isIntersecting |
68 |
| - ? " text-zinc-400 hover:text-zinc-100" |
69 |
| - : "text-zinc-600 hover:text-zinc-900" |
70 |
| - } `} |
71 |
| - /> |
72 |
| - </Link> |
73 |
| - <Link target="_blank" href="https://github.com/Tom0Brien"> |
74 |
| - <Github |
75 |
| - className={`w-6 h-6 duration-200 hover:font-medium ${ |
76 |
| - isIntersecting |
77 |
| - ? " text-zinc-400 hover:text-zinc-100" |
78 |
| - : "text-zinc-600 hover:text-zinc-900" |
79 |
| - } `} |
80 |
| - /> |
81 |
| - </Link> |
82 |
| - </div> |
| 43 | + return ( |
| 44 | + <header |
| 45 | + ref={ref} |
| 46 | + className="relative isolate overflow-hidden bg-gradient-to-tl from-black via-zinc-900 to-black" |
| 47 | + > |
| 48 | + <div |
| 49 | + className={`fixed inset-x-0 top-0 z-50 backdrop-blur lg:backdrop-blur-none duration-200 border-b lg:bg-transparent ${ |
| 50 | + isIntersecting |
| 51 | + ? "bg-zinc-900/0 border-transparent" |
| 52 | + : "bg-white/10 border-zinc-200 lg:border-transparent" |
| 53 | + }`} |
| 54 | + > |
| 55 | + <div className="container flex flex-row-reverse items-center justify-between p-6 mx-auto"> |
| 56 | + <div className="flex justify-between gap-8"> |
| 57 | + <span |
| 58 | + title="View counter for this page" |
| 59 | + className={`duration-200 hover:font-medium flex items-center gap-1 ${ |
| 60 | + isIntersecting |
| 61 | + ? " text-zinc-400 hover:text-zinc-100" |
| 62 | + : "text-zinc-600 hover:text-zinc-900" |
| 63 | + } `} |
| 64 | + ></span> |
| 65 | + <Link |
| 66 | + target="_blank" |
| 67 | + href="https://www.linkedin.com/in/thomas-o-brien-47078b165/?originalSubdomain=au" |
| 68 | + > |
| 69 | + <Linkedin |
| 70 | + className={`w-6 h-6 duration-200 hover:font-medium ${ |
| 71 | + isIntersecting |
| 72 | + ? " text-zinc-400 hover:text-zinc-100" |
| 73 | + : "text-zinc-600 hover:text-zinc-900" |
| 74 | + } `} |
| 75 | + /> |
| 76 | + </Link> |
| 77 | + <Link target="_blank" href="https://github.com/Tom0Brien"> |
| 78 | + <Github |
| 79 | + className={`w-6 h-6 duration-200 hover:font-medium ${ |
| 80 | + isIntersecting |
| 81 | + ? " text-zinc-400 hover:text-zinc-100" |
| 82 | + : "text-zinc-600 hover:text-zinc-900" |
| 83 | + } `} |
| 84 | + /> |
| 85 | + </Link> |
| 86 | + </div> |
83 | 87 |
|
84 |
| - <Link |
85 |
| - href="/projects" |
86 |
| - className={`duration-200 hover:font-medium ${ |
87 |
| - isIntersecting |
88 |
| - ? " text-zinc-400 hover:text-zinc-100" |
89 |
| - : "text-zinc-600 hover:text-zinc-900" |
90 |
| - } `} |
91 |
| - > |
92 |
| - <ArrowLeft className="w-6 h-6 " /> |
93 |
| - </Link> |
94 |
| - </div> |
95 |
| - </div> |
96 |
| - <div className="container mx-auto relative isolate overflow-hidden py-24 sm:py-32"> |
97 |
| - <div className="mx-auto max-w-7xl px-6 lg:px-8 text-center flex flex-col items-center"> |
98 |
| - <div className="mx-auto max-w-2xl lg:mx-0"> |
99 |
| - <h1 className="text-4xl font-bold tracking-tight text-white sm:text-6xl font-display"> |
100 |
| - {project.title} |
101 |
| - </h1> |
102 |
| - <p className="mt-6 text-lg leading-8 text-zinc-300"> |
103 |
| - {project.description} |
104 |
| - </p> |
105 |
| - </div> |
| 88 | + <Link |
| 89 | + href="/projects" |
| 90 | + className={`duration-200 hover:font-medium ${ |
| 91 | + isIntersecting |
| 92 | + ? " text-zinc-400 hover:text-zinc-100" |
| 93 | + : "text-zinc-600 hover:text-zinc-900" |
| 94 | + } `} |
| 95 | + > |
| 96 | + <ArrowLeft className="w-6 h-6 " /> |
| 97 | + </Link> |
| 98 | + </div> |
| 99 | + </div> |
| 100 | + <div className="container mx-auto relative isolate overflow-hidden py-24 sm:py-32"> |
| 101 | + <div className="mx-auto max-w-7xl px-6 lg:px-8 text-center flex flex-col items-center"> |
| 102 | + <div className="mx-auto max-w-2xl lg:mx-0"> |
| 103 | + <h1 className="text-4xl font-bold tracking-tight text-white sm:text-6xl font-display"> |
| 104 | + {project.title} |
| 105 | + </h1> |
| 106 | + <p className="mt-6 text-lg leading-8 text-zinc-300"> |
| 107 | + {project.description} |
| 108 | + </p> |
| 109 | + </div> |
106 | 110 |
|
107 |
| - <div className="mx-auto mt-10 max-w-2xl lg:mx-0 lg:max-w-none"> |
108 |
| - <div className="grid grid-cols-1 gap-y-6 gap-x-8 text-base font-semibold leading-7 text-white sm:grid-cols-2 md:flex lg:gap-x-10"> |
109 |
| - {links.map((link) => ( |
110 |
| - <Link target="_blank" key={link.label} href={link.href}> |
111 |
| - {link.label} <span aria-hidden="true">→</span> |
112 |
| - </Link> |
113 |
| - ))} |
114 |
| - </div> |
115 |
| - </div> |
116 |
| - </div> |
117 |
| - </div> |
118 |
| - </header> |
119 |
| - ); |
| 111 | + {project.media && ( |
| 112 | + <div className="relative w-full h-96 mt-8 overflow-hidden rounded-lg"> |
| 113 | + {project.media.endsWith(".mp4") ? ( |
| 114 | + <video |
| 115 | + autoPlay |
| 116 | + loop |
| 117 | + muted |
| 118 | + playsInline |
| 119 | + className="object-cover w-full h-full" |
| 120 | + > |
| 121 | + <source src={project.media} type="video/mp4" /> |
| 122 | + </video> |
| 123 | + ) : ( |
| 124 | + <Image |
| 125 | + src={project.media} |
| 126 | + alt={project.title} |
| 127 | + fill |
| 128 | + className="object-cover" |
| 129 | + /> |
| 130 | + )} |
| 131 | + </div> |
| 132 | + )} |
| 133 | + |
| 134 | + <div className="mx-auto mt-10 max-w-2xl lg:mx-0 lg:max-w-none"> |
| 135 | + <div className="grid grid-cols-1 gap-y-6 gap-x-8 text-base font-semibold leading-7 text-white sm:grid-cols-2 md:flex lg:gap-x-10"> |
| 136 | + {links.map((link) => ( |
| 137 | + <Link target="_blank" key={link.label} href={link.href}> |
| 138 | + {link.label} <span aria-hidden="true">→</span> |
| 139 | + </Link> |
| 140 | + ))} |
| 141 | + </div> |
| 142 | + </div> |
| 143 | + </div> |
| 144 | + </div> |
| 145 | + </header> |
| 146 | + ); |
120 | 147 | };
|
0 commit comments