mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: old code
This commit is contained in:
1 parent
c24639dd0c
commit
99ed269723
6 files changed
+1
-272
No files matched your search
@@ -1,61 +0,0 @@
|
|||||||
import { ContextMenu, DropdownMenu } from '@radix-ui/themes';
|
|
||||||
import mutateSession, { useSession } from '../../../../stores/session';
|
|
||||||
|
|
||||||
export type CustomColumnDisplay =
|
|
||||||
| 'battles'
|
|
||||||
| 'winrate'
|
|
||||||
| 'wn8'
|
|
||||||
| 'damage'
|
|
||||||
| 'none';
|
|
||||||
|
|
||||||
const NO_DELTA: CustomColumnDisplay[] = ['battles', 'wn8', 'none'];
|
|
||||||
|
|
||||||
interface CustomColumn {
|
|
||||||
Builder: typeof DropdownMenu | typeof ContextMenu;
|
|
||||||
column: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function CustomColumn({ column, Builder }: CustomColumn) {
|
|
||||||
const customColumn = useSession((state) => state.customColumns[column]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Builder.Sub>
|
|
||||||
<Builder.SubTrigger>Column {column + 1}</Builder.SubTrigger>
|
|
||||||
|
|
||||||
<Builder.SubContent>
|
|
||||||
<Builder.RadioGroup
|
|
||||||
value={customColumn.display}
|
|
||||||
onValueChange={(event) =>
|
|
||||||
mutateSession((draft) => {
|
|
||||||
draft.customColumns[column].display =
|
|
||||||
event as CustomColumnDisplay;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Builder.RadioItem value="battles">Battles</Builder.RadioItem>
|
|
||||||
<Builder.RadioItem value="winrate">Winrate</Builder.RadioItem>
|
|
||||||
<Builder.RadioItem value="wn8">WN8</Builder.RadioItem>
|
|
||||||
<Builder.RadioItem value="damage">Damage</Builder.RadioItem>
|
|
||||||
<Builder.RadioItem value="none">None</Builder.RadioItem>
|
|
||||||
</Builder.RadioGroup>
|
|
||||||
|
|
||||||
{!NO_DELTA.includes(customColumn.display) && (
|
|
||||||
<>
|
|
||||||
<Builder.Separator />
|
|
||||||
|
|
||||||
<Builder.CheckboxItem
|
|
||||||
checked={customColumn.showDelta}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
mutateSession((draft) => {
|
|
||||||
draft.customColumns[column].showDelta = checked;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Show delta
|
|
||||||
</Builder.CheckboxItem>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Builder.SubContent>
|
|
||||||
</Builder.Sub>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,135 +0,0 @@
|
|||||||
import {
|
|
||||||
Button,
|
|
||||||
ContextMenu,
|
|
||||||
Dialog,
|
|
||||||
DropdownMenu,
|
|
||||||
Flex,
|
|
||||||
Heading,
|
|
||||||
TextField,
|
|
||||||
} from '@radix-ui/themes';
|
|
||||||
import { createColors } from 'bepaint';
|
|
||||||
import { useRef, useState } from 'react';
|
|
||||||
import {
|
|
||||||
ACCENT_COLORS,
|
|
||||||
AccentColor,
|
|
||||||
GRAY_COLORS,
|
|
||||||
GrayColor,
|
|
||||||
PALETTES,
|
|
||||||
} from '../../../../constants/radixColors';
|
|
||||||
import { useSession } from '../../../../stores/session';
|
|
||||||
import { CustomColumn } from './CustomColumn';
|
|
||||||
|
|
||||||
interface ContextMenuProps {
|
|
||||||
Builder: typeof DropdownMenu | typeof ContextMenu;
|
|
||||||
reset: () => void;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function Menu({ Builder, reset }: ContextMenuProps) {
|
|
||||||
const session = useSession();
|
|
||||||
const [showTitleEditor, setShowTitleEditor] = useState(false);
|
|
||||||
const titleInput = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<Dialog.Root open={showTitleEditor} onOpenChange={setShowTitleEditor}>
|
|
||||||
<Dialog.Content>
|
|
||||||
<Flex direction="column" gap="4">
|
|
||||||
<Heading size="4">Edit title</Heading>
|
|
||||||
|
|
||||||
<Flex gap="2" style={{ width: '100%' }}>
|
|
||||||
<TextField.Root
|
|
||||||
style={{ flex: 1 }}
|
|
||||||
ref={titleInput}
|
|
||||||
defaultValue={session.title}
|
|
||||||
placeholder="Enter title..."
|
|
||||||
onKeyDown={(event) => {
|
|
||||||
if (event.key === 'Enter' && titleInput.current) {
|
|
||||||
setShowTitleEditor(false);
|
|
||||||
useSession.setState({ title: titleInput.current!.value });
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<Dialog.Close>
|
|
||||||
<Button
|
|
||||||
onClick={() =>
|
|
||||||
useSession.setState({ title: titleInput.current!.value })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Set
|
|
||||||
</Button>
|
|
||||||
</Dialog.Close>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
</Dialog.Content>
|
|
||||||
</Dialog.Root>
|
|
||||||
|
|
||||||
<Builder.Content>
|
|
||||||
<Builder.Sub>
|
|
||||||
<Builder.SubTrigger>Accent color</Builder.SubTrigger>
|
|
||||||
|
|
||||||
<Builder.SubContent>
|
|
||||||
<Builder.RadioGroup
|
|
||||||
value={session.color}
|
|
||||||
onValueChange={(value) =>
|
|
||||||
useSession.setState({ color: value as AccentColor | GrayColor })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{[...ACCENT_COLORS, ...GRAY_COLORS].map((color) => (
|
|
||||||
<Builder.RadioItem value={color} key={color}>
|
|
||||||
<Flex gap="2" align="center">
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
backgroundColor: createColors(PALETTES[color])
|
|
||||||
.solidBackground,
|
|
||||||
width: 16,
|
|
||||||
height: 16,
|
|
||||||
borderRadius: '100%',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
{`${color.charAt(0).toUpperCase()}${color.slice(1)}`}
|
|
||||||
</Flex>
|
|
||||||
</Builder.RadioItem>
|
|
||||||
))}
|
|
||||||
</Builder.RadioGroup>
|
|
||||||
</Builder.SubContent>
|
|
||||||
</Builder.Sub>
|
|
||||||
|
|
||||||
<Builder.Separator />
|
|
||||||
|
|
||||||
<Builder.Item onClick={() => setShowTitleEditor(true)}>
|
|
||||||
Edit title...
|
|
||||||
</Builder.Item>
|
|
||||||
<CustomColumn Builder={Builder} column={0} />
|
|
||||||
<CustomColumn Builder={Builder} column={1} />
|
|
||||||
<CustomColumn Builder={Builder} column={2} />
|
|
||||||
<CustomColumn Builder={Builder} column={3} />
|
|
||||||
|
|
||||||
<Builder.Separator />
|
|
||||||
|
|
||||||
<Builder.CheckboxItem
|
|
||||||
checked={session.showTotal}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
useSession.setState({ showTotal: checked })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Show total
|
|
||||||
</Builder.CheckboxItem>
|
|
||||||
<Builder.CheckboxItem
|
|
||||||
checked={session.showCareer}
|
|
||||||
onCheckedChange={(checked) =>
|
|
||||||
useSession.setState({ showCareer: checked })
|
|
||||||
}
|
|
||||||
>
|
|
||||||
Show career
|
|
||||||
</Builder.CheckboxItem>
|
|
||||||
|
|
||||||
<Builder.Separator />
|
|
||||||
|
|
||||||
<Builder.Item color="red" onClick={reset}>
|
|
||||||
Reset
|
|
||||||
</Builder.Item>
|
|
||||||
</Builder.Content>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
import { style } from '@vanilla-extract/css';
|
|
||||||
import { theme } from '../../../stitches.config';
|
|
||||||
|
|
||||||
export const toolBar = style({
|
|
||||||
'@media': {
|
|
||||||
'screen and (min-width: 640px)': {
|
|
||||||
flexDirection: 'row',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
flexDirection: 'column',
|
|
||||||
display: 'flex',
|
|
||||||
gap: 8,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const toolbarButton = style({
|
|
||||||
'@media': {
|
|
||||||
'screen and (min-width: 640px)': {
|
|
||||||
flex: 0,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
flex: 1,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const searchButton = style({
|
|
||||||
border: 'none',
|
|
||||||
background: 'none',
|
|
||||||
fontSize: 16,
|
|
||||||
display: 'flex',
|
|
||||||
padding: 8,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
cursor: 'pointer',
|
|
||||||
|
|
||||||
':hover': {
|
|
||||||
backgroundColor: theme.colors.componentInteractiveHover,
|
|
||||||
borderRadius: 4,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -13,7 +13,7 @@ const fonts = [
|
|||||||
|
|
||||||
export default async function jsxToSvg(
|
export default async function jsxToSvg(
|
||||||
jsx: JSX.Element,
|
jsx: JSX.Element,
|
||||||
renderConfiguration: RenderConfiguration,
|
renderConfiguration = new RenderConfiguration(),
|
||||||
) {
|
) {
|
||||||
return await satori(jsx, {
|
return await satori(jsx, {
|
||||||
width: renderConfiguration.width,
|
width: renderConfiguration.width,
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
import { useSession } from '../../stores/session';
|
|
||||||
import { setSession } from './setSession';
|
|
||||||
|
|
||||||
export function resetSession() {
|
|
||||||
const session = useSession.getState();
|
|
||||||
if (!session.isTracking) return;
|
|
||||||
setSession(session.region, session.id, session.nickname);
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
import { Region } from '../../constants/regions';
|
|
||||||
import { useSession } from '../../stores/session';
|
|
||||||
import { NormalizedTankStats, TanksStats } from '../../types/tanksStats';
|
|
||||||
import fetchBlitz from '../blitz/fetchBlitz';
|
|
||||||
|
|
||||||
export async function setSession(region: Region, id: number, nickname: string) {
|
|
||||||
// TODO: generalize this function and also check for more of these kind
|
|
||||||
const rawTankStats = (
|
|
||||||
await fetchBlitz<TanksStats>(region, 'tanks/stats', { account_id: id })
|
|
||||||
)[id];
|
|
||||||
const tankStats = rawTankStats!.reduce<NormalizedTankStats>(
|
|
||||||
(accumulator, tank) => ({
|
|
||||||
...accumulator,
|
|
||||||
[tank.tank_id]: tank,
|
|
||||||
}),
|
|
||||||
{},
|
|
||||||
);
|
|
||||||
|
|
||||||
useSession.setState({
|
|
||||||
isTracking: true,
|
|
||||||
id,
|
|
||||||
region,
|
|
||||||
nickname,
|
|
||||||
tankStats,
|
|
||||||
time: Date.now(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user