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 { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { useEquipment } from "../../hooks/useEquipment";
|
import { useEquipment } from "../../hooks/useEquipment";
|
||||||
import { useModel } from "../../hooks/useModel";
|
import { useModel } from "../../hooks/useModel";
|
||||||
|
import { useMounted } from "../../hooks/useMounted";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
import { TankopediaPersistent } from "../../stores/tankopediaPersistent";
|
||||||
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
||||||
import type { ComputedCharacteristics } from "../../types/characteristics";
|
import type { ComputedCharacteristics } from "../../types/characteristics";
|
||||||
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
|
||||||
import { ArmorPlateDisplay } from "../ArmorPlateDisplay";
|
import { ArmorPlateDisplay } from "../ArmorPlateDisplay";
|
||||||
import { CanvasAutoClear } from "../CanvasAutoClear";
|
import { CanvasAutoClear } from "../CanvasAutoClear";
|
||||||
import { CanvasControl } from "../CanvasControl";
|
import { CanvasControl } from "../CanvasControl";
|
||||||
@@ -31,16 +31,16 @@ import { TankStaticArmor, type ThicknessRange } from "../TankStaticArmor";
|
|||||||
import { Thicknesses } from "../Thicknesses";
|
import { Thicknesses } from "../Thicknesses";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
type TankSandboxProps = MaybeSkeletonComponentProps & {
|
interface TankSandboxProps {
|
||||||
thicknessRange: ThicknessRange;
|
thicknessRange: ThicknessRange;
|
||||||
antagonistCharacteristics: ComputedCharacteristics;
|
antagonistCharacteristics: ComputedCharacteristics;
|
||||||
};
|
}
|
||||||
|
|
||||||
export function TankopediaSandbox({
|
export function TankopediaSandbox({
|
||||||
skeleton,
|
|
||||||
thicknessRange,
|
thicknessRange,
|
||||||
antagonistCharacteristics,
|
antagonistCharacteristics,
|
||||||
}: TankSandboxProps) {
|
}: TankSandboxProps) {
|
||||||
|
const mounted = useMounted();
|
||||||
const wrapper = useRef<HTMLDivElement>(null);
|
const wrapper = useRef<HTMLDivElement>(null);
|
||||||
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
||||||
const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124);
|
const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124);
|
||||||
@@ -169,7 +169,7 @@ export function TankopediaSandbox({
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{!skeleton && <Content thicknessRange={thicknessRange} />}
|
{mounted && <Content thicknessRange={thicknessRange} />}
|
||||||
</SmartCanvas>
|
</SmartCanvas>
|
||||||
|
|
||||||
<TankSandboxLoader />
|
<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 { useAwait } from "../../../../../hooks/useAwait";
|
||||||
import { useCharacteristics } from "../../../../../hooks/useCharacteristics";
|
import { useCharacteristics } from "../../../../../hooks/useCharacteristics";
|
||||||
import { Tankopedia, TankopediaTab } from "../../../../../stores/tankopedia";
|
import { Tankopedia, TankopediaTab } from "../../../../../stores/tankopedia";
|
||||||
import type { MaybeSkeletonComponentProps } from "../../../../../types/maybeSkeletonComponentProps";
|
|
||||||
import styles from "./_index.module.css";
|
import styles from "./_index.module.css";
|
||||||
|
|
||||||
type PageProps = MaybeSkeletonComponentProps & {
|
interface PageProps {
|
||||||
id: number;
|
id: number;
|
||||||
};
|
}
|
||||||
|
|
||||||
type SandboxProps = MaybeSkeletonComponentProps & {
|
interface SandboxProps {
|
||||||
tier: number;
|
tier: number;
|
||||||
};
|
}
|
||||||
|
|
||||||
const tanks = await api.tanks();
|
const tanks = await api.tanks();
|
||||||
|
|
||||||
export const Page = withErrorWrapper(
|
export const Page = withErrorWrapper(
|
||||||
withLocale<PageProps>(({ skeleton, id }) => {
|
withLocale<PageProps>(({ id }) => {
|
||||||
const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`);
|
const protagonistTank = useAwait(() => api.tank(id), `tank-${id}`);
|
||||||
|
|
||||||
Tankopedia.useInitialization(protagonistTank);
|
Tankopedia.useInitialization(protagonistTank);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.page}>
|
<div className={styles.page}>
|
||||||
<Sandbox skeleton={skeleton} tier={protagonistTank.tier} />
|
<Sandbox tier={protagonistTank.tier} />
|
||||||
<Loadout />
|
<Loadout />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
@@ -61,7 +60,7 @@ function Loadout() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Sandbox({ skeleton, tier }: SandboxProps) {
|
function Sandbox({ tier }: SandboxProps) {
|
||||||
const protagonist = Tankopedia.use((state) => state.protagonist);
|
const protagonist = Tankopedia.use((state) => state.protagonist);
|
||||||
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
||||||
|
|
||||||
@@ -86,13 +85,10 @@ function Sandbox({ skeleton, tier }: SandboxProps) {
|
|||||||
return { value } satisfies ThicknessRange;
|
return { value } satisfies ThicknessRange;
|
||||||
}, [protagonist, equalize]);
|
}, [protagonist, equalize]);
|
||||||
|
|
||||||
const tabbed = Tankopedia.use((state) => state.tab === TankopediaTab.Sandbox);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.sandbox}>
|
<div className={styles.sandbox}>
|
||||||
<TankopediaSandbox
|
<TankopediaSandbox
|
||||||
antagonistCharacteristics={antagonistCharacteristics}
|
antagonistCharacteristics={antagonistCharacteristics}
|
||||||
skeleton={skeleton}
|
|
||||||
thicknessRange={thicknessRange}
|
thicknessRange={thicknessRange}
|
||||||
/>
|
/>
|
||||||
<TankopediaCharacteristics characteristics={characteristics} />
|
<TankopediaCharacteristics characteristics={characteristics} />
|
||||||
@@ -102,14 +98,4 @@ function Sandbox({ skeleton, tier }: SandboxProps) {
|
|||||||
<TankopediaTabs />
|
<TankopediaTabs />
|
||||||
</div>
|
</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="cyan" alpha />
|
||||||
<ColorScale color="green" />
|
<ColorScale color="green" />
|
||||||
|
|
||||||
<Page {id} {locale} client:only="react">
|
<Page {id} {locale} client:load />
|
||||||
<Page slot="fallback" {id} {locale} skeleton />
|
|
||||||
</Page>
|
|
||||||
</BaseLayout>
|
</BaseLayout>
|
||||||
Reference in new issue
Block a user