mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-29 04:44:23 +01:00
antaognsist sleector
This commit is contained in:
14 files changed
+203
-115
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
import { environmentConfig } from "@blitzkit/core";
|
import { environmentConfig } from "@blitzkit/core";
|
||||||
|
|
||||||
|
// TODO: remove the need for a `/ in the front of all paths
|
||||||
export function alias(alias: string, path: string) {
|
export function alias(alias: string, path: string) {
|
||||||
const environment = environmentConfig();
|
const environment = environmentConfig();
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
|
import type { TankDefinition } from "@blitzkit/protos";
|
||||||
import { PlusIcon, TrashIcon } from "@radix-ui/react-icons";
|
import { PlusIcon, TrashIcon } from "@radix-ui/react-icons";
|
||||||
import { useMemo, useState } from "react";
|
import { useCallback, useMemo } from "react";
|
||||||
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
||||||
import { withLocale } from "../../hocs/withLocale";
|
import { withLocale } from "../../hocs/withLocale";
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
@@ -11,9 +12,8 @@ import {
|
|||||||
import { resolveTankModules } from "../../tankopedia/resolveTankModules";
|
import { resolveTankModules } from "../../tankopedia/resolveTankModules";
|
||||||
import { Button } from "../Button";
|
import { Button } from "../Button";
|
||||||
import { Checkbox } from "../Checkbox";
|
import { Checkbox } from "../Checkbox";
|
||||||
import { Dialog } from "../Dialog";
|
|
||||||
import { SegmentedControl } from "../SegmentedControl";
|
import { SegmentedControl } from "../SegmentedControl";
|
||||||
import { TankSearchResults } from "../TankSearchResults";
|
import { TankSearchDialog } from "../TankSearchDialog";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
export const CompareControls = withLocale(Content);
|
export const CompareControls = withLocale(Content);
|
||||||
@@ -22,7 +22,20 @@ function Content() {
|
|||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
const deltaMode = ComparePersistent.use((state) => state.deltaMode);
|
const deltaMode = ComparePersistent.use((state) => state.deltaMode);
|
||||||
const syncShells = CompareEphemeral.use((state) => state.syncShells);
|
const syncShells = CompareEphemeral.use((state) => state.syncShells);
|
||||||
const [adding, setAdding] = useState(false);
|
|
||||||
|
const handleAdd = useCallback((tank: TankDefinition) => {
|
||||||
|
CompareEphemeral.mutate((draft) => {
|
||||||
|
draft.members.push(tankToCompareMember(tank));
|
||||||
|
draft.sorting.by = null;
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleAddAll = useCallback((tanks: TankDefinition[]) => {
|
||||||
|
CompareEphemeral.mutate((draft) => {
|
||||||
|
draft.members.push(...tanks.map(tankToCompareMember));
|
||||||
|
draft.sorting.by = null;
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const deltaOptions = useMemo<{ value: DeltaMode; label: string }[]>(
|
const deltaOptions = useMemo<{ value: DeltaMode; label: string }[]>(
|
||||||
() => [
|
() => [
|
||||||
@@ -36,46 +49,17 @@ function Content() {
|
|||||||
return (
|
return (
|
||||||
<div className={styles.controls}>
|
<div className={styles.controls}>
|
||||||
<div className={styles.group}>
|
<div className={styles.group}>
|
||||||
<Dialog.Root open={adding} onOpenChange={setAdding}>
|
<TankSearchDialog
|
||||||
<Dialog.Trigger asChild>
|
title={strings.compare.add.title}
|
||||||
|
description={strings.compare.add.description}
|
||||||
|
onSelect={handleAdd}
|
||||||
|
onSelectAll={handleAddAll}
|
||||||
|
>
|
||||||
<Button variant="soft">
|
<Button variant="soft">
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
{strings.compare.add.button}
|
{strings.compare.add.button}
|
||||||
</Button>
|
</Button>
|
||||||
</Dialog.Trigger>
|
</TankSearchDialog>
|
||||||
|
|
||||||
<Dialog.Portal>
|
|
||||||
<Dialog.Overlay />
|
|
||||||
<Dialog.Content>
|
|
||||||
<Dialog.Header>
|
|
||||||
<Dialog.Title>{strings.compare.add.title}</Dialog.Title>
|
|
||||||
<Dialog.Description>
|
|
||||||
{strings.compare.add.description}
|
|
||||||
</Dialog.Description>
|
|
||||||
</Dialog.Header>
|
|
||||||
|
|
||||||
<Dialog.Body>
|
|
||||||
<TankSearchResults
|
|
||||||
compact
|
|
||||||
onSelect={(tank) => {
|
|
||||||
CompareEphemeral.mutate((draft) => {
|
|
||||||
draft.members.push(tankToCompareMember(tank));
|
|
||||||
draft.sorting.by = null;
|
|
||||||
});
|
|
||||||
setAdding(false);
|
|
||||||
}}
|
|
||||||
onSelectAll={(tanks) => {
|
|
||||||
CompareEphemeral.mutate((draft) => {
|
|
||||||
draft.members.push(...tanks.map(tankToCompareMember));
|
|
||||||
draft.sorting.by = null;
|
|
||||||
});
|
|
||||||
setAdding(false);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Dialog.Body>
|
|
||||||
</Dialog.Content>
|
|
||||||
</Dialog.Portal>
|
|
||||||
</Dialog.Root>
|
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="soft"
|
variant="soft"
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import locales from "@blitzkit/i18n/locales.json";
|
import locales from "@blitzkit/i18n/locales.json";
|
||||||
|
import type { TankDefinition } from "@blitzkit/protos";
|
||||||
import { ExternalLinkIcon, LoopIcon, TrashIcon } from "@radix-ui/react-icons";
|
import { ExternalLinkIcon, LoopIcon, TrashIcon } from "@radix-ui/react-icons";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback } from "react";
|
||||||
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
import { tankToCompareMember } from "../../core/blitzkit/tankToCompareMember";
|
||||||
import { useLocale } from "../../hooks/useLocale";
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
import { CompareEphemeral } from "../../stores/compareEphemeral";
|
import { CompareEphemeral } from "../../stores/compareEphemeral";
|
||||||
import { Dialog } from "../Dialog";
|
|
||||||
import { IconButton } from "../IconButton";
|
import { IconButton } from "../IconButton";
|
||||||
import { TankSearchResults } from "../TankSearchResults";
|
import { TankSearchDialog } from "../TankSearchDialog";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
interface CompareTankControlProps {
|
interface CompareTankControlProps {
|
||||||
@@ -18,7 +18,6 @@ interface CompareTankControlProps {
|
|||||||
export function CompareTankControl({ index, slug }: CompareTankControlProps) {
|
export function CompareTankControl({ index, slug }: CompareTankControlProps) {
|
||||||
const locale = useLocale();
|
const locale = useLocale();
|
||||||
const strings = useStrings();
|
const strings = useStrings();
|
||||||
const [swapping, setSwapping] = useState(false);
|
|
||||||
|
|
||||||
const handleRemove = useCallback(() => {
|
const handleRemove = useCallback(() => {
|
||||||
CompareEphemeral.mutate((draft) => {
|
CompareEphemeral.mutate((draft) => {
|
||||||
@@ -27,44 +26,31 @@ export function CompareTankControl({ index, slug }: CompareTankControlProps) {
|
|||||||
});
|
});
|
||||||
}, [index]);
|
}, [index]);
|
||||||
|
|
||||||
|
const handleSwap = useCallback(
|
||||||
|
(tank: TankDefinition) => {
|
||||||
|
CompareEphemeral.mutate((draft) => {
|
||||||
|
draft.members[index] = tankToCompareMember(tank);
|
||||||
|
draft.sorting.by = null;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
[index],
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.controls}>
|
<div className={styles.controls}>
|
||||||
<IconButton variant="ghost" size="minor" onClick={handleRemove}>
|
<IconButton variant="ghost" size="minor" onClick={handleRemove}>
|
||||||
<TrashIcon />
|
<TrashIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
|
|
||||||
<Dialog.Root open={swapping} onOpenChange={setSwapping}>
|
<TankSearchDialog
|
||||||
<Dialog.Trigger asChild>
|
title={strings.compare.swap_dialog.title}
|
||||||
|
description={strings.compare.swap_dialog.description}
|
||||||
|
onSelect={handleSwap}
|
||||||
|
>
|
||||||
<IconButton variant="ghost" size="minor">
|
<IconButton variant="ghost" size="minor">
|
||||||
<LoopIcon />
|
<LoopIcon />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Dialog.Trigger>
|
</TankSearchDialog>
|
||||||
|
|
||||||
<Dialog.Portal>
|
|
||||||
<Dialog.Overlay />
|
|
||||||
<Dialog.Content>
|
|
||||||
<Dialog.Header>
|
|
||||||
<Dialog.Title>{strings.compare.swap_dialog.title}</Dialog.Title>
|
|
||||||
<Dialog.Description>
|
|
||||||
{strings.compare.swap_dialog.description}
|
|
||||||
</Dialog.Description>
|
|
||||||
</Dialog.Header>
|
|
||||||
|
|
||||||
<Dialog.Body>
|
|
||||||
<TankSearchResults
|
|
||||||
compact
|
|
||||||
onSelect={(tank) => {
|
|
||||||
CompareEphemeral.mutate((draft) => {
|
|
||||||
draft.members[index] = tankToCompareMember(tank);
|
|
||||||
draft.sorting.by = null;
|
|
||||||
});
|
|
||||||
setSwapping(false);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Dialog.Body>
|
|
||||||
</Dialog.Content>
|
|
||||||
</Dialog.Portal>
|
|
||||||
</Dialog.Root>
|
|
||||||
|
|
||||||
<IconButton
|
<IconButton
|
||||||
variant="ghost"
|
variant="ghost"
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<script is:inline>
|
||||||
|
// Runs before hydration so fullscreen controls never pop in late
|
||||||
|
document.documentElement.style.setProperty(
|
||||||
|
"--fullscreen-display",
|
||||||
|
document.fullscreenEnabled ? "flex" : "none",
|
||||||
|
);
|
||||||
|
</script>
|
||||||
@@ -5,18 +5,15 @@ import type {
|
|||||||
TurretDefinition,
|
TurretDefinition,
|
||||||
} from "@blitzkit/protos";
|
} from "@blitzkit/protos";
|
||||||
import { CaretUpIcon } from "@radix-ui/react-icons";
|
import { CaretUpIcon } from "@radix-ui/react-icons";
|
||||||
import { useState } from "react";
|
|
||||||
import { api } from "../../api/dynamic";
|
import { api } from "../../api/dynamic";
|
||||||
import { useStrings } from "../../hooks/useStrings";
|
|
||||||
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
import type { MaybeSkeletonComponentProps } from "../../types/maybeSkeletonComponentProps";
|
||||||
import { Button } from "../Button";
|
import { Button } from "../Button";
|
||||||
import { Dialog } from "../Dialog";
|
|
||||||
import { Discriminator } from "../Discriminator";
|
import { Discriminator } from "../Discriminator";
|
||||||
import { IconButton } from "../IconButton";
|
import { IconButton } from "../IconButton";
|
||||||
import { LazyImage } from "../LazyImage";
|
import { LazyImage } from "../LazyImage";
|
||||||
import { Popover } from "../Popover";
|
import { Popover } from "../Popover";
|
||||||
import { Skeleton } from "../Skeleton";
|
import { Skeleton } from "../Skeleton";
|
||||||
import { TankSearchResults } from "../TankSearchResults";
|
import { TankSearchDialog } from "../TankSearchDialog";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
const tankDefinitions = await api.tanks();
|
const tankDefinitions = await api.tanks();
|
||||||
@@ -39,8 +36,6 @@ export function MixerModuleChooser({
|
|||||||
turret,
|
turret,
|
||||||
gun,
|
gun,
|
||||||
}: MixerModuleChooserProps) {
|
}: MixerModuleChooserProps) {
|
||||||
const strings = useStrings();
|
|
||||||
const [open, setOpen] = useState(false);
|
|
||||||
const tankDefinition = tankDefinitions.tanks[tank];
|
const tankDefinition = tankDefinitions.tanks[tank];
|
||||||
const turretDefinition = tankDefinition.turrets.find((t) => t.id === turret);
|
const turretDefinition = tankDefinition.turrets.find((t) => t.id === turret);
|
||||||
const gunDefinition = turretDefinition?.guns.find((g) => g.id === gun);
|
const gunDefinition = turretDefinition?.guns.find((g) => g.id === gun);
|
||||||
@@ -52,8 +47,7 @@ export function MixerModuleChooser({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["mixer-module-chooser"]}>
|
<div className={styles["mixer-module-chooser"]}>
|
||||||
<Dialog.Root open={open} onOpenChange={setOpen}>
|
<TankSearchDialog onSelect={onSelect}>
|
||||||
<Dialog.Trigger asChild>
|
|
||||||
<Button
|
<Button
|
||||||
variant="surface"
|
variant="surface"
|
||||||
listChild="horizontal"
|
listChild="horizontal"
|
||||||
@@ -75,29 +69,7 @@ export function MixerModuleChooser({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Button>
|
</Button>
|
||||||
</Dialog.Trigger>
|
</TankSearchDialog>
|
||||||
|
|
||||||
<Dialog.Portal>
|
|
||||||
<Dialog.Overlay />
|
|
||||||
<Dialog.Content>
|
|
||||||
<Dialog.Header>
|
|
||||||
<Dialog.Title>
|
|
||||||
{strings.website.common.tank_search.select_dialog_title}
|
|
||||||
</Dialog.Title>
|
|
||||||
</Dialog.Header>
|
|
||||||
|
|
||||||
<Dialog.Body>
|
|
||||||
<TankSearchResults
|
|
||||||
compact
|
|
||||||
onSelect={(tank) => {
|
|
||||||
onSelect?.(tank);
|
|
||||||
setOpen(false);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</Dialog.Body>
|
|
||||||
</Dialog.Content>
|
|
||||||
</Dialog.Portal>
|
|
||||||
</Dialog.Root>
|
|
||||||
|
|
||||||
{subSelector && (
|
{subSelector && (
|
||||||
<Popover.Root>
|
<Popover.Root>
|
||||||
|
|||||||
@@ -1,13 +1,19 @@
|
|||||||
import { Canvas, type CanvasProps } from "@react-three/fiber";
|
import { Canvas, type CanvasProps } from "@react-three/fiber";
|
||||||
import { useRef } from "react";
|
import { useImperativeHandle, useRef, type Ref } from "react";
|
||||||
import { useOnScreen } from "../../hooks/useOnScreen";
|
import { useOnScreen } from "../../hooks/useOnScreen";
|
||||||
import { classNames } from "../../ui/classNames";
|
import { classNames } from "../../ui/classNames";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
export function SmartCanvas({ className, ...props }: CanvasProps) {
|
interface SmartCanvasProps extends Omit<CanvasProps, "ref"> {
|
||||||
|
ref?: Ref<HTMLCanvasElement>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function SmartCanvas({ className, ref, ...props }: SmartCanvasProps) {
|
||||||
const canvas = useRef<HTMLCanvasElement>(null!);
|
const canvas = useRef<HTMLCanvasElement>(null!);
|
||||||
const onScreen = useOnScreen(canvas);
|
const onScreen = useOnScreen(canvas);
|
||||||
|
|
||||||
|
useImperativeHandle(ref, () => canvas.current, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames(styles.aligner, className)}>
|
<div className={classNames(styles.aligner, className)}>
|
||||||
<div className={styles.canvas}>
|
<div className={styles.canvas}>
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
.filters {
|
||||||
|
overflow-x: auto;
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
import type { TankDefinition } from "@blitzkit/protos";
|
||||||
|
import { useCallback, useState, type ReactNode } from "react";
|
||||||
|
import { useLocale } from "../../hooks/useLocale";
|
||||||
|
import { useStrings } from "../../hooks/useStrings";
|
||||||
|
import { Dialog } from "../Dialog";
|
||||||
|
import { ScrollerCurtains } from "../ScrollerCurtains";
|
||||||
|
import { TankSearchBar } from "../TankSearchBar";
|
||||||
|
import { TankSearchFilters } from "../TankSearchFilters";
|
||||||
|
import { TankSearchResults } from "../TankSearchResults";
|
||||||
|
import styles from "./index.module.css";
|
||||||
|
|
||||||
|
interface TankSearchDialogProps {
|
||||||
|
// the trigger, passed to Dialog.Trigger with asChild
|
||||||
|
children: ReactNode;
|
||||||
|
title?: string;
|
||||||
|
description?: string;
|
||||||
|
onSelect: (tank: TankDefinition) => void;
|
||||||
|
onSelectAll?: (tanks: TankDefinition[]) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function TankSearchDialog({
|
||||||
|
children,
|
||||||
|
title,
|
||||||
|
description,
|
||||||
|
onSelect,
|
||||||
|
onSelectAll,
|
||||||
|
}: TankSearchDialogProps) {
|
||||||
|
const locale = useLocale();
|
||||||
|
const strings = useStrings();
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
|
||||||
|
const handleSelect = useCallback(
|
||||||
|
(tank: TankDefinition) => {
|
||||||
|
onSelect(tank);
|
||||||
|
setOpen(false);
|
||||||
|
},
|
||||||
|
[onSelect],
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleSelectAll = useCallback(
|
||||||
|
(tanks: TankDefinition[]) => {
|
||||||
|
onSelectAll!(tanks);
|
||||||
|
setOpen(false);
|
||||||
|
},
|
||||||
|
[onSelectAll],
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog.Root open={open} onOpenChange={setOpen}>
|
||||||
|
<Dialog.Trigger asChild>{children}</Dialog.Trigger>
|
||||||
|
|
||||||
|
<Dialog.Portal>
|
||||||
|
<Dialog.Overlay />
|
||||||
|
<Dialog.Content>
|
||||||
|
<Dialog.Header>
|
||||||
|
<Dialog.Title>
|
||||||
|
{title ?? strings.website.common.tank_search.select_dialog_title}
|
||||||
|
</Dialog.Title>
|
||||||
|
|
||||||
|
{description && (
|
||||||
|
<Dialog.Description>{description}</Dialog.Description>
|
||||||
|
)}
|
||||||
|
</Dialog.Header>
|
||||||
|
|
||||||
|
<Dialog.Body>
|
||||||
|
<TankSearchBar locale={locale} onSelect={handleSelect} />
|
||||||
|
|
||||||
|
<div className={styles.filters}>
|
||||||
|
<ScrollerCurtains />
|
||||||
|
<TankSearchFilters locale={locale} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<TankSearchResults
|
||||||
|
locale={locale}
|
||||||
|
compact
|
||||||
|
onSelect={handleSelect}
|
||||||
|
onSelectAll={onSelectAll && handleSelectAll}
|
||||||
|
/>
|
||||||
|
</Dialog.Body>
|
||||||
|
</Dialog.Content>
|
||||||
|
</Dialog.Portal>
|
||||||
|
</Dialog.Root>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import { alias, romanize, uniqueGuns } from "@blitzkit/core";
|
import { alias, romanize, uniqueGuns } from "@blitzkit/core";
|
||||||
import { literals } from "@blitzkit/i18n";
|
import { literals } from "@blitzkit/i18n";
|
||||||
import { useMemo } from "react";
|
import type { TankDefinition } from "@blitzkit/protos";
|
||||||
|
import { useCallback, useMemo } from "react";
|
||||||
import { useAbsoluteDisplay } from "../../hooks/useAbsoluteDisplay";
|
import { useAbsoluteDisplay } from "../../hooks/useAbsoluteDisplay";
|
||||||
import { useDuelModules } from "../../hooks/useDuelModules";
|
import { useDuelModules } from "../../hooks/useDuelModules";
|
||||||
import { useEquipment } from "../../hooks/useEquipment";
|
import { useEquipment } from "../../hooks/useEquipment";
|
||||||
@@ -8,12 +9,13 @@ import { useStrings } from "../../hooks/useStrings";
|
|||||||
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
||||||
import { Tankopedia } from "../../stores/tankopedia";
|
import { Tankopedia } from "../../stores/tankopedia";
|
||||||
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
import { TankopediaDisplay } from "../../stores/tankopediaPersistent/constants";
|
||||||
|
import { createTankState } from "../../tankopedia/createTankState";
|
||||||
import { CustomShellButton } from "../CustomShellButton";
|
import { CustomShellButton } from "../CustomShellButton";
|
||||||
import { EqualIcon } from "../EqualIcon";
|
import { EqualIcon } from "../EqualIcon";
|
||||||
import { IconButton } from "../IconButton";
|
import { IconButton } from "../IconButton";
|
||||||
|
|
||||||
import { Discriminator } from "../Discriminator";
|
import { Discriminator } from "../Discriminator";
|
||||||
import { LazyImage } from "../LazyImage";
|
import { LazyImage } from "../LazyImage";
|
||||||
|
import { TankSearchDialog } from "../TankSearchDialog";
|
||||||
import { Text } from "../Text";
|
import { Text } from "../Text";
|
||||||
import { Tooltip } from "../Tooltip";
|
import { Tooltip } from "../Tooltip";
|
||||||
import styles from "./index.module.css";
|
import styles from "./index.module.css";
|
||||||
@@ -49,6 +51,14 @@ export function TankopediaAntagonistControl({
|
|||||||
|
|
||||||
const isVisible = showControls && isDynamicArmorDisplay;
|
const isVisible = showControls && isDynamicArmorDisplay;
|
||||||
|
|
||||||
|
const handleTankSelect = useCallback((tank: TankDefinition) => {
|
||||||
|
Tankopedia.mutate((draft) => {
|
||||||
|
draft.antagonist = createTankState(tank);
|
||||||
|
draft.shot = undefined;
|
||||||
|
draft.customShell = undefined;
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles["antagonist-control"]} data-visible={isVisible}>
|
<div className={styles["antagonist-control"]} data-visible={isVisible}>
|
||||||
<Text lowContrast>
|
<Text lowContrast>
|
||||||
@@ -57,6 +67,15 @@ export function TankopediaAntagonistControl({
|
|||||||
})}
|
})}
|
||||||
</Text>
|
</Text>
|
||||||
|
|
||||||
|
<TankSearchDialog onSelect={handleTankSelect}>
|
||||||
|
<IconButton variant="soft" color="gray" size="major">
|
||||||
|
<LazyImage
|
||||||
|
alt={unwrap(protagonist.tank.name)}
|
||||||
|
src={alias("api", `/tanks/${protagonist.tank.id}/icons/big.webp`)}
|
||||||
|
/>
|
||||||
|
</IconButton>
|
||||||
|
</TankSearchDialog>
|
||||||
|
|
||||||
{antagonistUniqueGuns.length > 1 && (
|
{antagonistUniqueGuns.length > 1 && (
|
||||||
<div className={styles.group}>
|
<div className={styles.group}>
|
||||||
{[...antagonistUniqueGuns].reverse().map((entry) => {
|
{[...antagonistUniqueGuns].reverse().map((entry) => {
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
.fullscreen {
|
.fullscreen {
|
||||||
position: absolute;
|
/* set before hydration by FullscreenSupport.astro */
|
||||||
right: var(--space-4);
|
display: var(--fullscreen-display, none);
|
||||||
bottom: var(--space-4);
|
|
||||||
}
|
}
|
||||||
@@ -8,7 +8,6 @@ interface TankopediaFullscreenProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function TankopediaFullscreen({ target }: TankopediaFullscreenProps) {
|
export function TankopediaFullscreen({ target }: TankopediaFullscreenProps) {
|
||||||
const [available, setAvailable] = useState(false);
|
|
||||||
const [isFullscreen, setIsFullscreen] = useState(false);
|
const [isFullscreen, setIsFullscreen] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -16,7 +15,6 @@ export function TankopediaFullscreen({ target }: TankopediaFullscreenProps) {
|
|||||||
setIsFullscreen(document.fullscreenElement === target.current);
|
setIsFullscreen(document.fullscreenElement === target.current);
|
||||||
}
|
}
|
||||||
|
|
||||||
setAvailable(document.fullscreenEnabled);
|
|
||||||
document.addEventListener("fullscreenchange", handleFullscreenChange);
|
document.addEventListener("fullscreenchange", handleFullscreenChange);
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
@@ -32,8 +30,6 @@ export function TankopediaFullscreen({ target }: TankopediaFullscreenProps) {
|
|||||||
}
|
}
|
||||||
}, [isFullscreen]);
|
}, [isFullscreen]);
|
||||||
|
|
||||||
if (!available) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IconButton
|
<IconButton
|
||||||
className={styles.fullscreen}
|
className={styles.fullscreen}
|
||||||
|
|||||||
@@ -9,5 +9,21 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
background-color: black;
|
background-color: black;
|
||||||
|
|
||||||
|
.corner-actions {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--space-4);
|
||||||
|
|
||||||
|
position: absolute;
|
||||||
|
right: var(--space-4);
|
||||||
|
bottom: var(--space-4);
|
||||||
|
|
||||||
|
transition-duration: var(--duration-brief);
|
||||||
|
transform: translateY(calc(100% + var(--space-4) + var(--space-1)));
|
||||||
|
|
||||||
|
&[data-visible="true"] {
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,6 +22,7 @@ import { CanvasControl } from "../CanvasControl";
|
|||||||
import { InitialCameraAligner } from "../InitialCameraAligner";
|
import { InitialCameraAligner } from "../InitialCameraAligner";
|
||||||
import { Lighting, transitionEvent } from "../Lighting";
|
import { Lighting, transitionEvent } from "../Lighting";
|
||||||
import { SceneProps } from "../SceneProps";
|
import { SceneProps } from "../SceneProps";
|
||||||
|
import { ScreenshotButton } from "../ScreenshotButton";
|
||||||
import { ShotCard } from "../ShotCard";
|
import { ShotCard } from "../ShotCard";
|
||||||
import { SmartCanvas } from "../SmartCanvas";
|
import { SmartCanvas } from "../SmartCanvas";
|
||||||
import { TankDynamicArmor } from "../TankDynamicArmor";
|
import { TankDynamicArmor } from "../TankDynamicArmor";
|
||||||
@@ -52,8 +53,10 @@ function Sandbox({ id }: TankopediaSandboxProps) {
|
|||||||
Tankopedia.useInitialization(() => protagonistTank, import.meta.env.SSR);
|
Tankopedia.useInitialization(() => protagonistTank, import.meta.env.SSR);
|
||||||
|
|
||||||
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
const equalize = Tankopedia.use((state) => state.environment.equalize);
|
||||||
|
const showControls = Tankopedia.use((state) => state.showControls);
|
||||||
const mounted = useMounted();
|
const mounted = useMounted();
|
||||||
const wrapper = useRef<HTMLDivElement>(null);
|
const wrapper = useRef<HTMLDivElement>(null);
|
||||||
|
const canvas = useRef<HTMLCanvasElement>(null!);
|
||||||
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
const hasImprovedVerticalStabilizer = useEquipment("protagonist", 122);
|
||||||
const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124);
|
const hasDownImprovedVerticalStabilizer = useEquipment("protagonist", 124);
|
||||||
|
|
||||||
@@ -191,6 +194,7 @@ function Sandbox({ id }: TankopediaSandboxProps) {
|
|||||||
<div className={styles.wrapper} ref={wrapper}>
|
<div className={styles.wrapper} ref={wrapper}>
|
||||||
<div className={styles.cavity}>
|
<div className={styles.cavity}>
|
||||||
<SmartCanvas
|
<SmartCanvas
|
||||||
|
ref={canvas}
|
||||||
resize={{ debounce: 0 }}
|
resize={{ debounce: 0 }}
|
||||||
gl={{
|
gl={{
|
||||||
clippingPlanes: [],
|
clippingPlanes: [],
|
||||||
@@ -215,9 +219,18 @@ function Sandbox({ id }: TankopediaSandboxProps) {
|
|||||||
<Thicknesses thicknessRange={thicknessRange} />
|
<Thicknesses thicknessRange={thicknessRange} />
|
||||||
<TankopediaAntagonistControl penetration={antagonistPenetration} />
|
<TankopediaAntagonistControl penetration={antagonistPenetration} />
|
||||||
<TankopediaOptions />
|
<TankopediaOptions />
|
||||||
|
|
||||||
|
<div className={styles["corner-actions"]} data-visible={showControls}>
|
||||||
|
<ScreenshotButton
|
||||||
|
variant="ghost"
|
||||||
|
highContrast
|
||||||
|
canvas={canvas}
|
||||||
|
name={protagonistTank.slug}
|
||||||
|
/>
|
||||||
<TankopediaFullscreen target={wrapper} />
|
<TankopediaFullscreen target={wrapper} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import AutoFocus from "../components/AutoFocus.astro";
|
import AutoFocus from "../components/AutoFocus.astro";
|
||||||
import BaseMeta from "../components/BaseMeta.astro";
|
import BaseMeta from "../components/BaseMeta.astro";
|
||||||
import BaseStyles from "../components/BaseStyles.astro";
|
import BaseStyles from "../components/BaseStyles.astro";
|
||||||
|
import FullscreenSupport from "../components/FullscreenSupport.astro";
|
||||||
import ColorAlias from "../components/ColorAlias.astro";
|
import ColorAlias from "../components/ColorAlias.astro";
|
||||||
import ColorScale from "../components/ColorScale.astro";
|
import ColorScale from "../components/ColorScale.astro";
|
||||||
import NavbarSmall from "../components/NavbarSmall.astro";
|
import NavbarSmall from "../components/NavbarSmall.astro";
|
||||||
@@ -35,6 +36,7 @@ const { locale, accent, solidNavbar = false, tool } = Astro.props;
|
|||||||
<ColorAlias color={accent} alias="accent" />
|
<ColorAlias color={accent} alias="accent" />
|
||||||
|
|
||||||
<BaseStyles />
|
<BaseStyles />
|
||||||
|
<FullscreenSupport />
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
:root {
|
:root {
|
||||||
|
|||||||
Reference in new issue
Block a user