mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-25 03:29:51 +01:00
feat: navbar hydration issues
This commit is contained in:
1 parent
dab3393ba2
commit
6e96798d5e
3 files changed
+88
-78
No files matched your search
@@ -1,15 +0,0 @@
|
|||||||
import { styleVariants } from '@vanilla-extract/css';
|
|
||||||
import { theme } from '../stitches.config';
|
|
||||||
|
|
||||||
export const tool = styleVariants({
|
|
||||||
enabled: {
|
|
||||||
boxShadow: `inset 0 -200px 128px -128px ${theme.colors.appBackground1}`,
|
|
||||||
|
|
||||||
':hover': {
|
|
||||||
boxShadow: `inset 0 -160px 128px -128px ${theme.colors.appBackground1}`,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
disabled: {
|
|
||||||
boxShadow: `inset 0 -192px 128px -128px ${theme.colors.appBackground1}`,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -0,0 +1,54 @@
|
|||||||
|
import { style, styleVariants } from '@vanilla-extract/css';
|
||||||
|
|
||||||
|
export const hamburgerButton = style({
|
||||||
|
'@media': {
|
||||||
|
'screen and (min-width: 592px)': {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const navbarBase = style({
|
||||||
|
position: 'fixed',
|
||||||
|
top: 0,
|
||||||
|
left: 0,
|
||||||
|
width: '100%',
|
||||||
|
zIndex: 2,
|
||||||
|
padding: '1rem',
|
||||||
|
backgroundColor: 'var(--color-panel-translucent)',
|
||||||
|
backdropFilter: 'blur(4rem)',
|
||||||
|
WebkitBackdropFilter: 'blur(4rem)',
|
||||||
|
boxSizing: 'border-box',
|
||||||
|
transition: 'max-height 0.2s ease-in-out',
|
||||||
|
overflow: 'hidden',
|
||||||
|
});
|
||||||
|
export const navbar = styleVariants({
|
||||||
|
expanded: [
|
||||||
|
navbarBase,
|
||||||
|
{
|
||||||
|
maxHeight: '100%',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
collapsed: [
|
||||||
|
navbarBase,
|
||||||
|
{
|
||||||
|
maxHeight: 65,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
|
||||||
|
export const toolCard = style({
|
||||||
|
boxShadow: `inset 0 -200px 128px -128px var(--color-overlay)`,
|
||||||
|
|
||||||
|
':hover': {
|
||||||
|
boxShadow: `inset 0 -160px 128px -128px #ffffff00`,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const toolTexts = style({
|
||||||
|
'@media': {
|
||||||
|
'screen and (max-width: 592px)': {
|
||||||
|
display: 'none',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -14,52 +14,33 @@ import {
|
|||||||
Flex,
|
Flex,
|
||||||
Heading,
|
Heading,
|
||||||
IconButton,
|
IconButton,
|
||||||
Link as LinkRadix,
|
Link,
|
||||||
Popover,
|
Popover,
|
||||||
Spinner,
|
Spinner,
|
||||||
Text,
|
Text,
|
||||||
} from '@radix-ui/themes';
|
} from '@radix-ui/themes';
|
||||||
import Link from 'next/link';
|
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { Suspense, useState } from 'react';
|
import { Suspense, useState } from 'react';
|
||||||
import * as styles from '../../app/page.css';
|
|
||||||
import { REGIONS, UNLOCALIZED_REGION_NAMES } from '../../constants/regions';
|
import { REGIONS, UNLOCALIZED_REGION_NAMES } from '../../constants/regions';
|
||||||
import { TOOLS } from '../../constants/tools';
|
import { TOOLS } from '../../constants/tools';
|
||||||
import { authURL } from '../../core/blitz/authURL';
|
import { authURL } from '../../core/blitz/authURL';
|
||||||
import { useWideFormat } from '../../hooks/useWideFormat';
|
|
||||||
import { BlitzkitWide } from '../../icons/BlitzkitWide';
|
import { BlitzkitWide } from '../../icons/BlitzkitWide';
|
||||||
import { PatreonIcon } from '../../icons/Patreon';
|
import { PatreonIcon } from '../../icons/Patreon';
|
||||||
import { theme } from '../../stitches.config';
|
import { theme } from '../../stitches.config';
|
||||||
import { useApp } from '../../stores/app';
|
import { useApp } from '../../stores/app';
|
||||||
import { LoggedIn } from './components/LoggedIn';
|
import { LoggedIn } from './components/LoggedIn';
|
||||||
|
import * as styles from './index.css';
|
||||||
|
|
||||||
export const NAVBAR_HEIGHT = 64;
|
export const NAVBAR_HEIGHT = 64;
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
const wideFormat = useWideFormat(688 - 32 - 64);
|
|
||||||
const [showHamburgerMenu, setShowHamburgerMenu] = useState(false);
|
const [showHamburgerMenu, setShowHamburgerMenu] = useState(false);
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const login = useApp((state) => state.login!);
|
const login = useApp((state) => state.login!);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Box
|
||||||
style={{
|
className={styles.navbar[showHamburgerMenu ? 'expanded' : 'collapsed']}
|
||||||
position: 'fixed',
|
|
||||||
top: 0,
|
|
||||||
left: 0,
|
|
||||||
width: '100%',
|
|
||||||
maxHeight:
|
|
||||||
showHamburgerMenu && !wideFormat ? '100%' : NAVBAR_HEIGHT + 1,
|
|
||||||
zIndex: 2,
|
|
||||||
padding: '1rem',
|
|
||||||
background: theme.colors.appBackground1_alpha,
|
|
||||||
borderBottom: theme.borderStyles.nonInteractive,
|
|
||||||
backdropFilter: 'blur(4rem)',
|
|
||||||
WebkitBackdropFilter: 'blur(4rem)',
|
|
||||||
boxSizing: 'border-box',
|
|
||||||
transition: 'max-height 0.2s ease-in-out',
|
|
||||||
overflow: 'hidden',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<Flex direction="column" align="center" pt="2">
|
<Flex direction="column" align="center" pt="2">
|
||||||
<Flex
|
<Flex
|
||||||
@@ -69,16 +50,15 @@ export default function Navbar() {
|
|||||||
gap="8"
|
gap="8"
|
||||||
>
|
>
|
||||||
<Flex align="center" gap="4">
|
<Flex align="center" gap="4">
|
||||||
{!wideFormat && (
|
<IconButton
|
||||||
<IconButton
|
className={styles.hamburgerButton}
|
||||||
size="4"
|
size="4"
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
color="gray"
|
color="gray"
|
||||||
onClick={() => setShowHamburgerMenu((state) => !state)}
|
onClick={() => setShowHamburgerMenu((state) => !state)}
|
||||||
>
|
>
|
||||||
{showHamburgerMenu ? <Cross1Icon /> : <HamburgerMenuIcon />}
|
{showHamburgerMenu ? <Cross1Icon /> : <HamburgerMenuIcon />}
|
||||||
</IconButton>
|
</IconButton>
|
||||||
)}
|
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
onClick={() => setShowHamburgerMenu(false)}
|
onClick={() => setShowHamburgerMenu(false)}
|
||||||
@@ -94,32 +74,26 @@ export default function Navbar() {
|
|||||||
</Link>
|
</Link>
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
{wideFormat && (
|
<Flex justify="center" gap="4" className={styles.toolTexts}>
|
||||||
<Flex justify="center" gap="4">
|
{TOOLS.filter((tool) => !tool.href).map((tool) => {
|
||||||
{TOOLS.filter((tool) => !tool.href).map((tool) => {
|
const selected = pathname.startsWith(`/tools/${tool.id}`);
|
||||||
const selected = pathname.startsWith(`/tools/${tool.id}`);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LinkRadix
|
<Link
|
||||||
highContrast={selected}
|
highContrast={selected}
|
||||||
color="gray"
|
color="gray"
|
||||||
underline={selected ? 'always' : 'hover'}
|
underline={selected ? 'always' : 'hover'}
|
||||||
href="#"
|
size="2"
|
||||||
size="2"
|
onClick={(event) => event.preventDefault()}
|
||||||
onClick={(event) => event.preventDefault()}
|
style={{ all: 'inherit' }}
|
||||||
>
|
key={tool.id}
|
||||||
<Link
|
href={`/tools/${tool.id}`}
|
||||||
style={{ all: 'inherit' }}
|
>
|
||||||
key={tool.id}
|
{tool.title}
|
||||||
href={`/tools/${tool.id}`}
|
</Link>
|
||||||
>
|
);
|
||||||
{tool.title}
|
})}
|
||||||
</Link>
|
</Flex>
|
||||||
</LinkRadix>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Flex align="center" gap="4">
|
<Flex align="center" gap="4">
|
||||||
<Link
|
<Link
|
||||||
@@ -176,7 +150,6 @@ export default function Navbar() {
|
|||||||
</Popover.Root>
|
</Popover.Root>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* TODO: re-enable in the future */}
|
|
||||||
{!login && false && (
|
{!login && false && (
|
||||||
<Dialog.Root>
|
<Dialog.Root>
|
||||||
<Dialog.Trigger>
|
<Dialog.Trigger>
|
||||||
@@ -193,7 +166,7 @@ export default function Navbar() {
|
|||||||
|
|
||||||
<Flex gap="4" align="center" justify="center" wrap="wrap">
|
<Flex gap="4" align="center" justify="center" wrap="wrap">
|
||||||
{REGIONS.map((region) => (
|
{REGIONS.map((region) => (
|
||||||
<LinkRadix
|
<Link
|
||||||
onClick={() => setShowHamburgerMenu(false)}
|
onClick={() => setShowHamburgerMenu(false)}
|
||||||
key={region}
|
key={region}
|
||||||
href={authURL(
|
href={authURL(
|
||||||
@@ -204,7 +177,7 @@ export default function Navbar() {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{UNLOCALIZED_REGION_NAMES[region]}
|
{UNLOCALIZED_REGION_NAMES[region]}
|
||||||
</LinkRadix>
|
</Link>
|
||||||
))}
|
))}
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
@@ -219,9 +192,7 @@ export default function Navbar() {
|
|||||||
<Link
|
<Link
|
||||||
href={tool.href ?? `/tools/${tool.id}`}
|
href={tool.href ?? `/tools/${tool.id}`}
|
||||||
target={tool.href ? '_blank' : undefined}
|
target={tool.href ? '_blank' : undefined}
|
||||||
className={
|
className={styles.toolCard}
|
||||||
tool.disabled ? styles.tool.disabled : styles.tool.enabled
|
|
||||||
}
|
|
||||||
style={{
|
style={{
|
||||||
backgroundImage: `url(/assets/banners/${tool.id}.webp)`,
|
backgroundImage: `url(/assets/banners/${tool.id}.webp)`,
|
||||||
cursor: tool.disabled ? 'default' : 'pointer',
|
cursor: tool.disabled ? 'default' : 'pointer',
|
||||||
|
|||||||
Reference in new issue
Block a user