From 076572e7ff053911658f550d18410635caf02e2b Mon Sep 17 00:00:00 2001 From: tresabhi <43380238+tresabhi@users.noreply.github.com> Date: Fri, 27 Nov 2026 21:05:28 -0600 Subject: [PATCH] demote componnents --- .../src/components/ErrorWrapper/index.tsx | 1 + .../TankopediaAntagonistControl/index.tsx | 15 +- .../TankopediaCharacteristics/index.tsx | 21 ++- .../TankopediaGameModeAbilities.astro | 143 ++++++++++++++++++ .../index.module.css | 64 -------- .../TankopediaGameModeAbilities/index.tsx | 94 ------------ .../TankopediaLoadout/index.module.css} | 17 +-- .../components/TankopediaLoadout/index.tsx | 33 +++- .../components/TankopediaSandbox/index.tsx | 68 ++++++--- .../src/components/TankopediaTabs/index.tsx | 17 ++- .../src/components/TankopediaTitle.astro | 39 +++++ .../TankopediaTitle/index.module.css | 10 -- .../src/components/TankopediaTitle/index.tsx | 23 --- .../src/components/TankopediaVideos.astro | 108 +++++++++++++ .../TankopediaVideos/index.module.css | 48 ------ .../src/components/TankopediaVideos/index.tsx | 56 ------- .../[...locale]/tanks/[slug]/_index.tsx | 89 ----------- .../[...locale]/tanks/[slug]/index.astro | 32 +++- 18 files changed, 437 insertions(+), 441 deletions(-) create mode 100644 packages/website/src/components/TankopediaGameModeAbilities.astro delete mode 100644 packages/website/src/components/TankopediaGameModeAbilities/index.module.css delete mode 100644 packages/website/src/components/TankopediaGameModeAbilities/index.tsx rename packages/website/src/{pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css => components/TankopediaLoadout/index.module.css} (58%) create mode 100644 packages/website/src/components/TankopediaTitle.astro delete mode 100644 packages/website/src/components/TankopediaTitle/index.module.css delete mode 100644 packages/website/src/components/TankopediaTitle/index.tsx create mode 100644 packages/website/src/components/TankopediaVideos.astro delete mode 100644 packages/website/src/components/TankopediaVideos/index.module.css delete mode 100644 packages/website/src/components/TankopediaVideos/index.tsx delete mode 100644 packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.tsx diff --git a/packages/website/src/components/ErrorWrapper/index.tsx b/packages/website/src/components/ErrorWrapper/index.tsx index 9e57abee7..e5b524385 100644 --- a/packages/website/src/components/ErrorWrapper/index.tsx +++ b/packages/website/src/components/ErrorWrapper/index.tsx @@ -16,6 +16,7 @@ interface Props { children: ReactNode; } +// TODO: move error screen to separate element and just make the fallback trigger that to handle duplicate hoc's export function ErrorWrapper({ children }: Props) { return ( }> diff --git a/packages/website/src/components/TankopediaAntagonistControl/index.tsx b/packages/website/src/components/TankopediaAntagonistControl/index.tsx index cc83e1645..52df011bc 100644 --- a/packages/website/src/components/TankopediaAntagonistControl/index.tsx +++ b/packages/website/src/components/TankopediaAntagonistControl/index.tsx @@ -8,7 +8,6 @@ import { useStrings } from "../../hooks/useStrings"; import { useUnwrapper } from "../../hooks/useUnwrapper"; import { Tankopedia } from "../../stores/tankopedia"; import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants"; -import type { ComputedCharacteristics } from "../../types/characteristics"; import { CustomShellButton } from "../CustomShellButton"; import { EqualIcon } from "../EqualIcon"; import { IconButton } from "../IconButton"; @@ -20,21 +19,21 @@ import { Tooltip } from "../Tooltip"; import styles from "./index.module.css"; interface TankopediaAntagonistControlProps { - antagonistCharacteristics: ComputedCharacteristics; + penetration: number; } export function TankopediaAntagonistControl({ - antagonistCharacteristics, + penetration, }: TankopediaAntagonistControlProps) { const strings = useStrings(); const unwrap = useUnwrapper(); const showControls = Tankopedia.use((state) => state.showControls); const isDynamicArmorDisplay = useAbsoluteDisplay( - TankopediaDisplay.DynamicArmor, + TankopediaDisplay.DynamicArmor ); const hasCustomShell = Tankopedia.use( - (state) => state.customShell !== undefined, + (state) => state.customShell !== undefined ); const equalize = Tankopedia.use((state) => state.environment.equalize); @@ -45,7 +44,7 @@ export function TankopediaAntagonistControl({ const antagonistUniqueGuns = useMemo( () => uniqueGuns(protagonist.tank.turrets), - [protagonist.tank.turrets], + [protagonist.tank.turrets] ); const isVisible = showControls && isDynamicArmorDisplay; @@ -54,9 +53,7 @@ export function TankopediaAntagonistControl({
{literals(strings.common.units.mm, { - value: ( - antagonistCharacteristics.get("penetration") as number - ).toFixed(0), + value: penetration.toFixed(0), })} diff --git a/packages/website/src/components/TankopediaCharacteristics/index.tsx b/packages/website/src/components/TankopediaCharacteristics/index.tsx index 29d723d15..2030124ce 100644 --- a/packages/website/src/components/TankopediaCharacteristics/index.tsx +++ b/packages/website/src/components/TankopediaCharacteristics/index.tsx @@ -4,8 +4,12 @@ import { Fragment, useRef } from "react"; import { characteristicsGroups } from "../../config/characteristicsGroups"; import { RANKING_STEPS } from "../../config/rankings"; import { toys } from "../../config/toys"; +import { withErrorWrapper } from "../../hocs/withErrorWrapper"; +import { withLocale } from "../../hocs/withLocale"; +import { useCharacteristics } from "../../hooks/useCharacteristics"; import { useDuelModules } from "../../hooks/useDuelModules"; import { useRankings } from "../../hooks/useRankings"; +import { api } from "../../api/dynamic"; import { useStrings } from "../../hooks/useStrings"; import { Tankopedia, TankopediaRelativeAgainst } from "../../stores/tankopedia"; import type { CharacteristicRank } from "../../tankopedia/calculateRankings"; @@ -24,13 +28,20 @@ import { CharacteristicValue } from "../CharacteristicValue"; import { Text } from "../Text"; import styles from "./index.module.css"; +const tanks = await api.tanks(); + interface TankopediaCharacteristicsProps { - characteristics: ComputedCharacteristics; + id: number; } -export function TankopediaCharacteristics({ - characteristics, -}: TankopediaCharacteristicsProps) { +export const TankopediaCharacteristics = withErrorWrapper( + withLocale(Content) +); + +function Content({ id }: TankopediaCharacteristicsProps) { + Tankopedia.useInitialization(() => tanks.tanks[id]); + + const characteristics = useCharacteristics("protagonist"); const rankings = useRankings(characteristics); return ( @@ -56,7 +67,7 @@ type GroupItem = CharacteristicsGroup["order"][number]; // A toy that needs a characteristic only shows for the tanks that have it function hasToy( { requires }: ToyRenderConfig, - characteristics: ComputedCharacteristics, + characteristics: ComputedCharacteristics ) { return requires === undefined || characteristics.has(requires); } diff --git a/packages/website/src/components/TankopediaGameModeAbilities.astro b/packages/website/src/components/TankopediaGameModeAbilities.astro new file mode 100644 index 000000000..a2ab7df13 --- /dev/null +++ b/packages/website/src/components/TankopediaGameModeAbilities.astro @@ -0,0 +1,143 @@ +--- +import { alias } from "@blitzkit/core"; +import { unwrapper } from "@blitzkit/i18n"; +import { api } from "../api/dynamic"; +import { Heading } from "./Heading"; +import { Text } from "./Text"; + +interface Props { + id: number; + locale: string; +} + +const { id, locale } = Astro.props; +const [gameDefinitions, consumableDefinitions, provisionDefinitions, tanks] = + await Promise.all([ + api.game(), + api.consumables(), + api.provisions(), + api.tanks(), + ]); +const strings = await api.strings(locale); +const unwrap = unwrapper(locale); +const tank = tanks.tanks[id]; +const roles = Object.entries(tank.roles); +--- + + + +{ + roles.length > 0 && ( +
+ {strings.tanks.game_modes.title} + +
+ {roles.map(([id, value]) => { + const gameMode = gameDefinitions.gameModes[id]; + const role = gameDefinitions.roles[value]; + const banner = alias("api", `/gamemodes/${id}/banner.webp`); + const provisions = role.provisions.map((id) => ({ + icon: alias("api", `/icons/provisions/${id}.webp`), + name: unwrap(provisionDefinitions.provisions[id].name!), + })); + const consumables = role.consumables.map((id) => ({ + icon: alias("api", `/icons/consumables/${id}.webp`), + name: unwrap(consumableDefinitions.consumables[id].name!), + })); + + return ( +
+
+ ); + })} +
+
+ ) +} diff --git a/packages/website/src/components/TankopediaGameModeAbilities/index.module.css b/packages/website/src/components/TankopediaGameModeAbilities/index.module.css deleted file mode 100644 index 2d023d358..000000000 --- a/packages/website/src/components/TankopediaGameModeAbilities/index.module.css +++ /dev/null @@ -1,64 +0,0 @@ -.section { - display: flex; - flex-direction: column; - align-items: center; - gap: var(--space-5); - padding: var(--space-4); - - .cards { - display: flex; - flex-wrap: wrap; - justify-content: center; - gap: var(--space-4); - width: 100%; - - .card { - width: 16rem; - height: 20rem; - display: flex; - flex: 0 0 auto; - flex-direction: column; - overflow: hidden; - border-radius: var(--space-3); - background-size: cover; - background-position: center; - - .banner { - flex: 1; - background-size: cover; - background-position: center; - } - - .info { - display: flex; - min-height: 6.125rem; - flex-direction: column; - align-items: center; - justify-content: center; - gap: var(--space-2); - padding: var(--space-3); - backdrop-filter: blur(4rem); - -webkit-backdrop-filter: blur(4rem); - - .abilities { - display: flex; - flex-direction: column; - align-items: flex-start; - - .ability { - display: flex; - align-items: center; - gap: var(--space-1); - white-space: nowrap; - - img { - width: 1.5em; - height: 1.5em; - object-fit: contain; - } - } - } - } - } - } -} diff --git a/packages/website/src/components/TankopediaGameModeAbilities/index.tsx b/packages/website/src/components/TankopediaGameModeAbilities/index.tsx deleted file mode 100644 index 723fa7c62..000000000 --- a/packages/website/src/components/TankopediaGameModeAbilities/index.tsx +++ /dev/null @@ -1,94 +0,0 @@ -import { alias } from "@blitzkit/core"; -import { api } from "../../api/dynamic"; -import { useDuelModules } from "../../hooks/useDuelModules"; -import { useStrings } from "../../hooks/useStrings"; -import { useUnwrapper } from "../../hooks/useUnwrapper"; -import { Heading } from "../Heading"; -import { LazyImage } from "../LazyImage"; -import { Text } from "../Text"; -import styles from "./index.module.css"; - -const [gameDefinitions, consumableDefinitions, provisionDefinitions, tanks] = - await Promise.all([ - api.game(), - api.consumables(), - api.provisions(), - api.tanks(), - ]); - -export function TankopediaGameModeAbilities() { - const unwrap = useUnwrapper(); - const strings = useStrings(); - const protagonist = useDuelModules("protagonist"); - const roles = Object.entries(protagonist.tank.roles); - - if (roles.length === 0) return null; - - return ( -
- {strings.tanks.game_modes.title} - -
- {roles.map(([id, value]) => { - const gameMode = gameDefinitions.gameModes[id]; - const role = gameDefinitions.roles[value]; - const banner = alias("api", `/gamemodes/${id}/banner.webp`); - - return ( -
-
- -
- - {unwrap(gameMode.name!)} - - -
- {role.provisions.map((id) => { - const provisions = provisionDefinitions.provisions[id]; - - return ( - - ); - })} - - {role.consumables.map((id) => { - const consumable = consumableDefinitions.consumables[id]; - - return ( - - ); - })} -
-
-
- ); - })} -
-
- ); -} - -function Ability({ icon, name }: { icon: string; name: string }) { - return ( - - - {name} - - ); -} diff --git a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css b/packages/website/src/components/TankopediaLoadout/index.module.css similarity index 58% rename from packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css rename to packages/website/src/components/TankopediaLoadout/index.module.css index f3dd69701..3f6af122f 100644 --- a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.module.css +++ b/packages/website/src/components/TankopediaLoadout/index.module.css @@ -1,15 +1,3 @@ -.sandbox { - flex-grow: 1; - - display: flex; - flex-direction: column; - gap: var(--space-4); - - @media (pointer: fine) { - padding-top: var(--space-4); - } -} - .loadout { display: flex; flex-direction: column; @@ -25,11 +13,8 @@ padding: var(--space-5); box-sizing: border-box; -} -@media (pointer: coarse) { - .sandbox, - .loadout { + @media (pointer: coarse) { &[data-tabbed="false"] { display: none; } diff --git a/packages/website/src/components/TankopediaLoadout/index.tsx b/packages/website/src/components/TankopediaLoadout/index.tsx index 603c6f5d8..7014de96d 100644 --- a/packages/website/src/components/TankopediaLoadout/index.tsx +++ b/packages/website/src/components/TankopediaLoadout/index.tsx @@ -1,9 +1,13 @@ import { MAX_SKILL_LEVEL } from "@blitzkit/core"; import { useCallback } from "react"; +import { api } from "../../api/dynamic"; +import { withErrorWrapper } from "../../hocs/withErrorWrapper"; +import { withLocale } from "../../hocs/withLocale"; import { useDuelModules } from "../../hooks/useDuelModules"; -import { Tankopedia } from "../../stores/tankopedia"; -import { selectModule } from "../../tankopedia/selectModule"; +import { Tankopedia, TankopediaTab } from "../../stores/tankopedia"; import { createAugments, toggleAugment } from "../../tankopedia/augments"; +import { selectModule } from "../../tankopedia/selectModule"; +import { LoadoutAugments } from "../LoadoutAugments"; import { LoadoutConsumables } from "../LoadoutConsumables"; import { LoadoutEquipment } from "../LoadoutEquipment"; import { LoadoutModules } from "../LoadoutModules"; @@ -11,11 +15,28 @@ import { LoadoutProvisions } from "../LoadoutProvisions"; import { LoadoutShells } from "../LoadoutShells"; import { LoadoutSkills } from "../LoadoutSkills"; import { LoadoutStatus } from "../LoadoutStatus"; -import { LoadoutAugments } from "../LoadoutAugments"; +import { ScrollerOrientation } from "../Scroller"; +import { ScrollerCurtains } from "../ScrollerCurtains"; +import styles from "./index.module.css"; + +const tanks = await api.tanks(); + +interface TankopediaLoadoutProps { + id: number; +} + +export const TankopediaLoadout = withErrorWrapper( + withLocale(Content), +); + +function Content({ id }: TankopediaLoadoutProps) { + Tankopedia.useInitialization(() => tanks.tanks[id]); + + const tabbed = Tankopedia.use((state) => state.tab === TankopediaTab.Loadout); -export function TankopediaLoadout() { return ( - <> +
+ @@ -24,7 +45,7 @@ export function TankopediaLoadout() { - +
); } diff --git a/packages/website/src/components/TankopediaSandbox/index.tsx b/packages/website/src/components/TankopediaSandbox/index.tsx index b3b69557a..80b8e30a6 100644 --- a/packages/website/src/components/TankopediaSandbox/index.tsx +++ b/packages/website/src/components/TankopediaSandbox/index.tsx @@ -1,8 +1,13 @@ import type { QuicklimeEvent } from "quicklime"; -import { Suspense, useEffect, useRef } from "react"; +import { Suspense, useEffect, useMemo, useRef } from "react"; +import { api } from "../../api/dynamic"; +import { defaultEqualizer } from "../../config/equalizer"; import { applyPitchYawLimits } from "../../core/blitz/applyPitchYawLimits"; import { modelTransformEvent } from "../../core/blitzkit/modelTransform"; import { Pose, poseEvent } from "../../core/blitzkit/pose"; +import { withErrorWrapper } from "../../hocs/withErrorWrapper"; +import { withLocale } from "../../hocs/withLocale"; +import { useCharacteristics } from "../../hooks/useCharacteristics"; import { useDuelModels } from "../../hooks/useDuelModels"; import { useDuelModules } from "../../hooks/useDuelModules"; import { useEquipment } from "../../hooks/useEquipment"; @@ -11,7 +16,6 @@ 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 { ArmorPlateDisplay } from "../ArmorPlateDisplay"; import { CanvasAutoClear } from "../CanvasAutoClear"; import { CanvasControl } from "../CanvasControl"; @@ -31,15 +35,22 @@ import { TankStaticArmor, type ThicknessRange } from "../TankStaticArmor"; import { Thicknesses } from "../Thicknesses"; import styles from "./index.module.css"; -interface TankSandboxProps { - thicknessRange: ThicknessRange; - antagonistCharacteristics: ComputedCharacteristics; +const tanks = await api.tanks(); + +interface TankopediaSandboxProps { + id: number; } -export function TankopediaSandbox({ - thicknessRange, - antagonistCharacteristics, -}: TankSandboxProps) { +export const TankopediaSandbox = withErrorWrapper( + withLocale(Sandbox) +); + +function Sandbox({ id }: TankopediaSandboxProps) { + const protagonistTank = tanks.tanks[id]; + + Tankopedia.useInitialization(() => protagonistTank); + + const equalize = Tankopedia.use((state) => state.environment.equalize); const mounted = useMounted(); const wrapper = useRef(null); const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122); @@ -50,6 +61,31 @@ export function TankopediaSandbox({ const { turret, gun } = useDuelModels("protagonist"); const display = Tankopedia.use((state) => state.loaders.display.loaded); + const antagonistCharacteristics = useCharacteristics("antagonist"); + const antagonistPenetration = antagonistCharacteristics.get( + "penetration" + ) as number; + + 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; + }, [equalize]); + function handlePointerDown() { window.addEventListener("pointermove", handlePointerMove); window.addEventListener("pointerup", handlePointerUp); @@ -74,7 +110,7 @@ export function TankopediaSandbox({ gun.pitch!, turret.yaw, hasImprovedVerticalStabilizer, - hasDownImprovedVerticalStabilizer, + hasDownImprovedVerticalStabilizer ); modelTransformEvent.dispatch({ pitch, yaw }); @@ -88,7 +124,7 @@ export function TankopediaSandbox({ 0, gun.pitch!, turret.yaw, - hasImprovedVerticalStabilizer, + hasImprovedVerticalStabilizer ); modelTransformEvent.dispatch({ pitch, yaw }); @@ -102,7 +138,7 @@ export function TankopediaSandbox({ 0, gun.pitch!, turret.yaw, - hasImprovedVerticalStabilizer, + hasImprovedVerticalStabilizer ); modelTransformEvent.dispatch({ pitch, yaw }); @@ -130,7 +166,7 @@ export function TankopediaSandbox({ modelTransformEvent.last!.yaw, gun.pitch!, turret.yaw, - hasImprovedVerticalStabilizer, + hasImprovedVerticalStabilizer ); modelTransformEvent.dispatch({ pitch, yaw }); @@ -176,9 +212,7 @@ export function TankopediaSandbox({ - +
@@ -194,7 +228,7 @@ function Content({ thicknessRange }: { thicknessRange: ThicknessRange }) { // this causes a re-render of the ENTIRE thing, maybe move this elsewhere? const revealed = Tankopedia.use((state) => state.revealed); const hideTankModelUnderArmor = TankopediaPersistent.use( - (state) => state.hideTankModelUnderArmor, + (state) => state.hideTankModelUnderArmor ); return ( diff --git a/packages/website/src/components/TankopediaTabs/index.tsx b/packages/website/src/components/TankopediaTabs/index.tsx index f3859ef72..124d8ade2 100644 --- a/packages/website/src/components/TankopediaTabs/index.tsx +++ b/packages/website/src/components/TankopediaTabs/index.tsx @@ -1,8 +1,23 @@ +import { api } from "../../api/dynamic"; +import { withErrorWrapper } from "../../hocs/withErrorWrapper"; +import { withLocale } from "../../hocs/withLocale"; import { Tankopedia, TankopediaTab } from "../../stores/tankopedia"; import { SegmentedControl } from "../SegmentedControl"; import styles from "./index.module.css"; -export function TankopediaTabs() { +const tanks = await api.tanks(); + +interface TankopediaTabsProps { + id: number; +} + +export const TankopediaTabs = withErrorWrapper( + withLocale(Content) +); + +function Content({ id }: TankopediaTabsProps) { + Tankopedia.useInitialization(() => tanks.tanks[id]); + const tab = Tankopedia.use((state) => state.tab); return ( diff --git a/packages/website/src/components/TankopediaTitle.astro b/packages/website/src/components/TankopediaTitle.astro new file mode 100644 index 000000000..905bec1e7 --- /dev/null +++ b/packages/website/src/components/TankopediaTitle.astro @@ -0,0 +1,39 @@ +--- +import { unwrapper } from "@blitzkit/i18n"; +import { api } from "../api/dynamic"; +import { Heading } from "./Heading"; + +interface Props { + id: number; + locale: string; +} + +const { id, locale } = Astro.props; +const tanks = await api.tanks(); +const tank = tanks.tanks[id]; +const unwrap = unwrapper(locale); +--- + + + +
+
+ {unwrap(tank.name)} +
+
diff --git a/packages/website/src/components/TankopediaTitle/index.module.css b/packages/website/src/components/TankopediaTitle/index.module.css deleted file mode 100644 index b6f89b044..000000000 --- a/packages/website/src/components/TankopediaTitle/index.module.css +++ /dev/null @@ -1,10 +0,0 @@ -.wrapper { - background-size: cover; - background-position: center; - - .content { - padding: var(--space-4); - - background: linear-gradient(90deg, var(--gray-1), transparent); - } -} diff --git a/packages/website/src/components/TankopediaTitle/index.tsx b/packages/website/src/components/TankopediaTitle/index.tsx deleted file mode 100644 index cc96cf43a..000000000 --- a/packages/website/src/components/TankopediaTitle/index.tsx +++ /dev/null @@ -1,23 +0,0 @@ -import { useDuelModules } from "../../hooks/useDuelModules"; -import { useUnwrapper } from "../../hooks/useUnwrapper"; -import { Heading } from "../Heading"; -import styles from "./index.module.css"; - -export function TankopediaTitle() { - const unwrap = useUnwrapper(); - - const protagonist = useDuelModules("protagonist"); - - return ( -
-
- {unwrap(protagonist.tank.name)} -
-
- ); -} diff --git a/packages/website/src/components/TankopediaVideos.astro b/packages/website/src/components/TankopediaVideos.astro new file mode 100644 index 000000000..e42f8cbb0 --- /dev/null +++ b/packages/website/src/components/TankopediaVideos.astro @@ -0,0 +1,108 @@ +--- +import { youtubers } from "@blitzkit/core"; +import { api } from "../api/dynamic"; +import { awaitableReviews } from "../core/awaitables/reviews"; +import { Heading } from "./Heading"; +import { Text } from "./Text"; +import { VerifiedIcon } from "./VerifiedIcon"; + +interface Props { + id: number; + locale: string; +} + +const { id, locale } = Astro.props; +const reviews = await awaitableReviews; +const strings = await api.strings(locale); +const videos = reviews.reviews[id]?.videos ?? []; +--- + + + +{ + videos.length > 0 && ( +
+ {strings.tanks.videos.title} + +
+ {videos.map((video) => { + const image = `https://i.ytimg.com/vi/${video.id}/hqdefault.jpg`; + const youtuber = youtubers.find( + (youtuber) => youtuber.id === video.author, + ); + + if (!youtuber) return null; + + return ( + + +
+ ) +} diff --git a/packages/website/src/components/TankopediaVideos/index.module.css b/packages/website/src/components/TankopediaVideos/index.module.css deleted file mode 100644 index 9c24e66c1..000000000 --- a/packages/website/src/components/TankopediaVideos/index.module.css +++ /dev/null @@ -1,48 +0,0 @@ -.section { - display: flex; - flex-direction: column; - align-items: center; - gap: var(--space-5); - padding: var(--space-4); - - .cards { - display: flex; - flex-wrap: wrap; - justify-content: center; - gap: var(--space-4); - width: 100%; - - .card { - display: flex; - flex: 0 0 auto; - flex-direction: column; - overflow: hidden; - border-radius: var(--space-3); - background-size: cover; - background-position: 0 18px; - color: inherit; - text-decoration: none; - - .thumbnail { - width: 16rem; - aspect-ratio: 16 / 9; - background-size: cover; - background-position: center; - } - - .info { - display: flex; - align-items: center; - justify-content: center; - gap: var(--space-1); - padding: var(--space-3); - backdrop-filter: blur(4rem); - -webkit-backdrop-filter: blur(4rem); - } - - &:hover .info { - text-decoration: underline; - } - } - } -} diff --git a/packages/website/src/components/TankopediaVideos/index.tsx b/packages/website/src/components/TankopediaVideos/index.tsx deleted file mode 100644 index 9baaf6d0f..000000000 --- a/packages/website/src/components/TankopediaVideos/index.tsx +++ /dev/null @@ -1,56 +0,0 @@ -import { youtubers } from "@blitzkit/core"; -import { awaitableReviews } from "../../core/awaitables/reviews"; -import { useDuelModules } from "../../hooks/useDuelModules"; -import { useStrings } from "../../hooks/useStrings"; -import { Heading } from "../Heading"; -import { Text } from "../Text"; -import { VerifiedIcon } from "../VerifiedIcon"; -import styles from "./index.module.css"; - -const reviews = await awaitableReviews; - -export function TankopediaVideos() { - const strings = useStrings(); - const protagonist = useDuelModules("protagonist"); - const videos = reviews.reviews[protagonist.tank.id]?.videos; - - if (videos === undefined || videos.length === 0) return null; - - return ( -
- {strings.tanks.videos.title} - -
- {videos.map((video) => { - const image = `https://i.ytimg.com/vi/${video.id}/hqdefault.jpg`; - const youtuber = youtubers.find( - (youtuber) => youtuber.id === video.author, - ); - - if (!youtuber) return null; - - return ( - - -
- ); -} 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 deleted file mode 100644 index 5b1cadd94..000000000 --- a/packages/website/src/pages/[...chunk_default]/[...locale]/tanks/[slug]/_index.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { useMemo } from "react"; -import { api } from "../../../../../api/dynamic"; -import { ScrollerOrientation } from "../../../../../components/Scroller"; -import { ScrollerCurtains } from "../../../../../components/ScrollerCurtains"; -import type { ThicknessRange } from "../../../../../components/TankStaticArmor"; -import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics"; -import { TankopediaGameModeAbilities } from "../../../../../components/TankopediaGameModeAbilities"; -import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout"; -import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox"; -import { TankopediaTabs } from "../../../../../components/TankopediaTabs"; -import { TankopediaTitle } from "../../../../../components/TankopediaTitle"; -import { TankopediaVideos } from "../../../../../components/TankopediaVideos"; -import { defaultEqualizer } from "../../../../../config/equalizer"; -import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper"; -import { withLocale } from "../../../../../hocs/withLocale"; -import { useCharacteristics } from "../../../../../hooks/useCharacteristics"; -import { Tankopedia, TankopediaTab } from "../../../../../stores/tankopedia"; -import styles from "./_index.module.css"; - -interface TankProps { - id: number; -} - -const tanks = await api.tanks(); - -export const Sandbox = withErrorWrapper( - withLocale(({ id }) => { - const protagonistTank = tanks.tanks[id]; - - 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 ( -
- - - - - - -
- ); - }), -); - -export const Loadout = withErrorWrapper( - withLocale(({ id }) => { - Tankopedia.useInitialization(() => tanks.tanks[id]); - - const tabbed = Tankopedia.use( - (state) => state.tab === TankopediaTab.Loadout, - ); - - 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 8f0caa582..89a1af38f 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 @@ -3,10 +3,16 @@ import { api } from "../../../../../api/dynamic"; import { mixStaticPaths } from "../../../../../astro/mixStaticPaths"; import ColorRanks from "../../../../../components/ColorRanks.astro"; import ColorScale from "../../../../../components/ColorScale.astro"; +import { TankopediaCharacteristics } from "../../../../../components/TankopediaCharacteristics"; +import TankopediaGameModeAbilities from "../../../../../components/TankopediaGameModeAbilities.astro"; +import { TankopediaLoadout } from "../../../../../components/TankopediaLoadout"; +import { TankopediaSandbox } from "../../../../../components/TankopediaSandbox"; +import { TankopediaTabs } from "../../../../../components/TankopediaTabs"; +import TankopediaTitle from "../../../../../components/TankopediaTitle.astro"; +import TankopediaVideos from "../../../../../components/TankopediaVideos.astro"; import { tools } from "../../../../../config/tools"; import BaseLayout from "../../../../../layouts/BaseLayout.astro"; import { getStaticPaths as _getStaticPaths } from "../index.astro"; -import { Loadout, Sandbox } from "./_index"; export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => { const tanks = await api.tanks(); @@ -31,12 +37,32 @@ const { id, locale } = Astro.props; display: flex; gap: var(--space-4); + + .sandbox { + flex-grow: 1; + + display: flex; + flex-direction: column; + gap: var(--space-4); + + @media (pointer: fine) { + padding-top: var(--space-4); + } + } }
- - +
+ + + + + + +
+ +