From 94b7e0f1b16015b129d17d694d7711287e43bea9 Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Fri, 20 Nov 2026 11:36:14 -0600 Subject: [PATCH] cut html by 40% --- .../components/TankopediaSandbox/index.tsx | 10 +++---- packages/website/src/hooks/useMounted.ts | 9 ++++++ .../[...locale]/tanks/[slug]/_index.tsx | 28 +++++-------------- .../[...locale]/tanks/[slug]/index.astro | 4 +-- 4 files changed, 22 insertions(+), 29 deletions(-) create mode 100644 packages/website/src/hooks/useMounted.ts diff --git a/packages/website/src/components/TankopediaSandbox/index.tsx b/packages/website/src/components/TankopediaSandbox/index.tsx index 50adf705c..b3b69557a 100644 --- a/packages/website/src/components/TankopediaSandbox/index.tsx +++ b/packages/website/src/components/TankopediaSandbox/index.tsx @@ -7,11 +7,11 @@ import { useDuelModels } from "../../hooks/useDuelModels"; import { useDuelModules } from "../../hooks/useDuelModules"; import { useEquipment } from "../../hooks/useEquipment"; import { useModel } from "../../hooks/useModel"; +import { useMounted } from "../../hooks/useMounted"; import { Tankopedia } from "../../stores/tankopedia"; import { TankopediaPersistent } from "../../stores/tankopediaPersistent"; import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants"; import type { ComputedCharacteristics } from "../../types/characteristics"; -import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps"; import { ArmorPlateDisplay } from "../ArmorPlateDisplay"; import { CanvasAutoClear } from "../CanvasAutoClear"; import { CanvasControl } from "../CanvasControl"; @@ -31,16 +31,16 @@ import { TankStaticArmor, type ThicknessRange } from "../TankStaticArmor"; import { Thicknesses } from "../Thicknesses"; import styles from "./index.module.css"; -type TankSandboxProps = MaybeSkeletonComponentProps & { +interface TankSandboxProps { thicknessRange: ThicknessRange; antagonistCharacteristics: ComputedCharacteristics; -}; +} export function TankopediaSandbox({ - skeleton, thicknessRange, antagonistCharacteristics, }: TankSandboxProps) { + const mounted = useMounted(); const wrapper = useRef(null); const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122); const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124); @@ -169,7 +169,7 @@ export function TankopediaSandbox({ }); }} > - {!skeleton && } + {mounted && } diff --git a/packages/website/src/hooks/useMounted.ts b/packages/website/src/hooks/useMounted.ts new file mode 100644 index 000000000..ef451847e --- /dev/null +++ b/packages/website/src/hooks/useMounted.ts @@ -0,0 +1,9 @@ +import { useEffect, useState } from "react"; + +export function useMounted() { + const [mounted, setMounted] = useState(false); + + useEffect(() => setMounted(true), []); + + return mounted; +} 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 0d1b270b0..e4fb3511e 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 @@ -17,28 +17,27 @@ import { withLocale } from "../../../../../hocs/withLocale"; import { useAwait } from "../../../../../hooks/useAwait"; import { useCharacteristics } from "../../../../../hooks/useCharacteristics"; import { Tankopedia, TankopediaTab } from "../../../../../stores/tankopedia"; -import type { MaybeSkeletonComponentProps } from "../../../../../types/maybeSkeletonComponentProps"; import styles from "./_index.module.css"; -type PageProps = MaybeSkeletonComponentProps & { +interface PageProps { id: number; -}; +} -type SandboxProps = MaybeSkeletonComponentProps & { +interface SandboxProps { tier: number; -}; +} const tanks = await api.tanks(); export const Page = withErrorWrapper( - withLocale(({ skeleton, id }) => { + withLocale(({ id }) => { const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`); Tankopedia.useInitialization(protagonistTank); return (
- +
); @@ -61,7 +60,7 @@ function Loadout() { ); } -function Sandbox({ skeleton, tier }: SandboxProps) { +function Sandbox({ tier }: SandboxProps) { const protagonist = Tankopedia.use((state) => state.protagonist); const equalize = Tankopedia.use((state) => state.environment.equalize); @@ -86,13 +85,10 @@ function Sandbox({ skeleton, tier }: SandboxProps) { return { value } satisfies ThicknessRange; }, [protagonist, equalize]); - const tabbed = Tankopedia.use((state) => state.tab === TankopediaTab.Sandbox); - return (
@@ -102,14 +98,4 @@ function Sandbox({ skeleton, tier }: SandboxProps) {
); - - // return ( - // - // - // ); } 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 8247dcc52..59a1e5b41 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 @@ -30,7 +30,5 @@ const { id, locale } = Astro.props; - - - +