mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 10:47:04 +02:00
fix: some linting
This commit is contained in:
1 parent
65899a06c4
commit
c7856364ad
14 files changed
+33
-204
No files matched your search
@@ -1,32 +0,0 @@
|
||||
import { Flex, Select, Text } from '@radix-ui/themes';
|
||||
import { Charts, type ChartsPeriod } from '../../stores/charts';
|
||||
|
||||
export function ChartsControl() {
|
||||
const period = Charts.use((state) => state.period);
|
||||
const mutateCharts = Charts.useMutation();
|
||||
|
||||
return (
|
||||
<Flex justify="center" align="center" gap="2">
|
||||
<Text>Player count</Text>
|
||||
<Select.Root
|
||||
value={period}
|
||||
onValueChange={(period) => {
|
||||
mutateCharts((draft) => {
|
||||
draft.period = period as ChartsPeriod;
|
||||
});
|
||||
}}
|
||||
>
|
||||
<Select.Trigger />
|
||||
<Select.Content>
|
||||
<Select.Item value="total">Total</Select.Item>
|
||||
<Select.Item value="d_120">Past 120 days</Select.Item>
|
||||
<Select.Item value="d_90">Past 90 days</Select.Item>
|
||||
<Select.Item value="d_60">Past 60 days</Select.Item>
|
||||
<Select.Item value="d_30">This month</Select.Item>
|
||||
<Select.Item value="d_7">This week</Select.Item>
|
||||
<Select.Item value="d_1">Yesterday</Select.Item>
|
||||
</Select.Content>
|
||||
</Select.Root>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
import {
|
||||
TANK_CLASSES,
|
||||
TIERS,
|
||||
TIER_ROMAN_NUMERALS,
|
||||
TankClass,
|
||||
formatCompact,
|
||||
} from '@blitzkit/core';
|
||||
import strings from '@blitzkit/core/lang/en-US.json';
|
||||
import { useStore } from '@nanostores/react';
|
||||
import { Box, Flex, Heading } from '@radix-ui/themes';
|
||||
import { awaitableAverageDefinitions } from '../../core/awaitables/averageDefinitions';
|
||||
import { awaitableTankDefinitions } from '../../core/awaitables/tankDefinitions';
|
||||
import { filterTank } from '../../core/blitzkit/filterTank';
|
||||
import { useAveragesExclusionRatio } from '../../hooks/useAveragesExclusionRatio';
|
||||
import { Charts } from '../../stores/charts';
|
||||
import { $tankFilters } from '../../stores/tankFilters';
|
||||
import { ThemedBar } from '../Nivo/ThemedBar';
|
||||
|
||||
const [tankDefinitions, averageDefinitions] = await Promise.all([
|
||||
awaitableTankDefinitions,
|
||||
awaitableAverageDefinitions,
|
||||
]);
|
||||
|
||||
const averageDefinitionsArray = Object.entries(averageDefinitions.averages);
|
||||
|
||||
export function PlayersInPeriod() {
|
||||
const period = Charts.use((state) => state.period);
|
||||
const ratio = useAveragesExclusionRatio();
|
||||
const filters = useStore($tankFilters);
|
||||
const data = TIERS.map((tier) => {
|
||||
const players: Record<TankClass, number> = {
|
||||
0: 0,
|
||||
1: 0,
|
||||
2: 0,
|
||||
3: 0,
|
||||
};
|
||||
|
||||
averageDefinitionsArray.forEach(([idString, entry]) => {
|
||||
const id = Number(idString);
|
||||
const tank = tankDefinitions.tanks[id];
|
||||
|
||||
if (
|
||||
tank === undefined ||
|
||||
tank.tier !== tier ||
|
||||
!filterTank(filters, tank)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
players[tank.class] += entry.samples[period] * ratio;
|
||||
});
|
||||
|
||||
const bar: Record<string, number | string> = {
|
||||
tier: TIER_ROMAN_NUMERALS[tier],
|
||||
};
|
||||
|
||||
TANK_CLASSES.forEach((c) => {
|
||||
bar[strings.common.tank_class_short[c]] = players[c];
|
||||
});
|
||||
|
||||
return bar;
|
||||
});
|
||||
|
||||
return (
|
||||
<Flex direction="column" gap="4">
|
||||
<Heading align="center">Players by tier & class</Heading>
|
||||
<Box height="25rem">
|
||||
<ThemedBar
|
||||
data={data}
|
||||
keys={TANK_CLASSES.map((c) => strings.common.tank_class_short[c])}
|
||||
indexBy="tier"
|
||||
margin={{ right: 90, bottom: 50, left: 90 }}
|
||||
axisBottom={{
|
||||
legend: 'Tier',
|
||||
legendPosition: 'middle',
|
||||
legendOffset: 32,
|
||||
}}
|
||||
axisLeft={{
|
||||
legend: 'Players',
|
||||
legendPosition: 'middle',
|
||||
legendOffset: -60,
|
||||
format: formatCompact,
|
||||
}}
|
||||
legends={[
|
||||
{
|
||||
dataFrom: 'keys',
|
||||
anchor: 'bottom-right',
|
||||
direction: 'column',
|
||||
translateX: 120,
|
||||
itemWidth: 100,
|
||||
itemHeight: 20,
|
||||
},
|
||||
]}
|
||||
valueFormat={formatCompact}
|
||||
/>
|
||||
</Box>
|
||||
</Flex>
|
||||
);
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
export const FIRST_AVERAGES_ENTRY = 19925;
|
||||
@@ -1,7 +1,6 @@
|
||||
---
|
||||
import { Code, Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import { resolveBranchName } from '../core/blitzkit/branches';
|
||||
import { DEFAULT_LOCALE } from '@blitzkit/core';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import { literals } from '../core/i18n/literals';
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { awaitableDiscoveredIdsDefinitions } from '../../core/awaitables/discove
|
||||
import { literals } from '../../core/i18n/literals';
|
||||
import { useLocale } from '../../hooks/useLocale';
|
||||
import type { MaybeSkeletonComponentProps } from '../../types/maybeSkeletonComponentProps';
|
||||
import { InlineSkeleton } from '../InlineSkeleton';
|
||||
|
||||
const [discoveredIdsDefinitions, averageDefinitions] = await Promise.all([
|
||||
awaitableDiscoveredIdsDefinitions,
|
||||
@@ -36,11 +37,10 @@ export function PerformanceInfo({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
<InfoCircledIcon />
|
||||
</Callout.Icon>
|
||||
<Callout.Text>
|
||||
{/* Estimated stats based on{' '}
|
||||
{skeleton ? <InlineSkeleton width="2rem" /> : samples} players.
|
||||
Updated {skeleton ? <InlineSkeleton width="3rem" /> : timeAgo} ago. */}
|
||||
{skeleton && <InlineSkeleton width="9rem" />}
|
||||
|
||||
{literals(strings.website.tools.performance.estimation.body, [
|
||||
{!skeleton &&
|
||||
literals(strings.website.tools.performance.estimation.body, [
|
||||
samples,
|
||||
timeAgo,
|
||||
])}
|
||||
|
||||
@@ -51,7 +51,7 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
(a, b) =>
|
||||
sort.direction * (a.mu.hits / a.mu.shots - b.mu.hits / b.mu.shots),
|
||||
);
|
||||
case 'capturePoints':
|
||||
case 'capture_points':
|
||||
return averageDefinitionsArray.sort(
|
||||
(a, b) =>
|
||||
sort.direction *
|
||||
@@ -65,14 +65,14 @@ export function Tanks({ skeleton }: MaybeSkeletonComponentProps) {
|
||||
(a.mu.damage_dealt / a.mu.battles -
|
||||
b.mu.damage_dealt / b.mu.battles),
|
||||
);
|
||||
case 'damageRatio':
|
||||
case 'damage_ratio':
|
||||
return averageDefinitionsArray.sort(
|
||||
(a, b) =>
|
||||
sort.direction *
|
||||
(a.mu.damage_dealt / a.mu.damage_received -
|
||||
b.mu.damage_dealt / b.mu.damage_received),
|
||||
);
|
||||
case 'damageTaken':
|
||||
case 'damage_taken':
|
||||
return averageDefinitionsArray.sort(
|
||||
(a, b) =>
|
||||
sort.direction *
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
---
|
||||
import { imgur } from '@blitzkit/core';
|
||||
import { type Tool } from '../constants/tools';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
|
||||
interface Props {
|
||||
tool: Tool;
|
||||
}
|
||||
|
||||
const { tool } = Astro.props;
|
||||
const { locale } = Astro.params;
|
||||
const strings = getStrings(locale);
|
||||
const toolStrings =
|
||||
strings.website.tools[tool.id as keyof typeof strings.website.tools];
|
||||
---
|
||||
|
||||
<title>{tool.title}</title>
|
||||
<title>{toolStrings.name}</title>
|
||||
<meta property="og:image" content={imgur(tool.image)} />
|
||||
|
||||
{
|
||||
tool.pageDescription !== undefined && (
|
||||
<>
|
||||
<meta name="description" content={tool.pageDescription} />
|
||||
<meta property="og:description" content={tool.pageDescription} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
<meta name="description" content={toolStrings.seo_description} />
|
||||
<meta property="og:description" content={toolStrings.seo_description} />
|
||||
@@ -1,9 +1,11 @@
|
||||
import { assertSecret, REGIONS } from '@blitzkit/core';
|
||||
import strings from '@blitzkit/core/lang/en-US.json';
|
||||
import { Button, type ButtonProps, Dialog, Flex, Link } from '@radix-ui/themes';
|
||||
import { useLocale } from '../hooks/useLocale';
|
||||
import { WargamingIcon } from './WargamingIcon';
|
||||
|
||||
export function WargamingLoginButton({ children, ...props }: ButtonProps) {
|
||||
const { strings } = useLocale();
|
||||
|
||||
return (
|
||||
<Dialog.Root>
|
||||
<Dialog.Trigger>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { imgur, ImgurSize } from '@blitzkit/core';
|
||||
import { Box, Flex, Heading, Text } from '@radix-ui/themes';
|
||||
import ToolOpenGraph from '../components/ToolOpenGraph.astro';
|
||||
import { type Tool } from '../constants/tools';
|
||||
import { getStrings } from '../core/i18n/getStrings';
|
||||
import BaseLayout from './BaseLayout.astro';
|
||||
|
||||
interface Props {
|
||||
@@ -10,6 +11,10 @@ interface Props {
|
||||
}
|
||||
|
||||
const { tool } = Astro.props;
|
||||
const { locale } = Astro.params;
|
||||
const strings = getStrings(locale);
|
||||
const toolStrings =
|
||||
strings.website.tools[tool.id as keyof typeof strings.website.tools];
|
||||
---
|
||||
|
||||
<ToolOpenGraph tool={tool} />
|
||||
@@ -33,8 +38,8 @@ const { tool } = Astro.props;
|
||||
WebkitBackdropFilter: 'blur(4rem)',
|
||||
}}
|
||||
>
|
||||
<Heading size="7">{tool?.title}</Heading>
|
||||
<Text>{tool?.description}</Text>
|
||||
<Heading size="7">{toolStrings.name}</Heading>
|
||||
<Text>{toolStrings.description}</Text>
|
||||
</Flex>
|
||||
</Box>
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
import { Flex } from '@radix-ui/themes';
|
||||
import { ChartsControl } from '../../../../components/Charts/ChartsControl';
|
||||
import { PlayersInPeriod } from '../../../../components/Charts/PlayersInPeriod';
|
||||
import { PageWrapper } from '../../../../components/PageWrapper';
|
||||
import { FilterControl } from '../../../../components/TankSearch/components/FilterControl';
|
||||
import { Charts } from '../../../../stores/charts';
|
||||
|
||||
export function Page() {
|
||||
return (
|
||||
<Charts.Provider>
|
||||
<Content />
|
||||
</Charts.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
function Content() {
|
||||
return (
|
||||
<PageWrapper maxWidth="unset">
|
||||
<FilterControl />
|
||||
<ChartsControl />
|
||||
|
||||
<Flex justify="center">
|
||||
<Flex direction="column" maxWidth="45rem" flexGrow="1" py="6" gap="9">
|
||||
<PlayersInPeriod />
|
||||
</Flex>
|
||||
</Flex>
|
||||
</PageWrapper>
|
||||
);
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
---
|
||||
import { chartsTool } from '../../../../constants/tools';
|
||||
import ToolLayout from '../../../../layouts/ToolLayout.astro';
|
||||
import { Page } from './_index';
|
||||
|
||||
export { getStaticPaths } from '../../index.astro';
|
||||
---
|
||||
|
||||
<ToolLayout tool={chartsTool}>
|
||||
<Page client:load />
|
||||
</ToolLayout>
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Markdown } from '../../../../../components/Markdown';
|
||||
import { PageWrapper } from '../../../../../components/PageWrapper';
|
||||
import { Markdown } from '../../../../components/Markdown';
|
||||
import { PageWrapper } from '../../../../components/PageWrapper';
|
||||
|
||||
interface PageProps {
|
||||
content: string;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
import type { GetStaticPaths } from 'astro';
|
||||
import { readFile } from 'fs/promises';
|
||||
import BaseLayout from '../../../../../layouts/BaseLayout.astro';
|
||||
import BaseLayout from '../../../../layouts/BaseLayout.astro';
|
||||
import { Page } from './_index';
|
||||
|
||||
export const getStaticPaths = (async () => {
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
---
|
||||
import { MagicWandIcon, StarFilledIcon } from '@radix-ui/react-icons';
|
||||
import { Flex, Heading } from '@radix-ui/themes';
|
||||
import { Flex, Heading, Link } from '@radix-ui/themes';
|
||||
import { compareVersions } from 'compare-versions';
|
||||
import { LinkI18n } from '../../../../components/LinkI18n';
|
||||
import { PageWrapper } from '../../../../components/PageWrapper';
|
||||
import BaseLayout from '../../../../layouts/BaseLayout.astro';
|
||||
import { PageWrapper } from '../../../components/PageWrapper';
|
||||
import BaseLayout from '../../../layouts/BaseLayout.astro';
|
||||
|
||||
// this can't be used in template literal :(
|
||||
const ROOT = '../../../../../../docs/changelogs/';
|
||||
@@ -17,7 +16,6 @@ const versions = Object.keys(
|
||||
.map((file) => file.replace(ROOT, '').replace('.md', ''))
|
||||
.sort(compareVersions)
|
||||
.reverse();
|
||||
const { locale } = Astro.params;
|
||||
---
|
||||
|
||||
<title>BlitzKit Patches</title>
|
||||
@@ -33,8 +31,7 @@ const { locale } = Astro.params;
|
||||
const isMajor = split[2] === 0;
|
||||
|
||||
return (
|
||||
<LinkI18n
|
||||
{locale}
|
||||
<Link
|
||||
size="5"
|
||||
href={`/docs/changelogs/${version}`}
|
||||
mb={isMajor ? '6' : '0'}
|
||||
@@ -44,7 +41,7 @@ const { locale } = Astro.params;
|
||||
{isMajor && <StarFilledIcon />}
|
||||
{version}
|
||||
</Flex>
|
||||
</LinkI18n>
|
||||
</Link>
|
||||
);
|
||||
})
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user