Skip to content

Commit 856dc81

Browse files
committed
Improve the backdrop layer
1 parent 89e60ff commit 856dc81

File tree

1 file changed

+42
-9
lines changed

1 file changed

+42
-9
lines changed

src/app/conf/2025/components/navbar.tsx

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,33 @@ export function Navbar({ links, year }: NavbarProps): ReactElement {
3232
setMobileDrawerOpen(false)
3333
}, [pathname])
3434

35+
const navbarHeight = "70px"
36+
3537
return (
3638
<>
3739
<div
3840
/* pink background "prelude" */ className={clsx(
39-
"top-0 h-[70px] w-full scale-y-105 bg-pri-base dark:bg-pri-darker",
41+
"top-0 w-full scale-y-105 bg-pri-base dark:bg-pri-darker",
4042
mobileDrawerOpen ? "static" : "absolute",
4143
)}
44+
style={{
45+
height: navbarHeight,
46+
}}
4247
/>
4348
<header
4449
// todo: not white, but ALWAYS contrasting color, either white or black depending on background
4550
className={clsx(
46-
"top-0 z-10 w-full border-b border-white/70 bg-white/20 font-mono text-white antialiased",
51+
"top-0 z-10 w-full bg-white/20 font-mono text-white antialiased",
4752
mobileDrawerOpen ? "fixed" : "sticky",
4853
)}
54+
style={
55+
{
56+
"--navbar-h": navbarHeight,
57+
} as {}
58+
}
4959
>
50-
<div
51-
/* navbar backdrop */ className="absolute inset-0 -z-10 backdrop-blur-[6.4px]"
52-
/>
53-
{/* todo: better backdrop */}
54-
<div className="container flex h-[70px] items-center justify-between gap-5">
60+
<BackdropBlur />
61+
<div className="container flex h-[var(--navbar-h)] items-center justify-between gap-5">
5562
<div className="flex items-center gap-2 text-xl/none uppercase">
5663
<NextLink href="/">
5764
<GraphQLLogo className="h-6" />
@@ -62,13 +69,13 @@ export function Navbar({ links, year }: NavbarProps): ReactElement {
6269
{mobileDrawerOpen && (
6370
<div
6471
onClick={handleDrawerClick}
65-
className="fixed inset-0 top-[71px] z-10 bg-neu-0/40 backdrop-blur-[6.4px]"
72+
className="fixed inset-0 top-[calc(var(--navbar-h)+1px)] z-10 bg-neu-0/40 backdrop-blur-[6.4px]"
6673
/>
6774
)}
6875

6976
<nav
7077
className={clsx(
71-
"inset-0 z-20 flex gap-7 typography-menu max-lg:fixed max-lg:mt-[71px] max-lg:flex-col max-md:min-w-[50%] sm:max-lg:p-4 lg:items-end",
78+
"inset-0 z-20 flex gap-7 typography-menu max-lg:fixed max-lg:mt-[calc(var(--navbar-h)+1px)] max-lg:flex-col max-md:min-w-[50%] sm:max-lg:p-4 lg:items-end",
7279
mobileDrawerOpen
7380
? "translate-x-0 text-neu-900"
7481
: "text-white max-lg:translate-x-full",
@@ -132,3 +139,29 @@ function GraphQLLogo(props: React.SVGProps<SVGSVGElement>) {
132139
</svg>
133140
)
134141
}
142+
143+
function BackdropBlur() {
144+
const mask = "linear-gradient(to bottom, #000 0% 50%, transparent 50% 100%)"
145+
const edgeMask =
146+
"linear-gradient(to bottom, black 0, black 1.1px, transparent 1.1px)"
147+
return (
148+
<>
149+
<div
150+
// note: we can't use the background trick to reduce flickering, because we have many section
151+
// background colors and big images, so we'd have to change the --bg var with javascript
152+
className="pointer-events-none absolute inset-0 -z-10 h-[200%] backdrop-blur-[6.4px]"
153+
style={{
154+
maskImage: mask,
155+
WebkitMaskImage: mask,
156+
}}
157+
/>
158+
<div
159+
className="pointer-events-none absolute inset-0 -z-10 h-full translate-y-full bg-white/50 backdrop-blur-sm backdrop-brightness-200 backdrop-grayscale-[50%]"
160+
style={{
161+
maskImage: edgeMask,
162+
WebkitMaskImage: edgeMask,
163+
}}
164+
/>
165+
</>
166+
)
167+
}

0 commit comments

Comments
 (0)