mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 02:37:05 +02:00
feat: navbar account
This commit is contained in:
1 parent
85491c7f22
commit
829df50eca
7 files changed
+120
-87
No files matched your search
Binary file not shown.
|
After Width: | Height: | Size: 692 B |
@@ -0,0 +1,22 @@
|
||||
import { Theme } from '@radix-ui/themes';
|
||||
import type { ReactNode } from 'react';
|
||||
|
||||
interface BlitzKitThemeProps {
|
||||
children: ReactNode;
|
||||
}
|
||||
|
||||
export function BlitzKitTheme({ children }: BlitzKitThemeProps) {
|
||||
return (
|
||||
<Theme
|
||||
style={{ minHeight: 'unset' }}
|
||||
appearance="dark"
|
||||
panelBackground="solid"
|
||||
radius="full"
|
||||
accentColor="amber"
|
||||
suppressHydrationWarning
|
||||
suppressContentEditableWarning
|
||||
>
|
||||
{children}
|
||||
</Theme>
|
||||
);
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import { NAVBAR_HEIGHT } from '../constants/navbar';
|
||||
import { homeTool, TOOLS } from '../constants/tools';
|
||||
import { PatreonIcon } from './PatreonIcon';
|
||||
import { NavbarAccount } from './NavbarAccount';
|
||||
import { TestComponent } from '../pages/TestComponent';
|
||||
|
||||
const toolsFiltered = TOOLS.filter((tool) => !('href' in tool));
|
||||
const tools = [homeTool, ...toolsFiltered];
|
||||
@@ -44,7 +45,7 @@ const isBranchNamed =
|
||||
|
||||
transition-duration: 250ms;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
/* overflow: hidden; */
|
||||
backdrop-filter: blur(4rem) brightness(0.75);
|
||||
-webkit-backdrop-filter: blur(4rem) brightness(0.75);
|
||||
|
||||
@@ -198,7 +199,7 @@ const isBranchNamed =
|
||||
<GearIcon />
|
||||
</Link>
|
||||
|
||||
<NavbarAccount client:load />
|
||||
<NavbarAccount client:idle />
|
||||
</Flex>
|
||||
</Flex>
|
||||
</Flex>
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
import { Suspense } from 'react';
|
||||
import { $patreonLogin } from '../stores/patreonLogin';
|
||||
import { $wargamingLogin } from '../stores/wargamingLogin';
|
||||
import { BlitzKitTheme } from './BlitzKitTheme';
|
||||
import { PatreonIcon } from './PatreonIcon';
|
||||
import { WargamingAccountName } from './WargamingAccountName';
|
||||
import { WargamingIcon } from './WargamingIcon';
|
||||
@@ -32,79 +33,81 @@ export function NavbarAccount() {
|
||||
</IconButton>
|
||||
</Popover.Trigger>
|
||||
|
||||
<Popover.Content
|
||||
align="end"
|
||||
width="320px"
|
||||
onOpenAutoFocus={(event) => event.preventDefault()}
|
||||
>
|
||||
{(patreonLogin.token || wargamingLogin.token) && (
|
||||
<Flex direction="column" gap="2">
|
||||
<Text align="center" color="gray">
|
||||
Logged in accounts
|
||||
</Text>
|
||||
<BlitzKitTheme>
|
||||
<Popover.Content
|
||||
align="end"
|
||||
width="320px"
|
||||
onOpenAutoFocus={(event) => event.preventDefault()}
|
||||
>
|
||||
{(patreonLogin.token || wargamingLogin.token) && (
|
||||
<Flex direction="column" gap="2">
|
||||
<Text align="center" color="gray">
|
||||
Logged in accounts
|
||||
</Text>
|
||||
|
||||
{patreonLogin.token && (
|
||||
<Flex align="center" gap="2" justify="center">
|
||||
<PatreonIcon width={15} height={15} />
|
||||
<Text>Patreon</Text>
|
||||
<Button
|
||||
color="red"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
$patreonLogin.set({ token: undefined });
|
||||
}}
|
||||
>
|
||||
Logout
|
||||
</Button>
|
||||
</Flex>
|
||||
)}
|
||||
{patreonLogin.token && (
|
||||
<Flex align="center" gap="2" justify="center">
|
||||
<PatreonIcon width={15} height={15} />
|
||||
<Text>Patreon</Text>
|
||||
<Button
|
||||
color="red"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
$patreonLogin.set({ token: undefined });
|
||||
}}
|
||||
>
|
||||
Logout
|
||||
</Button>
|
||||
</Flex>
|
||||
)}
|
||||
|
||||
{wargamingLogin.token && (
|
||||
<Flex align="center" gap="2" justify="center">
|
||||
<WargamingIcon width={15} height={15} />
|
||||
<Text>
|
||||
<Suspense fallback={<Skeleton height="1em" width="5rem" />}>
|
||||
<WargamingAccountName />
|
||||
</Suspense>
|
||||
</Text>
|
||||
<Button
|
||||
color="red"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
$wargamingLogin.set({ token: undefined });
|
||||
}}
|
||||
>
|
||||
Logout
|
||||
</Button>
|
||||
</Flex>
|
||||
)}
|
||||
</Flex>
|
||||
)}
|
||||
{wargamingLogin.token && (
|
||||
<Flex align="center" gap="2" justify="center">
|
||||
<WargamingIcon width={15} height={15} />
|
||||
<Text>
|
||||
<Suspense fallback={<Skeleton height="1em" width="5rem" />}>
|
||||
<WargamingAccountName />
|
||||
</Suspense>
|
||||
</Text>
|
||||
<Button
|
||||
color="red"
|
||||
variant="ghost"
|
||||
onClick={() => {
|
||||
$wargamingLogin.set({ token: undefined });
|
||||
}}
|
||||
>
|
||||
Logout
|
||||
</Button>
|
||||
</Flex>
|
||||
)}
|
||||
</Flex>
|
||||
)}
|
||||
|
||||
{!patreonLogin.token !== !wargamingLogin.token && (
|
||||
<Inset side="x">
|
||||
<Separator my="4" size="4" />
|
||||
</Inset>
|
||||
)}
|
||||
{!patreonLogin.token !== !wargamingLogin.token && (
|
||||
<Inset side="x">
|
||||
<Separator my="4" size="4" />
|
||||
</Inset>
|
||||
)}
|
||||
|
||||
{(!patreonLogin.token || !wargamingLogin.token) && (
|
||||
<Flex direction="column" gap="2">
|
||||
<Text align="center" color="gray">
|
||||
Log in with...
|
||||
</Text>
|
||||
{(!patreonLogin.token || !wargamingLogin.token) && (
|
||||
<Flex direction="column" gap="2">
|
||||
<Text align="center" color="gray">
|
||||
Log in with...
|
||||
</Text>
|
||||
|
||||
{!patreonLogin.token && (
|
||||
<Link style={{ width: '100%' }} href={patreonLoginUrl()}>
|
||||
<Button style={{ width: '100%' }} color="tomato">
|
||||
<PatreonIcon width={15} height={15} /> Patreon
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
{!patreonLogin.token && (
|
||||
<Link style={{ width: '100%' }} href={patreonLoginUrl()}>
|
||||
<Button style={{ width: '100%' }} color="tomato">
|
||||
<PatreonIcon width={15} height={15} /> Patreon
|
||||
</Button>
|
||||
</Link>
|
||||
)}
|
||||
|
||||
{!wargamingLogin.token && <WargamingLoginButton />}
|
||||
</Flex>
|
||||
)}
|
||||
</Popover.Content>
|
||||
{!wargamingLogin.token && <WargamingLoginButton />}
|
||||
</Flex>
|
||||
)}
|
||||
</Popover.Content>
|
||||
</BlitzKitTheme>
|
||||
</Popover.Root>
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
---
|
||||
import { Flex, Theme } from '@radix-ui/themes';
|
||||
import { Flex } from '@radix-ui/themes';
|
||||
import { BlitzKitTheme } from '../components/BlitzKitTheme';
|
||||
import Footer from '../components/Footer.astro';
|
||||
import Navbar from '../components/Navbar.astro';
|
||||
import Party3 from '../components/Party3.astro';
|
||||
@@ -37,14 +38,7 @@ const isRoot = pathname === '/';
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<Theme
|
||||
appearance="dark"
|
||||
panelBackground="solid"
|
||||
radius="full"
|
||||
accentColor="amber"
|
||||
suppressHydrationWarning
|
||||
suppressContentEditableWarning
|
||||
>
|
||||
<BlitzKitTheme>
|
||||
<Flex direction="column" minHeight="100vh">
|
||||
<Navbar />
|
||||
|
||||
@@ -56,6 +50,6 @@ const isRoot = pathname === '/';
|
||||
|
||||
<Footer />
|
||||
</Flex>
|
||||
</Theme>
|
||||
</BlitzKitTheme>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Button, Popover } from '@radix-ui/themes';
|
||||
import { Button, Flex, Popover, Text } from '@radix-ui/themes';
|
||||
import { BlitzKitTheme } from '../components/BlitzKitTheme';
|
||||
|
||||
export function TestComponent() {
|
||||
return (
|
||||
@@ -7,7 +8,14 @@ export function TestComponent() {
|
||||
<Button>Radix UI</Button>
|
||||
</Popover.Trigger>
|
||||
|
||||
<Popover.Content>Content</Popover.Content>
|
||||
<BlitzKitTheme>
|
||||
<Popover.Content>
|
||||
<Flex direction="column">
|
||||
<Text>I should be in a dark mode popover</Text>
|
||||
<Button>And I should be yellow and have full border radius!</Button>
|
||||
</Flex>
|
||||
</Popover.Content>
|
||||
</BlitzKitTheme>
|
||||
</Popover.Root>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +1,16 @@
|
||||
---
|
||||
import { Theme } from '@radix-ui/themes';
|
||||
import '@radix-ui/themes/styles.css';
|
||||
import { BlitzKitTheme } from '../components/BlitzKitTheme';
|
||||
import { TestComponent } from './TestComponent';
|
||||
---
|
||||
|
||||
Minimal!
|
||||
<style is:global>
|
||||
@import '@radix-ui/themes/styles.css';
|
||||
</style>
|
||||
|
||||
<Theme>
|
||||
<TestComponent client:only="react" />
|
||||
</Theme>
|
||||
<html>
|
||||
<body>
|
||||
<BlitzKitTheme>
|
||||
<TestComponent client:idle />
|
||||
</BlitzKitTheme>
|
||||
</body>
|
||||
</html>
|
||||
Reference in new issue
Block a user