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
+231
-143
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import type { TankDefinition } from "@blitzkit/protos";
|
||||
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 { withLocale } from "../../hocs/withLocale";
|
||||
import { useStrings } from "../../hooks/useStrings";
|
||||
@@ -11,9 +12,8 @@ import {
|
||||
import { resolveTankModules } from "../../tankopedia/resolveTankModules";
|
||||
import { Button } from "../Button";
|
||||
import { Checkbox } from "../Checkbox";
|
||||
import { Dialog } from "../Dialog";
|
||||
import { SegmentedControl } from "../SegmentedControl";
|
||||
import { TankSearchResults } from "../TankSearchResults";
|
||||
import { TankSearchDialog } from "../TankSearchDialog";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export const CompareControls = withLocale(Content);
|
||||
@@ -22,7 +22,20 @@ function Content() {
|
||||
const strings = useStrings();
|
||||
const deltaMode = ComparePersistent.use((state) => state.deltaMode);
|
||||
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 }[]>(
|
||||
() => [
|
||||
@@ -36,46 +49,17 @@ function Content() {
|
||||
return (
|
||||
<div className={styles.controls}>
|
||||
<div className={styles.group}>
|
||||
<Dialog.Root open={adding} onOpenChange={setAdding}>
|
||||
<Dialog.Trigger asChild>
|
||||
<Button variant="soft">
|
||||
<PlusIcon />
|
||||
{strings.compare.add.button}
|
||||
</Button>
|
||||
</Dialog.Trigger>
|
||||
|
||||
<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>
|
||||
<TankSearchDialog
|
||||
title={strings.compare.add.title}
|
||||
description={strings.compare.add.description}
|
||||
onSelect={handleAdd}
|
||||
onSelectAll={handleAddAll}
|
||||
>
|
||||
<Button variant="soft">
|
||||
<PlusIcon />
|
||||
{strings.compare.add.button}
|
||||
</Button>
|
||||
</TankSearchDialog>
|
||||
|
||||
<Button
|
||||
variant="soft"
|
||||
|
||||
Reference in new issue
Block a user