From 08df0001ed487152f22d76e976768d7e5371b0e9 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Tue, 17 Nov 2026 23:48:31 -0600 Subject: [PATCH] i got ideas --- packages/i18n/strings/en.json | 24 ++ .../src/components/BlitzkitButtonGrayIcon.tsx | 40 -- packages/website/src/components/Navbar.astro | 359 ++++++++---------- .../src/components/Scroller/index.module.css | 3 + .../components/SmartCanvas/index.module.css | 12 +- .../src/components/SmartCanvas/index.tsx | 3 +- .../website/src/components/SystemTheme.astro | 12 + .../TankopediaSandbox/index.module.css | 19 +- .../components/TankopediaSandbox/index.tsx | 55 +-- packages/website/src/constants/tools.ts | 6 +- packages/website/src/layouts/BaseLayout.astro | 53 +-- .../[...locale]/index2.astro | 18 + .../tanks/[slug]/_index.module.css | 2 +- .../[...locale]/tanks/[slug]/_index.tsx | 108 +++--- 14 files changed, 350 insertions(+), 364 deletions(-) delete mode 100644 packages/website/src/components/BlitzkitButtonGrayIcon.tsx create mode 100644 packages/website/src/components/SystemTheme.astro create mode 100644 packages/website/src/pages/[...chunk_default]/[...locale]/index2.astro diff --git a/packages/i18n/strings/en.json b/packages/i18n/strings/en.json index 139cc1704..e356be747 100644 --- a/packages/i18n/strings/en.json +++ b/packages/i18n/strings/en.json @@ -1,4 +1,8 @@ { + "navbar": { + "settings": "Settings" + }, + "guesser": { "help": { "title": "Partially reveal tank?", @@ -449,6 +453,26 @@ "name": "Settings", "slogan": "", "action": "" + }, + "tier_list": { + "name": "Tier list", + "slogan": "Rank tanks your way", + "action": "Make a list" + }, + "embed": { + "name": "Embed", + "slogan": "Stream overlays and widgets", + "action": "Customize" + }, + "more": { + "name": "More", + "slogan": "Suggest a tool on Discord", + "action": "Join Discord" + }, + "credits": { + "name": "Credits", + "slogan": "", + "action": "" } }, diff --git a/packages/website/src/components/BlitzkitButtonGrayIcon.tsx b/packages/website/src/components/BlitzkitButtonGrayIcon.tsx deleted file mode 100644 index a9e7b07f3..000000000 --- a/packages/website/src/components/BlitzkitButtonGrayIcon.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import type { ComponentProps } from 'react'; - -export function BlitzkitButtonGrayIcon(props: ComponentProps<'svg'>) { - return ( - - - - - - - - - - - - - - ); -} diff --git a/packages/website/src/components/Navbar.astro b/packages/website/src/components/Navbar.astro index ece7cba64..03d02c2f0 100644 --- a/packages/website/src/components/Navbar.astro +++ b/packages/website/src/components/Navbar.astro @@ -1,226 +1,183 @@ --- -import { - Cross1Icon, - DiscordLogoIcon, - GearIcon, - HamburgerMenuIcon, -} from "@radix-ui/react-icons"; -import { Box, Code, Flex, Grid, IconButton, Link } from "@radix-ui/themes"; -import { resolveBranchName } from "../core/blitzkit/branches"; -import { getStrings } from "../core/i18n/getStrings"; -import { Var } from "../core/radix/var"; -import { LinkI18n } from "./LinkI18n"; +import { GearIcon } from "@radix-ui/react-icons"; +import { api } from "../api/dynamic"; import { tools } from "../constants/tools"; -import { NavbarAccount } from "./NavbarAccount"; +import type { LocaleAcceptorProps } from "../hooks/useLocale"; +import { Logo } from "../icons/Logo"; +import { LinkI18nWrapper } from "./LinkI18nWrapper"; +import { Text } from "./Text"; -export interface Props { - integrated?: boolean; - locale: string; -} +type Props = LocaleAcceptorProps; -const { integrated = false } = Astro.props; -const toolsFiltered = Object.entries(tools).filter(([, tool]) => !tool.href); const { locale } = Astro.props; -const branchName = resolveBranchName(locale); -const isBranchNamed = branchName !== undefined; -const strings = getStrings(locale); + +const strings = await api.strings(locale); + +const filtered = Object.values(tools).filter( + (tool) => !tool.href && (tool.navbar ?? true), +); --- - +
+ {filtered.map((tool) => ( + <> + +
+ + + + ))} +
- - - - - - - - - - - - - - - - - - - - - - - - { - toolsFiltered.map(([id, tool]) => { - const toolStrings = - strings.website.tools[ - (tool.strings ?? id) as keyof typeof strings.website.tools - ]; - - return ( - - - - {toolStrings.name} - - - - ); - }) - } - - - - - - + + + +
+ diff --git a/packages/website/src/components/Scroller/index.module.css b/packages/website/src/components/Scroller/index.module.css index edb530823..39bd8fe1c 100644 --- a/packages/website/src/components/Scroller/index.module.css +++ b/packages/website/src/components/Scroller/index.module.css @@ -107,6 +107,9 @@ } .bar { + /* TODO: temporarily hidden */ + display: none !important; + position: absolute; opacity: 0; diff --git a/packages/website/src/components/SmartCanvas/index.module.css b/packages/website/src/components/SmartCanvas/index.module.css index 92c88e259..0889bcba9 100644 --- a/packages/website/src/components/SmartCanvas/index.module.css +++ b/packages/website/src/components/SmartCanvas/index.module.css @@ -1,4 +1,10 @@ -.canvas { - position: absolute; - inset: 0; +.aligner { + position: relative; + width: 100%; + height: 100%; + + .canvas { + position: absolute; + inset: 0; + } } diff --git a/packages/website/src/components/SmartCanvas/index.tsx b/packages/website/src/components/SmartCanvas/index.tsx index 1d1afe769..3363a41ad 100644 --- a/packages/website/src/components/SmartCanvas/index.tsx +++ b/packages/website/src/components/SmartCanvas/index.tsx @@ -1,6 +1,7 @@ import { Canvas, type CanvasProps } from "@react-three/fiber"; import { useRef } from "react"; import { useOnScreen } from "../../hooks/useOnScreen"; +import { classNames } from "../../ui/classNames"; import styles from "./index.module.css"; export function SmartCanvas({ className, ...props }: CanvasProps) { @@ -8,7 +9,7 @@ export function SmartCanvas({ className, ...props }: CanvasProps) { const onScreen = useOnScreen(canvas); return ( -
+
+ const root = document.documentElement; + const media = window.matchMedia("(prefers-color-scheme: dark)"); + + function applyTheme(e: MediaQueryList | MediaQueryListEvent) { + root.classList.toggle("dark", e.matches); + root.classList.toggle("light", !e.matches); + } + + applyTheme(media); + media.addEventListener("change", applyTheme); + diff --git a/packages/website/src/components/TankopediaSandbox/index.module.css b/packages/website/src/components/TankopediaSandbox/index.module.css index 69903f43d..ffd632c35 100644 --- a/packages/website/src/components/TankopediaSandbox/index.module.css +++ b/packages/website/src/components/TankopediaSandbox/index.module.css @@ -1,20 +1,17 @@ .wrapper { - background-color: black; - height: calc(100dvh - 16rem); - position: relative; + padding: var(--space-4); + padding-bottom: 0; - overflow: hidden; + .cavity { + overflow: hidden; + + position: relative; - .sandbox { - position: absolute; - top: 0; - left: 0; width: 100%; height: 100%; + background-color: black; - .canvas { - background-color: black; - } + border-radius: var(--space-4); } } diff --git a/packages/website/src/components/TankopediaSandbox/index.tsx b/packages/website/src/components/TankopediaSandbox/index.tsx index 864e3bae1..50adf705c 100644 --- a/packages/website/src/components/TankopediaSandbox/index.tsx +++ b/packages/website/src/components/TankopediaSandbox/index.tsx @@ -152,34 +152,35 @@ export function TankopediaSandbox({ return (
- { - Tankopedia.mutate((draft) => { - draft.shot = undefined; - draft.highlightArmor = undefined; - }); - }} - > - {!skeleton && } - +
+ { + Tankopedia.mutate((draft) => { + draft.shot = undefined; + draft.highlightArmor = undefined; + }); + }} + > + {!skeleton && } + - - - - - - + + + + + + +
); } diff --git a/packages/website/src/constants/tools.ts b/packages/website/src/constants/tools.ts index b922a05ac..50befc6fb 100644 --- a/packages/website/src/constants/tools.ts +++ b/packages/website/src/constants/tools.ts @@ -1,12 +1,13 @@ export interface Tool { id: string; - path?: string; + slug?: string; href?: string; disabled?: boolean; banner_background_position: "top" | "center" | "bottom"; + navbar?: boolean; } export const tools: Record = { @@ -58,6 +59,7 @@ export const tools: Record = { }, tier_list: { id: "tier_list", + slug: "tier-list", banner_background_position: "bottom", }, embed: { @@ -82,10 +84,12 @@ export const tools: Record = { settings: { id: "settings", banner_background_position: "center", + navbar: false, }, credits: { disabled: true, id: "credits", banner_background_position: "center", + navbar: false, }, }; diff --git a/packages/website/src/layouts/BaseLayout.astro b/packages/website/src/layouts/BaseLayout.astro index 1b6b56dfb..5786ff55b 100644 --- a/packages/website/src/layouts/BaseLayout.astro +++ b/packages/website/src/layouts/BaseLayout.astro @@ -3,19 +3,22 @@ import BaseMeta from "../components/BaseMeta.astro"; import BaseStyles from "../components/BaseStyles.astro"; import ColorAlias from "../components/ColorAlias.astro"; import ColorScale from "../components/ColorScale.astro"; +import Navbar from "../components/Navbar.astro"; +import SystemTheme from "../components/SystemTheme.astro"; +import type { LocaleAcceptorProps } from "../hooks/useLocale"; import type { Color } from "../ui/color"; -interface Props { - locale: string; +type Props = LocaleAcceptorProps & { accent: Color; -} +}; -const { accent, locale } = Astro.props; +const { locale, accent } = Astro.props; --- + @@ -33,52 +36,36 @@ const { accent, locale } = Astro.props; - - - - - + -
+
- - diff --git a/packages/website/src/pages/[...chunk_default]/[...locale]/index2.astro b/packages/website/src/pages/[...chunk_default]/[...locale]/index2.astro new file mode 100644 index 000000000..347164213 --- /dev/null +++ b/packages/website/src/pages/[...chunk_default]/[...locale]/index2.astro @@ -0,0 +1,18 @@ +--- +import locales from "@blitzkit/i18n/locales.json"; +import BaseLayout2 from "../../../layouts/BaseLayout2.astro"; +import { getStaticPaths as _getStaticPaths } from "../_index"; + +import { mixStaticPaths } from "../../../astro/mixStaticPaths"; + +export const getStaticPaths = mixStaticPaths(_getStaticPaths, () => { + return locales.supported.map(({ locale }) => ({ + props: { locale }, + params: { locale: locale === locales.default ? undefined : locale }, + })); +}); + +const { locale } = Astro.props; +--- + + diff --git a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css b/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css index acebceff1..39eaf7cc2 100644 --- a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css +++ b/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css @@ -6,7 +6,7 @@ .sandbox { flex-grow: 1; - overflow-y: auto; + margin-left: calc(-1 * var(--space-4)); } .loadout { diff --git a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.tsx b/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.tsx index 4755132bb..ac924ec45 100644 --- a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.tsx +++ b/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.tsx @@ -23,6 +23,10 @@ type PageProps = MaybeSkeletonComponentProps & { id: number; }; +type SandboxProps = MaybeSkeletonComponentProps & { + tier: number; +}; + const tanks = await api.tanks(); export const Page = withErrorWrapper( @@ -31,54 +35,66 @@ export const Page = withErrorWrapper( Tankopedia.useInitialization(protagonistTank); - const protagonist = Tankopedia.use((state) => state.protagonist); - const equalize = Tankopedia.use((state) => state.environment.equalize); - - const characteristics = useCharacteristics("protagonist"); - const antagonistCharacteristics = useCharacteristics("antagonist"); - - const thicknessRange = useMemo(() => { - const entries = Object.values(tanks.tanks); - const filtered = entries.filter( - (thisTank) => thisTank.tier === protagonistTank.tier - ); - const value = - (filtered.reduce((accumulator, thisTank) => { - return ( - accumulator + - thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near * - ((equalize ? thisTank.equalizer : undefined) ?? defaultEqualizer) - .penetration - ); - }, 0) / - filtered.length) * - (3 / 4); - - return { value } satisfies ThicknessRange; - }, [protagonist, equalize]); - return (
- -
- -
-
- -
- - - - -
+ +
); - }) + }), ); + +function Loadout() { + return ( + +
+ +
+
+ ); +} + +function Sandbox({ skeleton, tier }: SandboxProps) { + const protagonist = Tankopedia.use((state) => state.protagonist); + const equalize = Tankopedia.use((state) => state.environment.equalize); + + const characteristics = useCharacteristics("protagonist"); + const antagonistCharacteristics = useCharacteristics("antagonist"); + + const thicknessRange = useMemo(() => { + const entries = Object.values(tanks.tanks); + const filtered = entries.filter((thisTank) => thisTank.tier === tier); + const value = + (filtered.reduce((accumulator, thisTank) => { + return ( + accumulator + + thisTank.turrets.at(-1)!.guns.at(-1)!.shells[0].penetration!.near * + ((equalize ? thisTank.equalizer : undefined) ?? defaultEqualizer) + .penetration + ); + }, 0) / + filtered.length) * + (3 / 4); + + return { value } satisfies ThicknessRange; + }, [protagonist, equalize]); + + return ( + + + + + + + ); +}