-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
68cff23
commit d2a62d3
Showing
12 changed files
with
460 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { cn } from "@/lib/utils" | ||
import { PropsWithChildren } from "react" | ||
|
||
import Icon from "./Icon" | ||
|
||
type Props = PropsWithChildren & { | ||
href: string; | ||
className?: string; | ||
}; | ||
|
||
export default function ExternalLink(props: Props) { | ||
const { href, children, className = "" } = props | ||
return ( | ||
<a | ||
className={cn("inline-flex items-center gap-1 text-inherit", className)} | ||
href={href} | ||
> | ||
<span className="underline">{children}</span> | ||
|
||
<Icon.externalLink className="inline-block" size="16" /> | ||
</a> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
"use client" | ||
|
||
import { useApi } from "@/components/providers/DataProvider" | ||
import { | ||
Carousel, | ||
CarouselContent, | ||
CarouselItem, | ||
} from "@/components/ui/carousel" | ||
import { type CarouselApi } from "@/components/ui/carousel" | ||
import { ContactLink } from "@/lib/types" | ||
import { useEffect, useRef, useState } from "react" | ||
|
||
import { Button } from "../ui/button" | ||
import Icon from "./Icon" | ||
import MainNav from "./MainNav" | ||
import WorkAvailability from "./WorkAvailability" | ||
|
||
export default function HeaderAd() { | ||
const [api, setApi] = useState<CarouselApi | null>(null) | ||
const { data } = useApi() | ||
const links: ContactLink[] = Object.values(data.profile.attributes.links) | ||
|
||
const intervalRef = useRef<number | null>(null) | ||
const [isPaused, setIsPaused] = useState(false) | ||
|
||
useEffect(() => { | ||
const updateAutoplay = (currentSlide: number) => { | ||
if (intervalRef.current !== null) { | ||
clearInterval(intervalRef.current) | ||
} | ||
|
||
const delay = currentSlide === 0 ? 6000 : 2000 | ||
|
||
intervalRef.current = window.setInterval(() => { | ||
if (api && !isPaused) { | ||
api.scrollNext() | ||
} | ||
}, delay) | ||
} | ||
if (!api) { | ||
return | ||
} | ||
|
||
const handleSelect = () => { | ||
const currentSlide = api.selectedScrollSnap() | ||
updateAutoplay(currentSlide) | ||
} | ||
|
||
api.on("select", handleSelect) | ||
updateAutoplay(api.selectedScrollSnap()) | ||
|
||
return () => { | ||
if (intervalRef.current !== null) { | ||
clearInterval(intervalRef.current) | ||
} | ||
api.off("select", handleSelect) | ||
} | ||
}, [api, isPaused]) | ||
|
||
const handleMouseEnter = () => { | ||
if (api?.selectedScrollSnap() === 0) { | ||
setIsPaused(true) | ||
} | ||
} | ||
|
||
const handleMouseLeave = () => { | ||
if (api?.selectedScrollSnap() === 0) { | ||
setIsPaused(false) | ||
} | ||
} | ||
|
||
return ( | ||
<Carousel | ||
setApi={setApi} | ||
opts={{ | ||
loop: true, | ||
align: "end", | ||
}} | ||
orientation="vertical" | ||
className="w-full max-w-xs" | ||
onMouseEnter={handleMouseEnter} | ||
onMouseLeave={handleMouseLeave} | ||
> | ||
<CarouselContent className="h-12"> | ||
<CarouselItem className="flex justify-end pt-3"> | ||
<MainNav links={links} className="mr-auto"> | ||
<Button | ||
variant="outline" | ||
size="sm" | ||
className="ml-auto mt-1 flex items-center gap-2" | ||
> | ||
<Icon.ellipsis /> | ||
<div>Menu</div> | ||
</Button> | ||
</MainNav> | ||
</CarouselItem> | ||
<CarouselItem> | ||
<WorkAvailability /> | ||
</CarouselItem> | ||
</CarouselContent> | ||
</Carousel> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.