mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-21 12:53:56 +01:00
rename methods
This commit is contained in:
1 parent
ec161addab
commit
5f737d940d
111 files changed
+563
-413
No files matched your search
@@ -1,6 +1,5 @@
|
||||
import { GalleryList } from "../../../../components/Gallery/List";
|
||||
import { GallerySearch } from "../../../../components/Gallery/Search";
|
||||
import { PageWrapper } from "../../../../components/PageWrapper";
|
||||
import { AvatarsSearch } from "../../../../components/Avatars/Search";
|
||||
import { AvatarsList } from "../../../../components/AvatarsList";
|
||||
import {
|
||||
LocaleProvider,
|
||||
type LocaleAcceptorProps,
|
||||
@@ -20,9 +19,9 @@ export function Page({
|
||||
|
||||
function Content({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
return (
|
||||
<PageWrapper maxWidth="80rem" color="gold">
|
||||
<GallerySearch skeleton={skeleton} />
|
||||
<GalleryList skeleton={skeleton} />
|
||||
</PageWrapper>
|
||||
<>
|
||||
<AvatarsSearch skeleton={skeleton} />
|
||||
<AvatarsList skeleton={skeleton} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
---
|
||||
import { Section } from "../../../../components/Section";
|
||||
import ToolBanner from "../../../../components/ToolBanner.astro";
|
||||
import { tools } from "../../../../constants/tools";
|
||||
import ToolLayout from "../../../../layouts/ToolLayout.astro";
|
||||
import type { getStaticPaths } from "../index.astro";
|
||||
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export { getStaticPaths } from "../index.astro";
|
||||
@@ -9,8 +10,12 @@ export { getStaticPaths } from "../index.astro";
|
||||
const { locale } = Astro.props;
|
||||
---
|
||||
|
||||
<ToolLayout {locale} tool={tools.gallery}>
|
||||
<Page {locale} client:only="react">
|
||||
<Page {locale} skeleton slot="fallback" />
|
||||
</Page>
|
||||
</ToolLayout>
|
||||
<BaseLayout {locale} accent="purple">
|
||||
<ToolBanner {locale} tool={tools.avatars} slot="pre-app" />
|
||||
|
||||
<Section>
|
||||
<Page {locale} client:only="react">
|
||||
<Page {locale} skeleton slot="fallback" />
|
||||
</Page>
|
||||
</Section>
|
||||
</BaseLayout>
|
||||
@@ -20,11 +20,11 @@ const [
|
||||
skillDefinitions,
|
||||
tankDefinitions,
|
||||
] = await Promise.all([
|
||||
api.modelDefinitions(),
|
||||
api.equipmentDefinitions(),
|
||||
api.provisionDefinitions(),
|
||||
api.skillDefinitions(),
|
||||
api.tankDefinitions(),
|
||||
api.models(),
|
||||
api.equipment(),
|
||||
api.provisions(),
|
||||
api.skill(),
|
||||
api.tanks(),
|
||||
]);
|
||||
|
||||
export function Page({ locale }: LocaleAcceptorProps) {
|
||||
|
||||
@@ -17,8 +17,8 @@ import { Tankopedia } from "../../../../stores/tankopedia";
|
||||
import type { MaybeSkeletonComponentProps } from "../../../../types/maybeSkeletonComponentProps";
|
||||
|
||||
const [tankDefinitions, modelDefinitions] = await Promise.all([
|
||||
api.tankDefinitions(),
|
||||
api.modelDefinitions(),
|
||||
api.tanks(),
|
||||
api.models(),
|
||||
]);
|
||||
|
||||
const ids = Object.keys(tankDefinitions.tanks);
|
||||
|
||||
@@ -35,10 +35,8 @@ import { Mixer } from "../../../../stores/mixer";
|
||||
import { Tankopedia } from "../../../../stores/tankopedia";
|
||||
import type { MaybeSkeletonComponentProps } from "../../../../types/maybeSkeletonComponentProps";
|
||||
|
||||
const modelDefinition = await api
|
||||
.modelDefinitions()
|
||||
.then(({ models }) => models[1]);
|
||||
const tankDefinitions = await api.tankDefinitions();
|
||||
const modelDefinition = await api.models().then(({ models }) => models[1]);
|
||||
const tankDefinitions = await api.tanks();
|
||||
|
||||
export function Page({
|
||||
locale,
|
||||
|
||||
@@ -47,7 +47,7 @@ import {
|
||||
import { Session, type SessionTracking } from "../../../../stores/session";
|
||||
|
||||
const [tankDefinitions, averageDefinitions] = await Promise.all([
|
||||
api.tankDefinitions(),
|
||||
api.tanks(),
|
||||
awaitableAverageDefinitions,
|
||||
]);
|
||||
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
.page {
|
||||
max-height: 100dvh;
|
||||
flex-grow: 1;
|
||||
display: flex;
|
||||
|
||||
.sandbox {
|
||||
flex-grow: 1;
|
||||
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.loadout {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
gap: var(--space-5);
|
||||
padding: var(--space-5);
|
||||
|
||||
overflow-y: auto;
|
||||
|
||||
background-color: var(--gray-2);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +1,45 @@
|
||||
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 { GuideSection } from "../../../../../components/Tankopedia/GuideSection";
|
||||
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 { useMemo } from "react";
|
||||
import { api } from "../../../../../core/blitzkit/api";
|
||||
import {
|
||||
LocaleProvider,
|
||||
type LocaleAcceptorProps,
|
||||
} from "../../../../../hooks/useLocale";
|
||||
import { Duel } from "../../../../../stores/duel";
|
||||
import { withErrorWrapper } from "../../../../../hocs/withErrorWrapper";
|
||||
import { withLocale } from "../../../../../hocs/withLocale";
|
||||
import { useAwait } from "../../../../../hooks/useAwait";
|
||||
import { Tankopedia } from "../../../../../stores/tankopedia";
|
||||
import type { MaybeSkeletonComponentProps } from "../../../../../types/maybeSkeletonComponentProps";
|
||||
import type { TankGuide } from "../../../../../types/tankGuide";
|
||||
import styles from "./_index.module.css";
|
||||
|
||||
type PageProps = MaybeSkeletonComponentProps &
|
||||
LocaleAcceptorProps & {
|
||||
id: number;
|
||||
guide?: TankGuide;
|
||||
};
|
||||
|
||||
const [tankDefinitions, modelDefinitions] = await Promise.all([
|
||||
api.tankDefinitions(),
|
||||
api.modelDefinitions(),
|
||||
]);
|
||||
|
||||
export function Page({ id, skeleton, locale, guide }: PageProps) {
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
const model = modelDefinitions.models[id];
|
||||
|
||||
Tankopedia.useInitialization(model);
|
||||
Duel.useInitialization({ tank, model });
|
||||
|
||||
return (
|
||||
<LocaleProvider locale={locale}>
|
||||
<PageWrapper p="0" maxWidth="unset" color="purple" gap="9" pb="9">
|
||||
<HeroSection skeleton={skeleton} />
|
||||
<MetaSection />
|
||||
<CalloutsSection />
|
||||
{tank.type === TankType.TANK_TYPE_RESEARCHABLE && !tank.deprecated && (
|
||||
<TechTreeSection skeleton={skeleton} />
|
||||
)}
|
||||
<CharacteristicsSection skeleton={skeleton} />
|
||||
<GameModeSection />
|
||||
{guide && <GuideSection guide={guide} />}
|
||||
<VideoSection skeleton={skeleton} />
|
||||
</PageWrapper>
|
||||
</LocaleProvider>
|
||||
);
|
||||
interface PageProps {
|
||||
id: number;
|
||||
}
|
||||
|
||||
export const Page = withErrorWrapper(
|
||||
withLocale<PageProps>(({ id }) => {
|
||||
const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||
|
||||
Tankopedia.useInitialization(protagonistTank);
|
||||
|
||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||
const protagonistEquipment = useEquipment(protagonistTank.tank!);
|
||||
|
||||
const { characteristics, parameters } = useMemo(
|
||||
() =>
|
||||
computeCharacteristics(
|
||||
protagonistTank,
|
||||
protagonistEquipment,
|
||||
protagonist,
|
||||
),
|
||||
[protagonist],
|
||||
);
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<div className={styles.loadout}>
|
||||
<TankopediaLoadout characteristics={characteristics} />
|
||||
</div>
|
||||
|
||||
<div className={styles.sandbox}>
|
||||
<TankopediaSandbox parameters={parameters} />
|
||||
<TankopediaCharacteristics characteristics={characteristics} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}),
|
||||
);
|
||||
+14
-113
@@ -1,130 +1,31 @@
|
||||
---
|
||||
import { AstroSeo } from "@astrolib/seo";
|
||||
import {
|
||||
alias,
|
||||
assertSecret,
|
||||
createDefaultProvisions,
|
||||
createDefaultSkills,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
} from "@blitzkit/core";
|
||||
import { unwrapper } from "@blitzkit/i18n";
|
||||
import { literals } from "@blitzkit/i18n/src/literals";
|
||||
import { load } from "cheerio";
|
||||
import { api } from "../../../../../core/blitzkit/api";
|
||||
import { mixStaticPaths } from "../../../../../core/blitzkit/mixStaticPaths";
|
||||
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 type { TankGuide } from "../../../../../types/tankGuide";
|
||||
import "@radix-ui/colors/violet-dark.css";
|
||||
import { api } from "../../../../api/dynamic";
|
||||
import { mixStaticPaths } from "../../../../astro/mixStaticPaths";
|
||||
import ColorScale from "../../../../components/ColorScale.astro";
|
||||
import BaseLayout from "../../../../layouts/BaseLayout.astro";
|
||||
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
||||
import { Page } from "./_index";
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
const tankDefinitions = await api.tankDefinitions();
|
||||
const { list } = await api.tankList();
|
||||
|
||||
return Object.values(tankDefinitions.tanks).map((tank) => ({
|
||||
return list.map((tank) => ({
|
||||
params: { slug: tank.slug },
|
||||
props: { id: tank.id },
|
||||
}));
|
||||
});
|
||||
|
||||
const { id, locale } = Astro.props;
|
||||
const strings = getStrings(locale);
|
||||
const tankDefinitions = await api.tankDefinitions();
|
||||
const skillDefinitions = await api.skillDefinitions();
|
||||
const provisionDefinitions = await api.provisionDefinitions();
|
||||
const equipmentDefinitions = await api.equipmentDefinitions();
|
||||
const tankModelDefinitions = await api.modelDefinitions();
|
||||
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
const tankModelDefinition = tankModelDefinitions.models[tank.id];
|
||||
const unwrap = unwrapper(locale);
|
||||
const title = literals(strings.website.tools.tankopedia.tank_seo_title, {
|
||||
name: unwrap(tank.name!),
|
||||
tier: TIER_ROMAN_NUMERALS[tank.tier],
|
||||
nationality:
|
||||
strings.common.nations_adjectives[
|
||||
tank.nation as keyof typeof strings.common.nations_adjectives
|
||||
],
|
||||
class: strings.common.tank_class_short[tank.class],
|
||||
website: "BlitzKit",
|
||||
});
|
||||
const url = import.meta.env.SITE + Astro.url.pathname;
|
||||
|
||||
const icon = alias("api", `/tanks/${id}/icons/big.webp`);
|
||||
const turret = tank.turrets.at(-1)!;
|
||||
const gun = turret.guns.at(-1)!;
|
||||
const shell = gun.shells[0];
|
||||
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,
|
||||
stockEngine: tank.engines[0],
|
||||
stockGun: tank.turrets[0].guns[0],
|
||||
stockTurret: tank.turrets[0],
|
||||
stockTrack: tank.tracks[0],
|
||||
track: tank.tracks.at(-1)!,
|
||||
assaultDistance: 0,
|
||||
equalize: false,
|
||||
},
|
||||
{ equipmentDefinitions, provisionDefinitions, tankModelDefinition },
|
||||
);
|
||||
const description = literals(
|
||||
strings.website.tools.tankopedia.tank_seo_description,
|
||||
{
|
||||
name: unwrap(tank.name!),
|
||||
dpm: Math.round(characteristics.dpm).toLocaleString(locale),
|
||||
alpha: Math.round(characteristics.damage).toLocaleString(locale),
|
||||
penetration: Math.round(characteristics.penetration).toLocaleString(locale),
|
||||
speed: Math.round(characteristics.speedForwards).toLocaleString(locale),
|
||||
health: Math.round(characteristics.health).toLocaleString(locale),
|
||||
},
|
||||
);
|
||||
|
||||
const guideUrl = `${assertSecret(import.meta.env.PUBLIC_GUIDE_WEBSITE)}/${tank.slug}`;
|
||||
let guide: TankGuide | undefined = undefined;
|
||||
const guideResponse = await fetch(guideUrl);
|
||||
|
||||
if (guideResponse.ok) {
|
||||
const $ = await guideResponse.text().then(load);
|
||||
const description = $(".entry-content p").first().text();
|
||||
const image = $(".entry-content img").first().attr("src")?.toString();
|
||||
|
||||
if (description !== undefined || image !== undefined) {
|
||||
guide = {
|
||||
url: guideUrl,
|
||||
description,
|
||||
image,
|
||||
};
|
||||
}
|
||||
}
|
||||
---
|
||||
|
||||
<AstroSeo
|
||||
{title}
|
||||
{description}
|
||||
openGraph={{ title, description, images: [{ url: icon }], url }}
|
||||
/>
|
||||
<BaseLayout {locale} accent="violet">
|
||||
<ColorScale color="amber" alpha />
|
||||
|
||||
<meta name="twitter:title" content={title} />
|
||||
<meta name="twitter:description" content={description} />
|
||||
<meta name="twitter:card" content="summary" />
|
||||
<meta name="twitter:image:src" content={icon} />
|
||||
<ColorScale color="red" />
|
||||
<ColorScale color="orange" />
|
||||
<ColorScale color="amber" />
|
||||
<ColorScale color="jade" />
|
||||
|
||||
<BaseLayout {locale} integrated>
|
||||
<Page {locale} id={id} {guide} client:only="react">
|
||||
<Page {locale} id={id} {guide} skeleton slot="fallback" />
|
||||
</Page>
|
||||
<Page {locale} {id} client:load />
|
||||
</BaseLayout>
|
||||
+2
-2
@@ -5,7 +5,7 @@ import LegacyRedirect from "../../../../../../layouts/LegacyRedirect.astro";
|
||||
import { getStaticPaths as _getStaticPaths } from "../index.astro";
|
||||
|
||||
export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
const tankDefinitions = await api.tankDefinitions();
|
||||
const tankDefinitions = await api.tanks();
|
||||
|
||||
return Object.values(tankDefinitions.tanks).map(({ id }) => ({
|
||||
params: { id },
|
||||
@@ -14,7 +14,7 @@ export const getStaticPaths = mixStaticPaths(_getStaticPaths, async () => {
|
||||
|
||||
const { id } = Astro.params;
|
||||
const { locale } = Astro.props;
|
||||
const tankDefinitions = await api.tankDefinitions();
|
||||
const tankDefinitions = await api.tanks();
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
---
|
||||
|
||||
|
||||
Reference in new issue
Block a user