mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 12:09:51 +02:00
feat: start of new navbar
This commit is contained in:
1 parent
ca7c01bbc8
commit
4b88a52fcf
5 files changed
+87
-360
No files matched your search
+2
-2
@@ -7,7 +7,7 @@ import { Roboto_Flex } from 'next/font/google';
|
|||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { ReactNode, Suspense } from 'react';
|
import { ReactNode, Suspense } from 'react';
|
||||||
import { Footer } from '../components/Footer';
|
import { Footer } from '../components/Footer';
|
||||||
import Navbar, { NAVBAR_HEIGHT } from '../components/Navbar';
|
import Navbar from '../components/Navbar';
|
||||||
import { Party3 } from '../components/Party3';
|
import { Party3 } from '../components/Party3';
|
||||||
import * as App from '../stores/app';
|
import * as App from '../stores/app';
|
||||||
import { Checks } from './components/Checks';
|
import { Checks } from './components/Checks';
|
||||||
@@ -68,7 +68,7 @@ export default function RootLayout({ children }: RootLayoutProps) {
|
|||||||
direction="column"
|
direction="column"
|
||||||
style={{
|
style={{
|
||||||
minHeight: '100vh',
|
minHeight: '100vh',
|
||||||
paddingTop: isEmbed ? undefined : NAVBAR_HEIGHT,
|
// paddingTop: isEmbed ? undefined : NAVBAR_HEIGHT,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!isEmbed && <Navbar />}
|
{!isEmbed && <Navbar />}
|
||||||
|
|||||||
@@ -1,42 +0,0 @@
|
|||||||
import { MagnifyingGlassIcon } from '@radix-ui/react-icons';
|
|
||||||
import { Card, TextField } from '@radix-ui/themes';
|
|
||||||
import { ComponentProps, useState } from 'react';
|
|
||||||
|
|
||||||
export function EverythingSearch({
|
|
||||||
style,
|
|
||||||
...props
|
|
||||||
}: ComponentProps<typeof TextField.Root>) {
|
|
||||||
const [search, setSearch] = useState('');
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<TextField.Root
|
|
||||||
value={search}
|
|
||||||
placeholder="Search tanks, players, clans..."
|
|
||||||
style={{ position: 'relative', ...style }}
|
|
||||||
onChange={(event) => {
|
|
||||||
setSearch(event.target.value.trim());
|
|
||||||
}}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<TextField.Slot>
|
|
||||||
<MagnifyingGlassIcon />
|
|
||||||
</TextField.Slot>
|
|
||||||
|
|
||||||
{search.length > 0 && (
|
|
||||||
<TextField.Slot>
|
|
||||||
<Card
|
|
||||||
style={{
|
|
||||||
position: 'absolute',
|
|
||||||
top: 'calc(100% + 8px)',
|
|
||||||
left: 0,
|
|
||||||
width: '100%',
|
|
||||||
zIndex: 1,
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</TextField.Slot>
|
|
||||||
)}
|
|
||||||
</TextField.Root>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,56 +1,23 @@
|
|||||||
import { style, styleVariants } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
const MIN_EXPANDED_TOOLS = 752;
|
const MIN_WIDTH = 640 + 64;
|
||||||
|
|
||||||
|
export const hamburger = style({
|
||||||
|
display: 'inline-flex',
|
||||||
|
|
||||||
export const hamburgerButton = style({
|
|
||||||
'@media': {
|
'@media': {
|
||||||
[`screen and (min-width: ${MIN_EXPANDED_TOOLS}px)`]: {
|
[`screen and (min-width: ${MIN_WIDTH}px)`]: {
|
||||||
display: 'none',
|
display: 'none',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const navbarBase = style({
|
export const tools = style({
|
||||||
position: 'fixed',
|
display: 'none',
|
||||||
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': {
|
'@media': {
|
||||||
[`screen and (max-width: ${MIN_EXPANDED_TOOLS}px)`]: {
|
[`screen and (min-width: ${MIN_WIDTH}px)`]: {
|
||||||
display: 'none',
|
display: 'flex',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
+75
-271
@@ -1,311 +1,115 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Cross1Icon,
|
|
||||||
DiscordLogoIcon,
|
DiscordLogoIcon,
|
||||||
GearIcon,
|
GearIcon,
|
||||||
HamburgerMenuIcon,
|
HamburgerMenuIcon,
|
||||||
PersonIcon,
|
PersonIcon,
|
||||||
} from '@radix-ui/react-icons';
|
} from '@radix-ui/react-icons';
|
||||||
import {
|
import { Box, Flex, IconButton, Separator } from '@radix-ui/themes';
|
||||||
Box,
|
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
Flex,
|
|
||||||
IconButton,
|
|
||||||
Inset,
|
|
||||||
Popover,
|
|
||||||
Separator,
|
|
||||||
Text,
|
|
||||||
} from '@radix-ui/themes';
|
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { REGIONS } from '../../constants/regions';
|
|
||||||
import { TOOLS } from '../../constants/tools';
|
import { TOOLS } from '../../constants/tools';
|
||||||
import { WARGAMING_APPLICATION_ID } from '../../constants/wargamingApplicationID';
|
|
||||||
import { imgur, ImgurSize } from '../../core/blitzkit/imgur';
|
|
||||||
import { patreonLoginUrl } from '../../core/blitzkit/patreonLoginUrl';
|
|
||||||
import { PatreonIcon } from '../../icons/Patreon';
|
import { PatreonIcon } from '../../icons/Patreon';
|
||||||
import { WargamingIcon } from '../../icons/Wargaming';
|
|
||||||
import strings from '../../lang/en-US.json';
|
|
||||||
import { theme } from '../../stitches.config';
|
|
||||||
import * as App from '../../stores/app';
|
import * as App from '../../stores/app';
|
||||||
import { Link } from '../Link';
|
import { Link } from '../Link';
|
||||||
import * as styles from './index.css';
|
import * as styles from './index.css';
|
||||||
|
|
||||||
export const NAVBAR_HEIGHT = 64;
|
|
||||||
|
|
||||||
export default function Navbar() {
|
export default function Navbar() {
|
||||||
const [showHamburgerMenu, setShowHamburgerMenu] = useState(false);
|
const [showHamburgerMenu, setShowHamburgerMenu] = useState(false);
|
||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const logins = App.use((state) => state.logins);
|
const logins = App.use((state) => state.logins);
|
||||||
const filteredTools = TOOLS.filter((tool) => !tool.href);
|
|
||||||
const mutateApp = App.useMutation();
|
const mutateApp = App.useMutation();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box
|
<Flex
|
||||||
className={styles.navbar[showHamburgerMenu ? 'expanded' : 'collapsed']}
|
justify="center"
|
||||||
style={{ zIndex: 3 }}
|
position="sticky"
|
||||||
|
top="0"
|
||||||
|
style={{
|
||||||
|
// 1px overlap with content to bleed color
|
||||||
|
marginBottom: -1,
|
||||||
|
backdropFilter: 'blur(4rem) brightness(0.75)',
|
||||||
|
WebkitBackdropFilter: 'blur(4rem) brightness(0.75)',
|
||||||
|
zIndex: 1,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Flex direction="column" align="center">
|
<Flex flexGrow="1" maxWidth="1024px" p="2" align="center">
|
||||||
<Flex
|
<Flex gap="3" align="center">
|
||||||
position="absolute"
|
<IconButton variant="ghost" color="gray" className={styles.hamburger}>
|
||||||
top="34px"
|
<HamburgerMenuIcon />
|
||||||
justify="between"
|
</IconButton>
|
||||||
align="center"
|
|
||||||
style={{
|
|
||||||
maxWidth: 1024,
|
|
||||||
width: '100%',
|
|
||||||
padding: '0 16px',
|
|
||||||
transform: 'translateY(-50%)',
|
|
||||||
}}
|
|
||||||
gap="8"
|
|
||||||
>
|
|
||||||
<Flex align="center" gap="4">
|
|
||||||
<IconButton
|
|
||||||
className={styles.hamburgerButton}
|
|
||||||
size="4"
|
|
||||||
variant="ghost"
|
|
||||||
color="gray"
|
|
||||||
onClick={() => setShowHamburgerMenu((state) => !state)}
|
|
||||||
>
|
|
||||||
{showHamburgerMenu ? <Cross1Icon /> : <HamburgerMenuIcon />}
|
|
||||||
</IconButton>
|
|
||||||
|
|
||||||
<Link
|
<Link
|
||||||
onClick={() => setShowHamburgerMenu(false)}
|
color="gray"
|
||||||
href="/"
|
highContrast
|
||||||
style={{
|
href="/"
|
||||||
color: 'inherit',
|
underline="hover"
|
||||||
display: 'flex',
|
weight="bold"
|
||||||
alignItems: 'center',
|
>
|
||||||
justifyContent: 'center',
|
BlitzKit
|
||||||
}}
|
</Link>
|
||||||
weight="bold"
|
</Flex>
|
||||||
>
|
|
||||||
BlitzKit
|
|
||||||
</Link>
|
|
||||||
</Flex>
|
|
||||||
|
|
||||||
<Flex justify="center" gap="4" className={styles.toolTexts}>
|
<Box flexGrow="1" />
|
||||||
{filteredTools.map((tool) => {
|
|
||||||
const selected = pathname.startsWith(`/tools/${tool.id}`);
|
|
||||||
|
|
||||||
return (
|
<Flex align="center" gap="2" justify="center" className={styles.tools}>
|
||||||
|
{TOOLS.map((tool, index) => {
|
||||||
|
const selected = pathname.startsWith(`/tools/${tool.id}`);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{index > 0 && <Separator orientation="vertical" size="1" />}
|
||||||
<Link
|
<Link
|
||||||
key={tool.id}
|
|
||||||
color="gray"
|
color="gray"
|
||||||
size="2"
|
|
||||||
highContrast={selected}
|
highContrast={selected}
|
||||||
|
size="2"
|
||||||
|
href={`tools/${tool.id}`}
|
||||||
|
key={tool.title}
|
||||||
underline={selected ? 'always' : 'hover'}
|
underline={selected ? 'always' : 'hover'}
|
||||||
href={`/tools/${tool.id}`}
|
|
||||||
>
|
>
|
||||||
{tool.title}
|
{tool.title}
|
||||||
</Link>
|
</Link>
|
||||||
);
|
</>
|
||||||
})}
|
);
|
||||||
</Flex>
|
})}
|
||||||
|
|
||||||
<Flex align="center" gap="4">
|
|
||||||
<Link
|
|
||||||
onClick={() => setShowHamburgerMenu(false)}
|
|
||||||
href="https://discord.gg/nDt7AjGJQH"
|
|
||||||
target="_blank"
|
|
||||||
style={{
|
|
||||||
color: 'inherit',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<DiscordLogoIcon width={16} height={16} />
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<Link
|
|
||||||
onClick={() => setShowHamburgerMenu(false)}
|
|
||||||
href="https://www.patreon.com/tresabhi"
|
|
||||||
target="_blank"
|
|
||||||
style={{
|
|
||||||
color: 'inherit',
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<PatreonIcon width={14} height={14} />
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<Link
|
|
||||||
href="/settings"
|
|
||||||
onClick={() => setShowHamburgerMenu(false)}
|
|
||||||
color="gray"
|
|
||||||
highContrast
|
|
||||||
>
|
|
||||||
<Flex style={{ width: '100%', height: '100%' }} justify="center">
|
|
||||||
<GearIcon />
|
|
||||||
</Flex>
|
|
||||||
</Link>
|
|
||||||
|
|
||||||
<Popover.Root>
|
|
||||||
<Popover.Trigger>
|
|
||||||
<PersonIcon style={{ cursor: 'pointer' }} />
|
|
||||||
</Popover.Trigger>
|
|
||||||
|
|
||||||
<Popover.Content
|
|
||||||
align="end"
|
|
||||||
width="320px"
|
|
||||||
onOpenAutoFocus={(event) => event.preventDefault()}
|
|
||||||
>
|
|
||||||
{(logins.patreon || logins.wargaming) && (
|
|
||||||
<Flex direction="column" gap="2">
|
|
||||||
<Text align="center" color="gray">
|
|
||||||
Logged in accounts
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
{logins.patreon && (
|
|
||||||
<Flex align="center" gap="2" justify="center">
|
|
||||||
<PatreonIcon width={15} height={15} />
|
|
||||||
<Text>Patreon</Text>
|
|
||||||
<Button
|
|
||||||
color="red"
|
|
||||||
variant="ghost"
|
|
||||||
onClick={() =>
|
|
||||||
mutateApp((draft) => {
|
|
||||||
draft.logins.patreon = undefined;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Logout
|
|
||||||
</Button>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{logins.wargaming && (
|
|
||||||
<Flex align="center" gap="2" justify="center">
|
|
||||||
<WargamingIcon width={15} height={15} />
|
|
||||||
<Text>Wargaming</Text>
|
|
||||||
<Button
|
|
||||||
color="red"
|
|
||||||
variant="ghost"
|
|
||||||
onClick={() =>
|
|
||||||
mutateApp((draft) => {
|
|
||||||
draft.logins.wargaming = undefined;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Logout
|
|
||||||
</Button>
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!logins.patreon !== !logins.wargaming && (
|
|
||||||
<Inset side="x">
|
|
||||||
<Separator my="4" size="4" />
|
|
||||||
</Inset>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{(!logins.patreon || !logins.wargaming) && (
|
|
||||||
<Flex direction="column" gap="2">
|
|
||||||
<Text align="center" color="gray">
|
|
||||||
Log in with...
|
|
||||||
</Text>
|
|
||||||
|
|
||||||
{!logins.patreon && (
|
|
||||||
<Link style={{ width: '100%' }} href={patreonLoginUrl()}>
|
|
||||||
<Button style={{ width: '100%' }} color="tomato">
|
|
||||||
<PatreonIcon width={15} height={15} /> Patreon
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{!logins.wargaming && (
|
|
||||||
<Dialog.Root>
|
|
||||||
<Dialog.Trigger>
|
|
||||||
<Button color="red">
|
|
||||||
<WargamingIcon width={15} height={15} /> Wargaming
|
|
||||||
</Button>
|
|
||||||
</Dialog.Trigger>
|
|
||||||
|
|
||||||
<Dialog.Content width="fit-content">
|
|
||||||
<Flex direction="column" gap="4" align="center">
|
|
||||||
<Text color="gray">Choose your region</Text>
|
|
||||||
|
|
||||||
<Flex gap="2" wrap="wrap">
|
|
||||||
{REGIONS.map((region) => (
|
|
||||||
<Dialog.Close key={region}>
|
|
||||||
<Link
|
|
||||||
href={
|
|
||||||
typeof window !== 'undefined'
|
|
||||||
? `https://api.worldoftanks.${region}/wot/auth/login/?application_id=${WARGAMING_APPLICATION_ID}&redirect_uri=${encodeURIComponent(
|
|
||||||
`${location.origin}/auth/wargaming?return=${location.origin}${location.pathname}`,
|
|
||||||
)}`
|
|
||||||
: undefined
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Button color="red">
|
|
||||||
{strings.common.regions.normal[region]}
|
|
||||||
</Button>
|
|
||||||
</Link>
|
|
||||||
</Dialog.Close>
|
|
||||||
))}
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
</Dialog.Content>
|
|
||||||
</Dialog.Root>
|
|
||||||
)}
|
|
||||||
</Flex>
|
|
||||||
)}
|
|
||||||
</Popover.Content>
|
|
||||||
</Popover.Root>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
|
|
||||||
<Flex mt="9" gap="3" justify="center" wrap="wrap">
|
<Box flexGrow="1" />
|
||||||
{filteredTools.map((tool) => (
|
|
||||||
<Link
|
<Flex align="center" gap="3">
|
||||||
key={tool.id}
|
<Link
|
||||||
href={`/tools/${tool.id}`}
|
style={{ display: 'flex', alignContent: 'center' }}
|
||||||
className={styles.toolCard}
|
color="gray"
|
||||||
style={{
|
href="https://discord.gg/nDt7AjGJQH"
|
||||||
backgroundImage: `url(${imgur(tool.image, {
|
underline="none"
|
||||||
format: 'jpeg',
|
target="_blank"
|
||||||
size: ImgurSize.MediumThumbnail,
|
>
|
||||||
})})`,
|
<DiscordLogoIcon />
|
||||||
cursor: tool.disabled ? 'default' : 'pointer',
|
</Link>
|
||||||
opacity: tool.disabled ? 0.25 : 1,
|
<Link
|
||||||
height: 64,
|
style={{ display: 'flex', alignContent: 'center' }}
|
||||||
minWidth: 176,
|
color="gray"
|
||||||
flex: 1,
|
href="https://discord.gg/nDt7AjGJQH"
|
||||||
borderRadius: 8,
|
underline="none"
|
||||||
textDecoration: 'none',
|
target="_blank"
|
||||||
backgroundSize: 'cover',
|
>
|
||||||
backgroundPosition: 'center',
|
<PatreonIcon width="0.75em" height="0.75em" />
|
||||||
overflow: 'hidden',
|
</Link>
|
||||||
display: 'flex',
|
<Link
|
||||||
flexDirection: 'column',
|
style={{ display: 'flex', alignContent: 'center' }}
|
||||||
alignItems: 'flex-start',
|
color="gray"
|
||||||
justifyContent: 'flex-end',
|
href="/settings"
|
||||||
padding: 8,
|
underline="none"
|
||||||
transition: `box-shadow ${theme.durations.regular}`,
|
target="_blank"
|
||||||
}}
|
>
|
||||||
onClick={() => setShowHamburgerMenu(false)}
|
<GearIcon />
|
||||||
>
|
</Link>
|
||||||
<Text
|
<IconButton variant="ghost" color="gray">
|
||||||
style={{
|
<PersonIcon />
|
||||||
color: theme.colors.textHighContrast,
|
</IconButton>
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{tool.title}
|
|
||||||
</Text>
|
|
||||||
</Link>
|
|
||||||
))}
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Box>
|
</Flex>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -126,6 +126,4 @@ export const TOOLS: Tool[] = [
|
|||||||
playerStatsTool,
|
playerStatsTool,
|
||||||
sessionTool,
|
sessionTool,
|
||||||
ratingTool,
|
ratingTool,
|
||||||
discordTool,
|
|
||||||
moreTool,
|
|
||||||
];
|
];
|
||||||
Reference in new issue
Block a user