From a0660fc2acbd665d14df7eb9949da251a25bdb9a Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Sat, 28 Nov 2026 16:05:47 -0600 Subject: [PATCH] home page --- CLAUDE.md | 1 + packages/i18n/strings/en.json | 1 + .../website/src/components/BaseStyles.astro | 2 +- .../src/components/HomeCosmetics.astro | 9 ++-- .../website/src/components/HomeGames.astro | 9 ++-- .../website/src/components/HomeHero.astro | 6 +-- .../website/src/components/HomePlayers.astro | 15 ++---- .../website/src/components/HomeSection.astro | 22 +++++++++ .../website/src/components/HomeTanks.astro | 9 ++-- .../src/components/HomeTechnical.astro | 9 ++-- .../website/src/components/HomeTools.astro | 29 ++++++++++++ .../website/src/components/NavbarFine.astro | 9 ++++ .../website/src/components/Sections.astro | 20 +++++++- .../TankopediaFullscreen/index.module.css | 5 ++ .../components/TankopediaFullscreen/index.tsx | 47 +++++++++++++++++++ .../TankopediaLoadout/index.module.css | 4 +- .../TankopediaSandbox/index.module.css | 4 -- .../components/TankopediaSandbox/index.tsx | 2 + .../website/src/components/ToolCard.astro | 2 +- packages/website/src/config/tools.ts | 9 +++- .../[...locale]/index.astro | 19 +++++--- .../[...locale]/tanks/[slug]/index.astro | 23 +++++---- 22 files changed, 190 insertions(+), 66 deletions(-) create mode 100644 packages/website/src/components/HomeSection.astro create mode 100644 packages/website/src/components/HomeTools.astro create mode 100644 packages/website/src/components/TankopediaFullscreen/index.module.css create mode 100644 packages/website/src/components/TankopediaFullscreen/index.tsx diff --git a/CLAUDE.md b/CLAUDE.md index aef843e74..bfd7f421f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -50,6 +50,7 @@ Pages that are not migrated yet are named `_index.astro` so Astro skips them. Mi - Select elements by their own class, never by structure or tag (`> *`, `> div`, `:first-child`, bare `svg`, `[data-x] > *`). If an element needs styling, give it a class and nest that class under its parent. The exception is content a component renders internally that has no `className` to pass, like the icon inside an `IconButton` (`.swatch svg`). - Nest CSS to mirror the markup: a child's rules go inside its parent's block (`.marker { .bar { } }`), so the stylesheet reads like the HTML tree. - Fully rounded corners use `var(--radius-max)`, never `var(--max-size)`. +- Zero takes no unit (`0`, not `0px`), except where it ends up inside `calc()`, which needs a length (`calc(100dvh - var(--x, 0px))`). - Avoid `z-index: 2` or above unless nothing else works. Resolve overlaps first by DOM order (a later sibling at the same `z-index` paints on top, so put overlays and curtains before what must sit above them) or by leveling the field (give competing siblings the same `position: relative`/`z-index: 1`, or `isolation: isolate` a container so its children's layers stay inside it). ## Components diff --git a/packages/i18n/strings/en.json b/packages/i18n/strings/en.json index 2e2be9a11..c88064b56 100644 --- a/packages/i18n/strings/en.json +++ b/packages/i18n/strings/en.json @@ -526,6 +526,7 @@ "tanks": "Tanks", "players": "Players", "games": "Games", + "tools": "Tools", "cosmetics": "Cosmetics", "technical": "Technical" }, diff --git a/packages/website/src/components/BaseStyles.astro b/packages/website/src/components/BaseStyles.astro index 8c90c53f7..3e15efa17 100644 --- a/packages/website/src/components/BaseStyles.astro +++ b/packages/website/src/components/BaseStyles.astro @@ -22,7 +22,7 @@ styles += "}"; + +
+ {title} + +
diff --git a/packages/website/src/components/HomeTanks.astro b/packages/website/src/components/HomeTanks.astro index 2f2671aa4..f2bfa626a 100644 --- a/packages/website/src/components/HomeTanks.astro +++ b/packages/website/src/components/HomeTanks.astro @@ -1,8 +1,7 @@ --- import { api } from "../api/dynamic"; import { tools } from "../config/tools"; -import { Heading } from "./Heading"; -import { Section } from "./Section"; +import HomeSection from "./HomeSection.astro"; import ToolCard from "./ToolCard.astro"; import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro"; import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro"; @@ -15,9 +14,7 @@ const { locale } = Astro.props; const strings = await api.strings(locale); --- -
- {strings.home.tanks} - + @@ -28,4 +25,4 @@ const strings = await api.strings(locale); -
+ diff --git a/packages/website/src/components/HomeTechnical.astro b/packages/website/src/components/HomeTechnical.astro index 268e0f3db..4c97fff11 100644 --- a/packages/website/src/components/HomeTechnical.astro +++ b/packages/website/src/components/HomeTechnical.astro @@ -1,8 +1,7 @@ --- import { api } from "../api/dynamic"; import { tools } from "../config/tools"; -import { Heading } from "./Heading"; -import { Section } from "./Section"; +import HomeSection from "./HomeSection.astro"; import ToolCard from "./ToolCard.astro"; import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro"; import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro"; @@ -16,9 +15,7 @@ const { locale } = Astro.props; const strings = await api.strings(locale); --- -
- {strings.home.technical} - + @@ -28,4 +25,4 @@ const strings = await api.strings(locale); -
+ diff --git a/packages/website/src/components/HomeTools.astro b/packages/website/src/components/HomeTools.astro new file mode 100644 index 000000000..531e4bf02 --- /dev/null +++ b/packages/website/src/components/HomeTools.astro @@ -0,0 +1,29 @@ +--- +import { api } from "../api/dynamic"; +import { tools } from "../config/tools"; +import HomeSection from "./HomeSection.astro"; +import ToolCard from "./ToolCard.astro"; +import ToolCardLayoutColumn from "./ToolCardLayoutColumn.astro"; +import ToolCardLayoutRoot from "./ToolCardLayoutRoot.astro"; + +interface Props { + locale: string; +} + +const { locale } = Astro.props; + +const strings = await api.strings(locale); +--- + + + + + + + + + + + + + diff --git a/packages/website/src/components/NavbarFine.astro b/packages/website/src/components/NavbarFine.astro index fef40813b..70d72a4c2 100644 --- a/packages/website/src/components/NavbarFine.astro +++ b/packages/website/src/components/NavbarFine.astro @@ -206,9 +206,18 @@ const groups = toolGroups.map((group) => { const triggers = navbar.querySelectorAll(".trigger"); const panels = navbar.querySelectorAll(".panel"); const icons = navbar.querySelectorAll(".bar .icon"); + const bar = navbar.querySelector(".bar")!; let hoverTimeout: number | undefined; + // Lets sticky page elements sit below the bar instead of behind it + new ResizeObserver(() => { + document.documentElement.style.setProperty( + "--navbar-fine-height", + `${bar.offsetHeight}px`, + ); + }).observe(bar); + function resize(height: number) { const duration = Math.min(MAX_DURATION, Math.max(MIN_DURATION, height / 2)); diff --git a/packages/website/src/components/Sections.astro b/packages/website/src/components/Sections.astro index e0d7e3aef..403e77e99 100644 --- a/packages/website/src/components/Sections.astro +++ b/packages/website/src/components/Sections.astro @@ -1,15 +1,31 @@ +--- +interface Props { + // Centers the sections within the page width, lined up with the navbar + centered?: boolean; +} + +const { centered } = Astro.props; +--- + -
+
diff --git a/packages/website/src/components/TankopediaFullscreen/index.module.css b/packages/website/src/components/TankopediaFullscreen/index.module.css new file mode 100644 index 000000000..2cfb2582a --- /dev/null +++ b/packages/website/src/components/TankopediaFullscreen/index.module.css @@ -0,0 +1,5 @@ +.fullscreen { + position: absolute; + right: var(--space-4); + bottom: var(--space-4); +} diff --git a/packages/website/src/components/TankopediaFullscreen/index.tsx b/packages/website/src/components/TankopediaFullscreen/index.tsx new file mode 100644 index 000000000..d1d7df8ae --- /dev/null +++ b/packages/website/src/components/TankopediaFullscreen/index.tsx @@ -0,0 +1,47 @@ +import { EnterFullScreenIcon, ExitFullScreenIcon } from "@radix-ui/react-icons"; +import { useCallback, useEffect, useState, type RefObject } from "react"; +import { IconButton } from "../IconButton"; +import styles from "./index.module.css"; + +interface TankopediaFullscreenProps { + target: RefObject; +} + +export function TankopediaFullscreen({ target }: TankopediaFullscreenProps) { + const [available, setAvailable] = useState(false); + const [isFullscreen, setIsFullscreen] = useState(false); + + useEffect(() => { + function handleFullscreenChange() { + setIsFullscreen(document.fullscreenElement === target.current); + } + + setAvailable(document.fullscreenEnabled); + document.addEventListener("fullscreenchange", handleFullscreenChange); + + return () => { + document.removeEventListener("fullscreenchange", handleFullscreenChange); + }; + }, []); + + const handleClick = useCallback(() => { + if (isFullscreen) { + document.exitFullscreen(); + } else { + target.current!.requestFullscreen(); + } + }, [isFullscreen]); + + if (!available) return null; + + return ( + + {isFullscreen ? : } + + ); +} diff --git a/packages/website/src/components/TankopediaLoadout/index.module.css b/packages/website/src/components/TankopediaLoadout/index.module.css index 3f6af122f..ec0e35927 100644 --- a/packages/website/src/components/TankopediaLoadout/index.module.css +++ b/packages/website/src/components/TankopediaLoadout/index.module.css @@ -6,9 +6,9 @@ background-color: var(--gray-2); position: sticky; - top: 0; + top: var(--navbar-fine-height, 0); - max-height: 100dvh; + max-height: calc(100dvh - var(--navbar-fine-height, 0px)); overflow-y: auto; padding: var(--space-5); diff --git a/packages/website/src/components/TankopediaSandbox/index.module.css b/packages/website/src/components/TankopediaSandbox/index.module.css index 5d8472ad7..efd67096f 100644 --- a/packages/website/src/components/TankopediaSandbox/index.module.css +++ b/packages/website/src/components/TankopediaSandbox/index.module.css @@ -9,9 +9,5 @@ width: 100%; height: 100%; background-color: black; - - @media (pointer: fine) { - border-radius: var(--space-4); - } } } diff --git a/packages/website/src/components/TankopediaSandbox/index.tsx b/packages/website/src/components/TankopediaSandbox/index.tsx index 9b1e0a8c6..1a2fbe7bd 100644 --- a/packages/website/src/components/TankopediaSandbox/index.tsx +++ b/packages/website/src/components/TankopediaSandbox/index.tsx @@ -27,6 +27,7 @@ import { SmartCanvas } from "../SmartCanvas"; import { TankDynamicArmor } from "../TankDynamicArmor"; import { TankModel } from "../TankModel"; import { TankopediaAntagonistControl } from "../TankopediaAntagonistControl"; +import { TankopediaFullscreen } from "../TankopediaFullscreen"; import { TankopediaOptions } from "../TankopediaOptions"; import { TankopediaQuickInputs } from "../TankopediaQuickInputs"; import { TankopediaSkinSwitcher } from "../TankopediaSkinSwitcher"; @@ -214,6 +215,7 @@ function Sandbox({ id }: TankopediaSandboxProps) { +
); diff --git a/packages/website/src/components/ToolCard.astro b/packages/website/src/components/ToolCard.astro index 0ea08ab35..9ee22fb8c 100644 --- a/packages/website/src/components/ToolCard.astro +++ b/packages/website/src/components/ToolCard.astro @@ -90,7 +90,7 @@ const name = strings.tools[tool.id as keyof typeof strings.tools]; {locale} className="link" underline="never" - href={tool.href ?? `/${tool.id}`} + href={tool.href ?? `/${tool.slug ?? tool.id}`} target={tool.href ? "_blank" : undefined} >
{ - - - - - - + + + + + + + diff --git a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/index.astro b/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/index.astro index 89a1af38f..1855f5cd9 100644 --- a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/index.astro +++ b/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/index.astro @@ -36,8 +36,6 @@ const { id, locale } = Astro.props; flex-grow: 1; display: flex; - gap: var(--space-4); - .sandbox { flex-grow: 1; @@ -45,8 +43,12 @@ const { id, locale } = Astro.props; flex-direction: column; gap: var(--space-4); - @media (pointer: fine) { - padding-top: var(--space-4); + .content { + display: flex; + flex-direction: column; + gap: var(--space-4); + + padding-inline: var(--page-padding); } } } @@ -55,12 +57,15 @@ const { id, locale } = Astro.props;
- - - - - + +
+ + + + + +