mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
feat: revert navbar
This commit is contained in:
1 parent
ca6973f529
commit
2ad1e71176
5 files changed
+67
-143
No files matched your search
@@ -1,5 +1,5 @@
|
|||||||
import { literals } from "@blitzkit/i18n";
|
import { literals } from "@blitzkit/i18n";
|
||||||
import { Grade } from "@protos/auto_items";
|
import { Grade } from "@protos/blitz_static_standard_grades_enum";
|
||||||
import { DownloadIcon, StarFilledIcon } from "@radix-ui/react-icons";
|
import { DownloadIcon, StarFilledIcon } from "@radix-ui/react-icons";
|
||||||
import type { Color } from "../../core/ui/color";
|
import type { Color } from "../../core/ui/color";
|
||||||
import { useGameStrings } from "../../hooks/useGameStrings";
|
import { useGameStrings } from "../../hooks/useGameStrings";
|
||||||
@@ -55,11 +55,11 @@ interface DetailsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const gradeColors: Record<Grade, Color> = {
|
const gradeColors: Record<Grade, Color> = {
|
||||||
[Grade.GRADE_GRADE_UNSPECIFIED]: "gray",
|
[Grade.GRADE_UNSPECIFIED]: "gray",
|
||||||
[Grade.GRADE_GRADE_COMMON]: "gray",
|
[Grade.GRADE_COMMON]: "gray",
|
||||||
[Grade.GRADE_GRADE_RARE]: "blue",
|
[Grade.GRADE_RARE]: "blue",
|
||||||
[Grade.GRADE_GRADE_EPIC]: "purple",
|
[Grade.GRADE_EPIC]: "purple",
|
||||||
[Grade.GRADE_GRADE_LEGENDARY]: "amber",
|
[Grade.GRADE_LEGENDARY]: "amber",
|
||||||
};
|
};
|
||||||
|
|
||||||
function Details({ avatars }: DetailsProps) {
|
function Details({ avatars }: DetailsProps) {
|
||||||
|
|||||||
@@ -5,108 +5,77 @@ import { Text } from "./Text";
|
|||||||
import { api } from "../core/api/dynamic";
|
import { api } from "../core/api/dynamic";
|
||||||
import { tools } from "../core/tools/tools";
|
import { tools } from "../core/tools/tools";
|
||||||
import type { Tool } from "../core/tools/tools";
|
import type { Tool } from "../core/tools/tools";
|
||||||
|
import { HamburgerMenuIcon, MagnifyingGlassIcon } from "@radix-ui/react-icons";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
locale: string;
|
locale: string;
|
||||||
selectedTool?: Tool;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const { locale, selectedTool } = Astro.props;
|
const { locale } = Astro.props;
|
||||||
const strings = await api.strings(locale);
|
|
||||||
const toolsArray = Object.values(tools);
|
|
||||||
|
|
||||||
const toolsSorted =
|
|
||||||
selectedTool === undefined
|
|
||||||
? toolsArray
|
|
||||||
: [selectedTool, ...toolsArray.filter((tool) => tool !== selectedTool)];
|
|
||||||
---
|
---
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#navbar {
|
#navbar {
|
||||||
position: fixed;
|
position: sticky;
|
||||||
bottom: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
justify-content: center;
|
||||||
align-items: center;
|
|
||||||
|
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
background-color: var(--gray-a5);
|
background-color: var(--gray-a2);
|
||||||
box-shadow: var(--shadow-none);
|
box-shadow: var(--shadow-none);
|
||||||
backdrop-filter: var(--blur-glass) brightness(5%);
|
backdrop-filter: var(--blur-glass) brightness(10%);
|
||||||
border-radius: var(--space-4) var(--space-4) 0 0;
|
box-shadow: var(--shadow-subtle);
|
||||||
|
|
||||||
transition-duration: var(--duration-brief);
|
transition-duration: var(--duration-brief);
|
||||||
|
|
||||||
&[data-sticky="true"] {
|
&[data-sticky="true"] {
|
||||||
transform: translateY(100%);
|
transform: translateY(-100%);
|
||||||
}
|
box-shadow: var(--shadow-none);
|
||||||
|
|
||||||
.bar {
|
|
||||||
width: 100%;
|
|
||||||
max-width: var(--space-6);
|
|
||||||
height: var(--space-2);
|
|
||||||
margin-top: var(--space-3);
|
|
||||||
|
|
||||||
background-color: var(--white-a2);
|
|
||||||
|
|
||||||
border-radius: var(--max-size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.content {
|
.content {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: calc(var(--page-width) + 2 * var(--space-4));
|
max-width: calc(var(--page-width) + 2 * var(--space-4));
|
||||||
|
|
||||||
display: grid;
|
.group {
|
||||||
grid-template-columns: repeat(4, 1fr);
|
|
||||||
|
|
||||||
.action {
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
|
||||||
align-items: center;
|
|
||||||
padding: var(--space-3);
|
|
||||||
gap: var(--space-2);
|
gap: var(--space-2);
|
||||||
|
|
||||||
cursor: pointer;
|
.action {
|
||||||
color: var(--color-regular);
|
display: flex;
|
||||||
text-decoration: none;
|
flex-direction: column;
|
||||||
color: var(--gray-11);
|
align-items: center;
|
||||||
|
padding: var(--space-3);
|
||||||
|
gap: var(--space-2);
|
||||||
|
|
||||||
&[data-selected="true"] {
|
cursor: pointer;
|
||||||
color: var(--accent-12);
|
color: var(--color-regular);
|
||||||
|
text-decoration: none;
|
||||||
|
color: var(--gray-11);
|
||||||
|
|
||||||
.selector {
|
.selector {
|
||||||
background-color: var(--accent-5);
|
padding: var(--space-2);
|
||||||
}
|
border-radius: var(--max-size);
|
||||||
|
|
||||||
.label {
|
display: flex;
|
||||||
color: var(--gray-12) !important;
|
justify-content: center;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.selector {
|
|
||||||
padding: var(--space-2);
|
|
||||||
border-radius: var(--max-size);
|
|
||||||
|
|
||||||
display: flex;
|
|
||||||
justify-content: center;
|
|
||||||
|
|
||||||
width: 100%;
|
|
||||||
max-width: var(--space-6);
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
height: 1.25em;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
vertical-align: top;
|
max-width: var(--space-6);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.label {
|
.icon {
|
||||||
font-size: var(--font-size-minor);
|
height: 1.25em;
|
||||||
|
width: 100%;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -120,7 +89,10 @@ const toolsSorted =
|
|||||||
function handleScroll() {
|
function handleScroll() {
|
||||||
const dy = window.scrollY - lastScrollY;
|
const dy = window.scrollY - lastScrollY;
|
||||||
lastScrollY = window.scrollY;
|
lastScrollY = window.scrollY;
|
||||||
navbar.dataset.sticky = `${dy > 0}`;
|
|
||||||
|
const hide = window.scrollY > navbar.clientHeight && dy > 0;
|
||||||
|
|
||||||
|
navbar.dataset.sticky = `${hide}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleScroll();
|
handleScroll();
|
||||||
@@ -128,41 +100,27 @@ const toolsSorted =
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div id="navbar">
|
<div id="navbar">
|
||||||
<div class="bar"></div>
|
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<LinkI18n
|
<div class="group">
|
||||||
{locale}
|
<LinkI18n {locale} href="/" className="action" tabIndex={0}>
|
||||||
href="/"
|
<div class="selector">
|
||||||
className="action"
|
<BlitzKitIcon className="icon" />
|
||||||
tabIndex={0}
|
</div>
|
||||||
data-selected={selectedTool === undefined}
|
</LinkI18n>
|
||||||
>
|
</div>
|
||||||
<div class="selector">
|
|
||||||
<BlitzKitIcon className="icon" />
|
|
||||||
</div>
|
|
||||||
<Text lowContrast className="label">{strings.navbar.home}</Text>
|
|
||||||
</LinkI18n>
|
|
||||||
|
|
||||||
{
|
<div class="group">
|
||||||
toolsSorted.map(({ id, Icon }) => (
|
<LinkI18n {locale} href="/" className="action" tabIndex={0}>
|
||||||
<LinkI18n
|
<div class="selector">
|
||||||
key={id}
|
<MagnifyingGlassIcon className="icon" />
|
||||||
{locale}
|
</div>
|
||||||
href={`/${id}`}
|
</LinkI18n>
|
||||||
className="action"
|
|
||||||
tabIndex={0}
|
|
||||||
data-selected={selectedTool?.id === id}
|
|
||||||
>
|
|
||||||
<div class="selector">
|
|
||||||
<Icon className="icon" />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Text lowContrast className="label">
|
<LinkI18n {locale} href="/" className="action" tabIndex={0}>
|
||||||
{strings.tools[id as keyof typeof strings.tools].name}
|
<div class="selector">
|
||||||
</Text>
|
<HamburgerMenuIcon className="icon" />
|
||||||
</LinkI18n>
|
</div>
|
||||||
))
|
</LinkI18n>
|
||||||
}
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
---
|
---
|
||||||
import { ArrowLeftIcon } from "@radix-ui/react-icons";
|
|
||||||
import { api } from "../core/api/dynamic";
|
import { api } from "../core/api/dynamic";
|
||||||
import type { Tool } from "../core/tools/tools";
|
import type { Tool } from "../core/tools/tools";
|
||||||
import { Heading } from "./Heading";
|
import { Heading } from "./Heading";
|
||||||
import { LinkI18n } from "./LinkI18n";
|
|
||||||
import { Text } from "./Text";
|
import { Text } from "./Text";
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
@@ -26,7 +24,7 @@ const toolStrings = strings.tools[tool.id as keyof typeof strings.tools];
|
|||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
justify-content: center;
|
||||||
gap: var(--space-4);
|
gap: var(--space-4);
|
||||||
padding: var(--space-5) var(--space-4);
|
padding: var(--space-5) var(--space-4);
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@@ -37,10 +35,6 @@ const toolStrings = strings.tools[tool.id as keyof typeof strings.tools];
|
|||||||
padding: var(--space-6) var(--space-4);
|
padding: var(--space-6) var(--space-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
.back {
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.centered {
|
.centered {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
max-width: var(--page-width);
|
max-width: var(--page-width);
|
||||||
@@ -77,10 +71,6 @@ const toolStrings = strings.tools[tool.id as keyof typeof strings.tools];
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<LinkI18n highContrast className="back" {locale} href="/">
|
|
||||||
<ArrowLeftIcon />
|
|
||||||
</LinkI18n>
|
|
||||||
|
|
||||||
<div
|
<div
|
||||||
class="pattern"
|
class="pattern"
|
||||||
style={{ backgroundImage: `url(/assets/patterns/${tool.id}.svg)` }}
|
style={{ backgroundImage: `url(/assets/patterns/${tool.id}.svg)` }}
|
||||||
|
|||||||
@@ -1,11 +1,3 @@
|
|||||||
import {
|
|
||||||
ExclamationTriangleIcon,
|
|
||||||
GearIcon,
|
|
||||||
PersonIcon,
|
|
||||||
} from "@radix-ui/react-icons";
|
|
||||||
import type { IconProps } from "@radix-ui/react-icons/dist/types";
|
|
||||||
import type { ComponentProps, ReactNode } from "react";
|
|
||||||
import { TankIcon } from "../../icons/Tank";
|
|
||||||
import type { Color } from "../ui/color";
|
import type { Color } from "../ui/color";
|
||||||
|
|
||||||
export interface Tool {
|
export interface Tool {
|
||||||
@@ -13,17 +5,12 @@ export interface Tool {
|
|||||||
|
|
||||||
accent: Color;
|
accent: Color;
|
||||||
banner_background_position: "top" | "center" | "bottom";
|
banner_background_position: "top" | "center" | "bottom";
|
||||||
|
|
||||||
Icon:
|
|
||||||
| ((props: ComponentProps<"svg">) => ReactNode)
|
|
||||||
| ((props: IconProps) => ReactNode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const tools: Record<string, Tool> = {
|
export const tools: Record<string, Tool> = {
|
||||||
tanks: {
|
tanks: {
|
||||||
id: "tanks",
|
id: "tanks",
|
||||||
|
|
||||||
Icon: TankIcon,
|
|
||||||
accent: "purple",
|
accent: "purple",
|
||||||
banner_background_position: "top",
|
banner_background_position: "top",
|
||||||
},
|
},
|
||||||
@@ -31,7 +18,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
players: {
|
players: {
|
||||||
id: "players",
|
id: "players",
|
||||||
|
|
||||||
Icon: PersonIcon,
|
|
||||||
accent: "purple",
|
accent: "purple",
|
||||||
banner_background_position: "top",
|
banner_background_position: "top",
|
||||||
},
|
},
|
||||||
@@ -39,7 +25,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
settings: {
|
settings: {
|
||||||
id: "settings",
|
id: "settings",
|
||||||
|
|
||||||
Icon: GearIcon,
|
|
||||||
accent: "gray",
|
accent: "gray",
|
||||||
banner_background_position: "top",
|
banner_background_position: "top",
|
||||||
},
|
},
|
||||||
@@ -47,7 +32,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
avatars: {
|
avatars: {
|
||||||
id: "avatars",
|
id: "avatars",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "gold",
|
accent: "gold",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -55,7 +39,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
backgrounds: {
|
backgrounds: {
|
||||||
id: "backgrounds",
|
id: "backgrounds",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "gold",
|
accent: "gold",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -63,7 +46,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
api: {
|
api: {
|
||||||
id: "api",
|
id: "api",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "lime",
|
accent: "lime",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -71,7 +53,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
compare: {
|
compare: {
|
||||||
id: "compare",
|
id: "compare",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "crimson",
|
accent: "crimson",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -79,7 +60,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
performance: {
|
performance: {
|
||||||
id: "performance",
|
id: "performance",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "jade",
|
accent: "jade",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -87,7 +67,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
playlist: {
|
playlist: {
|
||||||
id: "playlist",
|
id: "playlist",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "tomato",
|
accent: "tomato",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -95,7 +74,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
mixer: {
|
mixer: {
|
||||||
id: "mixer",
|
id: "mixer",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "gray",
|
accent: "gray",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -103,7 +81,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
guesser: {
|
guesser: {
|
||||||
id: "guesser",
|
id: "guesser",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "cyan",
|
accent: "cyan",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
@@ -111,7 +88,6 @@ export const tools: Record<string, Tool> = {
|
|||||||
session: {
|
session: {
|
||||||
id: "session",
|
id: "session",
|
||||||
|
|
||||||
Icon: ExclamationTriangleIcon,
|
|
||||||
accent: "blue",
|
accent: "blue",
|
||||||
banner_background_position: "bottom",
|
banner_background_position: "bottom",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -61,12 +61,12 @@ const { accent, noNavbar, locale, selectedTool } = Astro.props;
|
|||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="dark">
|
<body class="dark">
|
||||||
|
{!noNavbar && <Navbar {selectedTool} {locale} />}
|
||||||
|
|
||||||
<slot name="pre-app" />
|
<slot name="pre-app" />
|
||||||
|
|
||||||
<div class="app">
|
<div class="app">
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!noNavbar && <Navbar {selectedTool} {locale} />}
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in new issue
Block a user