mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 20:35:43 +01:00
cut html by 40%
This commit is contained in:
4 files changed
+22
-29
No files matched your search
@@ -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<HTMLDivElement>(null);
|
||||
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
||||
const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124);
|
||||
@@ -169,7 +169,7 @@ export function TankopediaSandbox({
|
||||
});
|
||||
}}
|
||||
>
|
||||
{!skeleton && <Content thicknessRange={thicknessRange} />}
|
||||
{mounted && <Content thicknessRange={thicknessRange} />}
|
||||
</SmartCanvas>
|
||||
|
||||
<TankSandboxLoader />
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export function useMounted() {
|
||||
const [mounted, setMounted] = useState(false);
|
||||
|
||||
useEffect(() => setMounted(true), []);
|
||||
|
||||
return mounted;
|
||||
}
|
||||
@@ -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<PageProps>(({ skeleton, id }) => {
|
||||
withLocale<PageProps>(({ id }) => {
|
||||
const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||
|
||||
Tankopedia.useInitialization(protagonistTank);
|
||||
|
||||
return (
|
||||
<div className={styles.page}>
|
||||
<Sandbox skeleton={skeleton} tier={protagonistTank.tier} />
|
||||
<Sandbox tier={protagonistTank.tier} />
|
||||
<Loadout />
|
||||
</div>
|
||||
);
|
||||
@@ -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 (
|
||||
<div className={styles.sandbox}>
|
||||
<TankopediaSandbox
|
||||
antagonistCharacteristics={antagonistCharacteristics}
|
||||
skeleton={skeleton}
|
||||
thicknessRange={thicknessRange}
|
||||
/>
|
||||
<TankopediaCharacteristics characteristics={characteristics} />
|
||||
@@ -102,14 +98,4 @@ function Sandbox({ skeleton, tier }: SandboxProps) {
|
||||
<TankopediaTabs />
|
||||
</div>
|
||||
);
|
||||
|
||||
// return (
|
||||
// <Scroller
|
||||
// id="main"
|
||||
// className={styles.sandbox}
|
||||
// data-tabbed={tabbed}
|
||||
// orientation={ScrollerOrientation.Vertical}
|
||||
// >
|
||||
// </Scroller>
|
||||
// );
|
||||
}
|
||||
@@ -30,7 +30,5 @@ const { id, locale } = Astro.props;
|
||||
<ColorScale color="cyan" alpha />
|
||||
<ColorScale color="green" />
|
||||
|
||||
<Page {id} {locale} client:only="react">
|
||||
<Page slot="fallback" {id} {locale} skeleton />
|
||||
</Page>
|
||||
<Page {id} {locale} client:load />
|
||||
</BaseLayout>
|
||||
Reference in new issue
Block a user