mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: reset button
This commit is contained in:
1 parent
6b8433c690
commit
86eecd202a
4 files changed
+48
-12
No files matched your search
@@ -0,0 +1,6 @@
|
|||||||
|
# BlitzKit 1.25.0
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
- Added embeds
|
||||||
|
- This tool is intended
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "blitzkit",
|
"name": "blitzkit",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "1.24.0",
|
"version": "1.25.0",
|
||||||
"description": "🎉 Tools for everything World of Tanks Blitz",
|
"description": "🎉 Tools for everything World of Tanks Blitz",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"types": "./types.d.ts",
|
"types": "./types.d.ts",
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import {
|
|||||||
type IndividualTankStats,
|
type IndividualTankStats,
|
||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import strings from '@blitzkit/core/lang/en-US.json';
|
import strings from '@blitzkit/core/lang/en-US.json';
|
||||||
|
import { ReloadIcon } from '@radix-ui/react-icons';
|
||||||
|
import { ContextMenu } from '@radix-ui/themes';
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
import { breakdownConfig } from '../../constants/embeds';
|
import { breakdownConfig } from '../../constants/embeds';
|
||||||
import { EmbedBreakdownPersistent } from '../../stores/embedBreakdownPersistent';
|
import { EmbedBreakdownPersistent } from '../../stores/embedBreakdownPersistent';
|
||||||
@@ -46,6 +48,7 @@ export function BreakdownRenderer() {
|
|||||||
function BreakdownRendererContent() {
|
function BreakdownRendererContent() {
|
||||||
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const mutateEmbedBreakdownPersistent = EmbedBreakdownPersistent.useMutation();
|
||||||
const id = Number(params.get('id'));
|
const id = Number(params.get('id'));
|
||||||
const tankStatsA = EmbedBreakdownPersistent.use((state) => state[id] ?? []);
|
const tankStatsA = EmbedBreakdownPersistent.use((state) => state[id] ?? []);
|
||||||
const [tankStatsB, setTankStatsB] = useState<IndividualTankStats[]>([]);
|
const [tankStatsB, setTankStatsB] = useState<IndividualTankStats[]>([]);
|
||||||
@@ -70,14 +73,35 @@ function BreakdownRendererContent() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<BreakdownEmbedWrapper>
|
<ContextMenu.Root>
|
||||||
{useEmbedState('showTotal') && <BreakdownEmbedCard tank={null} />}
|
<ContextMenu.Trigger>
|
||||||
|
<BreakdownEmbedWrapper>
|
||||||
|
{useEmbedState('showTotal') && <BreakdownEmbedCard tank={null} />}
|
||||||
|
|
||||||
{diff.slice(0, useEmbedState('listMaxTanks')).map((diff) => {
|
{diff.slice(0, useEmbedState('listMaxTanks')).map((diff) => {
|
||||||
const tank = tankDefinitions.tanks[diff.tank_id];
|
const tank = tankDefinitions.tanks[diff.tank_id];
|
||||||
|
|
||||||
return <BreakdownEmbedCard key={tank.id} tank={tank} />;
|
return <BreakdownEmbedCard key={tank.id} tank={tank} />;
|
||||||
})}
|
})}
|
||||||
</BreakdownEmbedWrapper>
|
</BreakdownEmbedWrapper>
|
||||||
|
</ContextMenu.Trigger>
|
||||||
|
|
||||||
|
<ContextMenu.Content>
|
||||||
|
<ContextMenu.Item
|
||||||
|
color="red"
|
||||||
|
onClick={async () => {
|
||||||
|
const newA = await getTankStats(idToRegion(id), id);
|
||||||
|
|
||||||
|
if (newA === null) return;
|
||||||
|
|
||||||
|
mutateEmbedBreakdownPersistent((draft) => {
|
||||||
|
draft[id] = newA;
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<ReloadIcon /> Reset
|
||||||
|
</ContextMenu.Item>
|
||||||
|
</ContextMenu.Content>
|
||||||
|
</ContextMenu.Root>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
} from '@blitzkit/core';
|
} from '@blitzkit/core';
|
||||||
import strings from '@blitzkit/core/lang/en-US.json';
|
import strings from '@blitzkit/core/lang/en-US.json';
|
||||||
import { amberDark, blueDark } from '@radix-ui/colors';
|
import { amberDark, blueDark } from '@radix-ui/colors';
|
||||||
import { Flex, Text } from '@radix-ui/themes';
|
import { Flex, Text, type FlexProps } from '@radix-ui/themes';
|
||||||
import { times } from 'lodash-es';
|
import { times } from 'lodash-es';
|
||||||
import type { ReactNode } from 'react';
|
import type { ReactNode } from 'react';
|
||||||
import { breakdownConfig } from '../constants/embeds';
|
import { breakdownConfig } from '../constants/embeds';
|
||||||
@@ -18,17 +18,23 @@ import { ClassLight } from './ClassIcon/components/ClassLight';
|
|||||||
import { ClassMedium } from './ClassIcon/components/ClassMedium';
|
import { ClassMedium } from './ClassIcon/components/ClassMedium';
|
||||||
import { ClassTankDestroyer } from './ClassIcon/components/ClassTankDestroyer';
|
import { ClassTankDestroyer } from './ClassIcon/components/ClassTankDestroyer';
|
||||||
|
|
||||||
interface BreakdownEmbedWrapperProps {
|
type BreakdownEmbedWrapperProps = FlexProps & {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
};
|
||||||
|
|
||||||
export function BreakdownEmbedWrapper({
|
export function BreakdownEmbedWrapper({
|
||||||
children,
|
children,
|
||||||
|
...props
|
||||||
}: BreakdownEmbedWrapperProps) {
|
}: BreakdownEmbedWrapperProps) {
|
||||||
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
const { useEmbedState } = useEmbedStateCurry<typeof breakdownConfig>();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Flex direction="column" gap={useEmbedState('listGap')} height="100%">
|
<Flex
|
||||||
|
direction="column"
|
||||||
|
gap={useEmbedState('listGap')}
|
||||||
|
height="100%"
|
||||||
|
{...props}
|
||||||
|
>
|
||||||
{children}
|
{children}
|
||||||
</Flex>
|
</Flex>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in new issue
Block a user