feat: new nav bar

This commit is contained in:
tresabhi committed 2025-04-03 12:15:08 -05:00
1 parent de471400ad
commit 21a37ec6cc
5 files changed
+97 -151

No files matched your search

@@ -83,7 +83,7 @@ function Content() {
const { locale, strings } = useLocale(); const { locale, strings } = useLocale();
return ( return (
<Flex direction="column" pt="4"> <Flex direction="column" pt="4" pb="6">
<Heading align="center" size="5"> <Heading align="center" size="5">
{strings.website.home.hot_tanks.title} {strings.website.home.hot_tanks.title}
</Heading> </Heading>
+92 -135
View File
@@ -21,6 +21,7 @@ import { resolveBranchName } from '../core/blitzkit/branches';
import { homeTool, TOOLS } from '../constants/tools'; import { homeTool, TOOLS } from '../constants/tools';
import { LinkI18n } from './LinkI18n'; import { LinkI18n } from './LinkI18n';
import { getStrings } from '../core/i18n/getStrings'; import { getStrings } from '../core/i18n/getStrings';
import { Var } from '../core/radix/var';
const toolsFiltered = TOOLS.filter((tool) => !('href' in tool)); const toolsFiltered = TOOLS.filter((tool) => !('href' in tool));
const tools = [homeTool, ...toolsFiltered]; const tools = [homeTool, ...toolsFiltered];
@@ -31,93 +32,63 @@ const strings = getStrings(locale);
--- ---
<style> <style>
.navbar { .navbar[data-expanded='false'] *[data-expanded] {
height: var(--navbar-height);
top: 0;
z-index: 1;
position: sticky;
}
.expander {
--navbar-height: 48px;
/* overflow: hidden; */
transition-duration: 250ms;
width: 100%;
backdrop-filter: blur(4rem) brightness(0.75);
-webkit-backdrop-filter: blur(4rem) brightness(0.75);
}
.expander[data-expanded='false'] {
height: var(--navbar-height);
}
.expander[data-expanded='false'] *[data-expanded] {
display: none; display: none;
} }
.expander[data-expanded='true'] { .navbar[data-expanded='true'] *[data-closed] {
height: 100vh;
}
.expander[data-expanded='true'] *[data-closed] {
display: none; display: none;
} }
.expander div[data-radix-scroll-area-viewport] {
overflow-y: scroll !important;
overscroll-behavior: contain;
}
.hamburger {
display: inline-flex;
}
.tools {
display: none;
}
@media (min-width: 768px) {
.hamburger {
display: none;
}
.tools {
display: flex;
}
.expander {
max-height: var(--navbar-height) !important;
}
}
</style> </style>
<script> <script>
const expander = document.querySelector<HTMLDivElement>('.expander'); const navbar = document.querySelector<HTMLDivElement>('.navbar');
const hamburger = document.querySelector<HTMLButtonElement>('.hamburger'); const hamburger = document.querySelector<HTMLButtonElement>('.hamburger');
expander?.addEventListener('click', () => { navbar?.addEventListener('click', () => {
expander.dataset.expanded = 'false'; navbar.dataset.expanded = 'false';
}); });
hamburger?.addEventListener('click', (event) => { hamburger?.addEventListener('click', (event) => {
if (!expander) return; if (!navbar) return;
event.stopPropagation(); event.stopPropagation();
expander.dataset.expanded = `${expander.dataset.expanded === 'false'}`; navbar.dataset.expanded = `${navbar.dataset.expanded === 'false'}`;
}); });
</script> </script>
<Flex className="navbar"> <Box height={{ initial: '3.5rem', sm: '3rem' }} />
<Flex className="expander" data-expanded="false" direction="column" gap="2">
<Flex justify="center"> <Flex
<Flex flexGrow="1" maxWidth="1024px" p="3" align="center"> direction="column"
align="center"
data-expanded="false"
className="navbar"
width="100%"
top="0"
position="fixed"
height="100%"
style={{
zIndex: 1,
}}
>
<Flex
width="100%"
maxWidth="80rem"
p={{ initial: '4', sm: '3' }}
gap="4"
direction="column"
style={{
backgroundColor: Var('gray-1'),
}}
>
<Flex align="center">
<LinkI18n <LinkI18n
{locale} {locale}
color="gray" color="gray"
highContrast highContrast
href="/" href="/"
underline="hover" underline="hover"
weight="bold" weight="medium"
> >
<Flex align="center" gap="1"> <Flex align="center" gap="1">
BlitzKit BlitzKit
@@ -133,7 +104,13 @@ const strings = getStrings(locale);
<Box flexGrow="1" /> <Box flexGrow="1" />
<Flex align="center" gap="2" justify="center" className="tools"> <Flex
align="center"
gap={{ initial: '4', md: '6' }}
display={{ initial: 'none', sm: 'flex' }}
justify="center"
className="tools"
>
{ {
toolsFiltered.map((tool, index) => { toolsFiltered.map((tool, index) => {
const unavailableOnBranch = tool.branches?.every( const unavailableOnBranch = tool.branches?.every(
@@ -150,19 +127,17 @@ const strings = getStrings(locale);
if (unavailableOnBranch) return null; if (unavailableOnBranch) return null;
return ( return (
<Fragment key={tool.id}>
{index > 0 && <Separator orientation="vertical" size="1" />}
<LinkI18n <LinkI18n
{locale} {locale}
weight={selected ? 'medium' : 'regular'}
color="gray" color="gray"
highContrast={selected} highContrast={selected}
size="2" size="2"
href={`/tools/${tool.id}`} href={`/tools/${tool.id}`}
underline={selected ? 'always' : 'hover'} underline="hover"
> >
{toolStrings.name} {toolStrings.name}
</LinkI18n> </LinkI18n>
</Fragment>
); );
}) })
} }
@@ -170,7 +145,7 @@ const strings = getStrings(locale);
<Box flexGrow="1" /> <Box flexGrow="1" />
<Flex align="center" gap="3"> <Flex align="center" gap="4">
<Link <Link
style={{ display: 'flex', alignContent: 'center' }} style={{ display: 'flex', alignContent: 'center' }}
color="gray" color="gray"
@@ -178,7 +153,7 @@ const strings = getStrings(locale);
underline="none" underline="none"
target="_blank" target="_blank"
> >
<DiscordLogoIcon /> <DiscordLogoIcon width="1em" height="1em" />
</Link> </Link>
<LinkI18n <LinkI18n
@@ -188,11 +163,12 @@ const strings = getStrings(locale);
href="/settings" href="/settings"
underline="none" underline="none"
> >
<GearIcon /> <GearIcon width="1em" height="1em" />
</LinkI18n> </LinkI18n>
<!-- <NavbarAccount client:idle /> --> <!-- <NavbarAccount client:idle /> -->
<Flex align="center" display={{ initial: 'flex', sm: 'none' }}>
<IconButton variant="ghost" color="gray" className="hamburger"> <IconButton variant="ghost" color="gray" className="hamburger">
<Cross1Icon data-expanded /> <Cross1Icon data-expanded />
<HamburgerMenuIcon data-closed /> <HamburgerMenuIcon data-closed />
@@ -201,87 +177,68 @@ const strings = getStrings(locale);
</Flex> </Flex>
</Flex> </Flex>
<ScrollArea scrollbars="vertical" style={{ height: '100%', width: '100%' }}> <Flex
<Grid direction="column"
columns="repeat(auto-fill, minmax(12rem, 1fr))" data-expanded
flow="dense" gap="3"
gap="2" display={{ initial: 'flex', sm: 'none' }}
width="100%"
p="3"
pt="0"
> >
{ {
tools.map((tool) => { toolsFiltered.map((tool) => {
const unavailableOnBranch = tool.branches?.every( const unavailableOnBranch = tool.branches?.every(
(branch) => (branch) =>
branch !== assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH), branch !== assertSecret(import.meta.env.PUBLIC_ASSET_BRANCH),
); );
const toolStrings =
strings.website.tools[
(tool.stringsId ??
tool.id) as keyof typeof strings.website.tools
];
if (unavailableOnBranch) return null; if (unavailableOnBranch) return null;
const toolStrings =
strings.website.tools[
(tool.stringsId ?? tool.id) as keyof typeof strings.website.tools
];
return ( return (
<Flex <Link
key={tool.id} color="gray"
style={{ highContrast
position: 'relative', style={{ display: 'contents' }}
borderRadius: 'var(--radius-2)', href={`/tools/${tool.id}`}
overflow: 'hidden',
backgroundImage: `url(${imgur(tool.image, {
format: 'jpeg',
size: ImgurSize.MediumThumbnail,
})})`,
backgroundSize: 'cover',
backgroundPosition: 'center',
aspectRatio: '2 / 1',
}}
>
<LinkI18n
{locale}
href={tool.id.length === 0 ? '/' : `/tools/${tool.id}`}
style={{
display: 'flex',
width: '100%',
height: '100%',
flexDirection: 'column',
textDecoration: 'none',
color: 'inherit',
}}
> >
<Box <Box
flexGrow="1"
style={{ style={{
backgroundImage: `url(${imgur(tool.image, { borderRadius: Var('radius-2'),
format: 'jpeg', backgroundImage: `url(${imgur(tool.image, { format: 'jpeg', size: ImgurSize.LargeThumbnail })})`,
size: ImgurSize.MediumThumbnail, backgroundSize: '200%',
})})`, backgroundPosition: 'right center',
backgroundSize: 'cover', overflow: 'hidden',
backgroundPosition: 'center',
}}
/>
<Flex
p="2"
align="center"
width="100%"
style={{
backgroundColor: 'var(--color-panel-translucent)',
backdropFilter: 'blur(4rem)',
WebkitBackdropFilter: 'blur(4rem)',
}} }}
> >
<Text>{toolStrings.name}</Text> <Flex
</Flex> py="4"
</LinkI18n> justify="end"
flexGrow="1"
style={{
background: `linear-gradient(90deg, transparent, ${Var('gray-1')})`,
}}
>
{toolStrings.name}
</Flex> </Flex>
</Box>
</Link>
); );
}) })
} }
</Grid>
</ScrollArea>
</Flex> </Flex>
</Flex> </Flex>
<Box
data-expanded
flexGrow="1"
width="100%"
style={{
backgroundColor: Var('black-a7'),
backdropFilter: 'blur(0.5rem)',
WebkitBackdropFilter: 'blur(0.5rem)',
}}
/>
</Flex>
@@ -39,7 +39,7 @@ export function PageWrapper({
gap="4" gap="4"
p={padding} p={padding}
width="100%" width="100%"
maxWidth="50rem" maxWidth="80rem"
style={{ style={{
margin: 'auto', margin: 'auto',
boxSizing: 'border-box', boxSizing: 'border-box',
+2 -13
View File
@@ -9,19 +9,8 @@ export type VarName =
| `radius-${1 | 2 | 3 | 4 | 5 | 6 | 'full'}` | `radius-${1 | 2 | 3 | 4 | 5 | 6 | 'full'}`
| `space-${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}` | `space-${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9}`
| `shadow-${1 | 2 | 3 | 4 | 5 | 6}` | `shadow-${1 | 2 | 3 | 4 | 5 | 6}`
| `${RadixColor | 'accent' | 'gray'}-${ | `${RadixColor | 'accent' | 'gray' | 'black' | 'white'}-${
| 1 | `${'' | 'a'}${1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12}`
| 2
| 3
| 4
| 5
| 6
| 7
| 8
| 9
| 10
| 11
| 12
| 'surface' | 'surface'
| 'indicator' | 'indicator'
| 'track' | 'track'
@@ -90,7 +90,7 @@ export const getStaticPaths = (() => {
} }
<Flex p="4" justify="center" gap="4" mt="3"> <Flex p="4" justify="center" gap="4" mt="3">
<Flex maxWidth="64rem" flexGrow="1" gap="4" direction="column"> <Flex maxWidth="80rem" flexGrow="1" gap="4" direction="column">
<ToolCard tool={tankopediaTool} /> <ToolCard tool={tankopediaTool} />
{ {