|
1 | | -import { ArrowRight, Dna } from "lucide-react"; |
| 1 | +import { useEffect, useLayoutEffect, useState } from "react"; |
| 2 | +import { ArrowRight, Dna, X } from "lucide-react"; |
2 | 3 | import { Link } from "react-router-dom"; |
3 | 4 |
|
4 | | -const RecruitmentBanner = () => ( |
5 | | - <aside |
6 | | - aria-label="Fall 2026 recruitment announcement" |
7 | | - className="relative isolate overflow-hidden border-b border-gold/30 bg-gold/[0.12] dark:bg-gold/[0.08]" |
8 | | - > |
9 | | - <div |
10 | | - className="pointer-events-none absolute inset-0 -z-10 opacity-45" |
11 | | - aria-hidden="true" |
12 | | - style={{ |
13 | | - backgroundImage: |
14 | | - "linear-gradient(90deg, transparent, hsl(var(--gold) / 0.16), transparent)", |
15 | | - }} |
16 | | - /> |
17 | | - |
18 | | - <div className="mx-auto flex min-h-12 max-w-6xl flex-col items-start justify-between gap-2 px-4 py-2.5 sm:flex-row sm:items-center sm:gap-6 sm:px-6 lg:px-8"> |
19 | | - <div className="flex items-start gap-2.5 sm:items-center"> |
20 | | - <Dna |
21 | | - className="mt-0.5 h-4 w-4 shrink-0 text-label sm:mt-0" |
22 | | - aria-hidden="true" |
23 | | - /> |
24 | | - <p className="text-[13px] leading-5 text-foreground"> |
25 | | - <strong className="font-bold text-heading"> |
26 | | - We’re recruiting soon for Fall 2026. |
27 | | - </strong>{" "} |
28 | | - Sign up for updates and stay tuned. |
29 | | - </p> |
| 5 | +const dismissalKey = "compbio-fall-2026-recruitment-dismissed"; |
| 6 | +const useBrowserLayoutEffect = |
| 7 | + typeof window === "undefined" ? useEffect : useLayoutEffect; |
| 8 | + |
| 9 | +const RecruitmentBanner = () => { |
| 10 | + const [isDismissed, setIsDismissed] = useState(false); |
| 11 | + |
| 12 | + useBrowserLayoutEffect(() => { |
| 13 | + try { |
| 14 | + setIsDismissed(window.sessionStorage.getItem(dismissalKey) === "true"); |
| 15 | + } catch { |
| 16 | + // Keep the banner available when browser storage is disabled. |
| 17 | + } |
| 18 | + }, []); |
| 19 | + |
| 20 | + const dismissBanner = () => { |
| 21 | + setIsDismissed(true); |
| 22 | + |
| 23 | + try { |
| 24 | + window.sessionStorage.setItem(dismissalKey, "true"); |
| 25 | + } catch { |
| 26 | + // The in-memory dismissal still applies for this page view. |
| 27 | + } |
| 28 | + }; |
| 29 | + |
| 30 | + if (isDismissed) return null; |
| 31 | + |
| 32 | + return ( |
| 33 | + <aside |
| 34 | + aria-label="Fall 2026 recruitment announcement" |
| 35 | + className="relative isolate overflow-hidden border-b border-border bg-card/90" |
| 36 | + > |
| 37 | + <div |
| 38 | + className="pointer-events-none absolute inset-0 -z-10" |
| 39 | + aria-hidden="true" |
| 40 | + style={{ |
| 41 | + backgroundImage: |
| 42 | + "linear-gradient(90deg, hsl(var(--background) / 0.72), hsl(var(--gold) / 0.07) 36%, hsl(var(--gold) / 0.12) 50%, hsl(var(--gold) / 0.07) 64%, hsl(var(--background) / 0.72))", |
| 43 | + }} |
| 44 | + /> |
| 45 | + |
| 46 | + <div className="mx-auto flex min-h-12 max-w-6xl items-center justify-center px-14 py-2.5 text-center sm:px-16"> |
| 47 | + <div className="flex flex-col items-center justify-center gap-1.5 sm:flex-row sm:gap-3"> |
| 48 | + <div className="flex items-center justify-center gap-2"> |
| 49 | + <Dna className="h-4 w-4 shrink-0 text-label" aria-hidden="true" /> |
| 50 | + <p className="text-[13px] leading-5 text-foreground"> |
| 51 | + <strong className="font-bold text-heading"> |
| 52 | + We’re recruiting soon for Fall 2026. |
| 53 | + </strong>{" "} |
| 54 | + Sign up for updates and stay tuned. |
| 55 | + </p> |
| 56 | + </div> |
| 57 | + |
| 58 | + <Link |
| 59 | + to="/signup/" |
| 60 | + className="group inline-flex min-h-8 shrink-0 items-center gap-1.5 border-b border-heading/40 text-xs font-bold text-heading transition-colors hover:border-heading focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background" |
| 61 | + > |
| 62 | + sign up |
| 63 | + <ArrowRight |
| 64 | + className="h-3.5 w-3.5 transition-transform group-hover:translate-x-0.5" |
| 65 | + aria-hidden="true" |
| 66 | + /> |
| 67 | + </Link> |
| 68 | + </div> |
30 | 69 | </div> |
31 | 70 |
|
32 | | - <Link |
33 | | - to="/signup/" |
34 | | - className="group ml-6 inline-flex min-h-8 shrink-0 items-center gap-1.5 border-b border-heading/45 text-xs font-bold text-heading transition-colors hover:border-heading hover:text-heading focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background sm:ml-0" |
| 71 | + <button |
| 72 | + type="button" |
| 73 | + onClick={dismissBanner} |
| 74 | + aria-label="Dismiss Fall 2026 recruitment announcement" |
| 75 | + className="absolute right-1 top-1/2 inline-flex h-11 w-11 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground transition-colors hover:bg-background/70 hover:text-heading focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-card sm:right-3" |
35 | 76 | > |
36 | | - sign up |
37 | | - <ArrowRight |
38 | | - className="h-3.5 w-3.5 transition-transform group-hover:translate-x-0.5" |
39 | | - aria-hidden="true" |
40 | | - /> |
41 | | - </Link> |
42 | | - </div> |
43 | | - </aside> |
44 | | -); |
| 77 | + <X className="h-4 w-4" aria-hidden="true" /> |
| 78 | + </button> |
| 79 | + </aside> |
| 80 | + ); |
| 81 | +}; |
45 | 82 |
|
46 | 83 | export default RecruitmentBanner; |
0 commit comments