From 46374a7a26713478a6adb04108200d8e4fcf8884 Mon Sep 17 00:00:00 2001
From: tresabhi <43380238+tresabhi@users.noreply.github.com>
Date: Thu, 20 Mar 2025 12:33:36 -0500
Subject: [PATCH] feat: some hero code
---
.../tools/tankopedia/[id]/_index.tsx | 64 ----------
.../tools/tankopedia/[id]/index.astro | 110 -----------------
.../components/TankSandboxLoader.tsx | 17 ++-
.../Tankopedia/HeroSection/index.tsx | 115 ++++++++----------
.../src/core/blitzkit/tankToDuelMember.ts | 39 +++---
.../pages/[...locale]/tanks/[slug]/_index.tsx | 61 +++++++---
.../[...locale]/tanks/[slug]/_pre_index.astro | 30 +++++
.../[...locale]/tanks/[slug]/_pre_index.tsx | 26 ++++
.../[...locale]/tanks/[slug]/index.astro | 72 ++++++++++-
packages/website/src/stores/duel/index.ts | 46 +++----
.../website/src/stores/tankopediaEphemeral.ts | 34 +++---
11 files changed, 287 insertions(+), 327 deletions(-)
delete mode 100644 packages/preforged/tools/tankopedia/[id]/_index.tsx
delete mode 100644 packages/preforged/tools/tankopedia/[id]/index.astro
create mode 100644 packages/website/src/pages/[...locale]/tanks/[slug]/_pre_index.astro
create mode 100644 packages/website/src/pages/[...locale]/tanks/[slug]/_pre_index.tsx
diff --git a/packages/preforged/tools/tankopedia/[id]/_index.tsx b/packages/preforged/tools/tankopedia/[id]/_index.tsx
deleted file mode 100644
index 617382f94..000000000
--- a/packages/preforged/tools/tankopedia/[id]/_index.tsx
+++ /dev/null
@@ -1,64 +0,0 @@
-import { TankType } from '@blitzkit/core';
-import { PageWrapper } from '../../../../../components/PageWrapper';
-import { CalloutsSection } from '../../../../../components/Tankopedia/CalloutsSection';
-import { CharacteristicsSection } from '../../../../../components/Tankopedia/CharacteristicsSection';
-import { GameModeSection } from '../../../../../components/Tankopedia/GameModeSection';
-import { HeroSection } from '../../../../../components/Tankopedia/HeroSection';
-import { MetaSection } from '../../../../../components/Tankopedia/MetaSection';
-import { TechTreeSection } from '../../../../../components/Tankopedia/TechTreeSection';
-import { VideoSection } from '../../../../../components/Tankopedia/VideoSection';
-import { awaitableModelDefinitions } from '../../../../../core/awaitables/modelDefinitions';
-import { awaitableProvisionDefinitions } from '../../../../../core/awaitables/provisionDefinitions';
-import { awaitableTankDefinitions } from '../../../../../core/awaitables/tankDefinitions';
-import {
- LocaleProvider,
- type LocaleAcceptorProps,
-} from '../../../../../hooks/useLocale';
-import { App } from '../../../../../stores/app';
-import { Duel } from '../../../../../stores/duel';
-import { TankopediaEphemeral } from '../../../../../stores/tankopediaEphemeral';
-import { TankopediaPersistent } from '../../../../../stores/tankopediaPersistent';
-import type { MaybeSkeletonComponentProps } from '../../../../../types/maybeSkeletonComponentProps';
-
-type PageProps = MaybeSkeletonComponentProps &
- LocaleAcceptorProps & {
- id: number;
- };
-
-const [tankDefinitions, provisionDefinitions, modelDefinitions] =
- await Promise.all([
- awaitableTankDefinitions,
- awaitableProvisionDefinitions,
- awaitableModelDefinitions,
- ]);
-
-export function Page({ id, skeleton, locale }: PageProps) {
- const tank = tankDefinitions.tanks[id];
- const model = modelDefinitions.models[id];
-
- return (
-
-
-
-
-
-
-
-
-
- {tank.type === TankType.RESEARCHABLE && !tank.deprecated && (
-
- )}
-
-
-
-
-
-
-
-
-
- );
-}
diff --git a/packages/preforged/tools/tankopedia/[id]/index.astro b/packages/preforged/tools/tankopedia/[id]/index.astro
deleted file mode 100644
index f048dc556..000000000
--- a/packages/preforged/tools/tankopedia/[id]/index.astro
+++ /dev/null
@@ -1,110 +0,0 @@
----
-import {
- asset,
- createDefaultProvisions,
- createDefaultSkills,
- fetchEquipmentDefinitions,
- fetchModelDefinitions,
- fetchProvisionDefinitions,
- fetchSkillDefinitions,
- fetchTankDefinitions,
- TIER_ROMAN_NUMERALS,
-} from '@blitzkit/core';
-import { DEFAULT_LOCALE, unwrapper } from '@blitzkit/i18n';
-import { literals } from '@blitzkit/i18n/src/literals';
-import type { GetStaticPaths } from 'astro';
-import { tankCharacteristics } from '../../../../../core/blitzkit/tankCharacteristics';
-import { getStrings } from '../../../../../core/i18n/getStrings';
-import BaseLayout from '../../../../../layouts/BaseLayout.astro';
-import { genericDefaultEquipmentMatrix } from '../../../../../stores/duel/constants';
-import { getStaticPaths as parentGetStaticPaths } from '../index.astro';
-import { Page } from './_index';
-
-export const getStaticPaths = (async () => {
- const tankDefinitions = await fetchTankDefinitions();
- const parentPaths = parentGetStaticPaths();
-
- return Object.values(tankDefinitions.tanks)
- .map((tank) =>
- parentPaths.map((parent) => ({
- params: { ...parent.params, id: tank.id },
- })),
- )
- .flat();
-}) satisfies GetStaticPaths;
-
-const { id } = Astro.params;
-const locale = Astro.params.locale ?? DEFAULT_LOCALE;
-const strings = getStrings(locale);
-const tankDefinitions = await fetchTankDefinitions();
-const skillDefinitions = await fetchSkillDefinitions();
-const provisionDefinitions = await fetchProvisionDefinitions();
-const equipmentDefinitions = await fetchEquipmentDefinitions();
-const tankModelDefinitions = await fetchModelDefinitions();
-const tank = tankDefinitions.tanks[id];
-const tankModelDefinition = tankModelDefinitions.models[tank.id];
-const name = tank.name_full ?? tank.name;
-const unwrap = unwrapper(locale);
-const title = literals(strings.website.tools.tanks.tank_seo_title, [
- unwrap(name),
- TIER_ROMAN_NUMERALS[tank.tier],
- strings.common.nations_adjectives[
- tank.nation as keyof typeof strings.common.nations_adjectives
- ],
- strings.common.tank_class_short[tank.class],
- 'BlitzKit',
- strings.common.nations[tank.nation as keyof typeof strings.common.nations],
-]);
-const url = import.meta.env.SITE + Astro.url.pathname;
-const icon = asset(`icons/tanks/big/${id}.webp`);
-const turret = tank.turrets.at(-1)!;
-const gun = turret.guns.at(-1)!;
-const characteristics = tankCharacteristics(
- {
- tank,
- applyDynamicArmor: false,
- applyReactiveArmor: false,
- applySpallLiner: false,
- camouflage: true,
- consumables: [],
- crewSkills: createDefaultSkills(skillDefinitions),
- engine: tank.engines.at(-1)!,
- equipmentMatrix: genericDefaultEquipmentMatrix,
- turret,
- gun,
- provisions: createDefaultProvisions(tank, gun, provisionDefinitions),
- shell: gun.gun_type!.value.base.shells[0],
- stockEngine: tank.engines[0],
- stockGun: tank.turrets[0].guns[0],
- stockTurret: tank.turrets[0],
- stockTrack: tank.tracks[0],
- track: tank.tracks.at(-1)!,
- },
- { equipmentDefinitions, provisionDefinitions, tankModelDefinition },
-);
-const description = literals(strings.website.tools.tanks.tank_seo_description, [
- unwrap(name),
- Math.round(characteristics.dpm).toLocaleString(locale),
- Math.round(characteristics.damage).toLocaleString(locale),
- Math.round(characteristics.penetration).toLocaleString(locale),
- Math.round(characteristics.speedForwards).toLocaleString(locale),
- Math.round(characteristics.health).toLocaleString(locale),
-]);
----
-
-
{title}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandboxLoader.tsx b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandboxLoader.tsx
index 9f99f4855..28e98bfde 100644
--- a/packages/website/src/components/Tankopedia/HeroSection/components/TankSandboxLoader.tsx
+++ b/packages/website/src/components/Tankopedia/HeroSection/components/TankSandboxLoader.tsx
@@ -1,9 +1,8 @@
-import { asset } from '@blitzkit/core';
-import { Flex, type FlexProps, Progress } from '@radix-ui/themes';
+import { Box, Flex, type FlexProps, Progress } from '@radix-ui/themes';
import { useProgress } from '@react-three/drei';
type TankSandboxLoaderProps = Omit & {
- id: number;
+ id: string;
};
export function TankSandboxLoader({ id, ...props }: TankSandboxLoaderProps) {
@@ -11,9 +10,15 @@ export function TankSandboxLoader({ id, ...props }: TankSandboxLoaderProps) {
return (
-