mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
feat: updated /ownedtanks to new design
This commit is contained in:
1 parent
2bf5eb78be
commit
cf20ae38d4
7 files changed
+96
-31
No files matched your search
+26
-11
@@ -90,7 +90,6 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
`https://api.wotblitz.${server}/wotb/clans/accountinfo/?application_id=${WARGAMING_APPLICATION_ID}&account_id=${id}&extra=clan`,
|
||||||
);
|
);
|
||||||
const leftColumnSize = Math.ceil(tanks.length / 2);
|
const leftColumnSize = Math.ceil(tanks.length / 2);
|
||||||
const rightColumnSize = tanks.length - leftColumnSize;
|
|
||||||
const leftColumn = tanks.slice(0, leftColumnSize);
|
const leftColumn = tanks.slice(0, leftColumnSize);
|
||||||
const rightColumn = tanks.slice(leftColumnSize);
|
const rightColumn = tanks.slice(leftColumnSize);
|
||||||
|
|
||||||
@@ -114,16 +113,32 @@ export const ownedTanksCommand: CommandRegistry = {
|
|||||||
|
|
||||||
{tanks.length > 0 && (
|
{tanks.length > 0 && (
|
||||||
<Tanks.Root>
|
<Tanks.Root>
|
||||||
{await Promise.all(
|
<Tanks.Column>
|
||||||
tanks.map(async (tank) => (
|
{await Promise.all(
|
||||||
<Tanks.Item
|
leftColumn.map(async (tank) => (
|
||||||
key={tank.tank_id}
|
<Tanks.Item
|
||||||
name={await resolveTankName(tank.tank_id)}
|
key={tank.tank_id}
|
||||||
type={tank.type}
|
name={await resolveTankName(tank.tank_id)}
|
||||||
icon={tank.images?.normal}
|
type={tank.type}
|
||||||
/>
|
image={tank.images?.preview}
|
||||||
)),
|
isPremium={tank.is_premium}
|
||||||
)}
|
/>
|
||||||
|
)),
|
||||||
|
)}
|
||||||
|
</Tanks.Column>
|
||||||
|
<Tanks.Column>
|
||||||
|
{await Promise.all(
|
||||||
|
rightColumn.map(async (tank) => (
|
||||||
|
<Tanks.Item
|
||||||
|
key={tank.tank_id}
|
||||||
|
name={await resolveTankName(tank.tank_id)}
|
||||||
|
type={tank.type}
|
||||||
|
image={tank.images?.preview}
|
||||||
|
isPremium={tank.is_premium}
|
||||||
|
/>
|
||||||
|
)),
|
||||||
|
)}
|
||||||
|
</Tanks.Column>
|
||||||
</Tanks.Root>
|
</Tanks.Root>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { ReactNode } from 'react';
|
||||||
|
|
||||||
|
export interface RootProps {
|
||||||
|
children: ReactNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function Column({ children }: RootProps) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
gap: 8,
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,38 +1,62 @@
|
|||||||
import { TANK_ICONS } from '../../../core/blitz/tankopedia.js';
|
import {
|
||||||
|
TANK_ICONS,
|
||||||
|
TANK_ICONS_PREMIUM,
|
||||||
|
} from '../../../core/blitz/tankopedia.js';
|
||||||
|
import { theme, themeAmber } from '../../../stitches.config.js';
|
||||||
|
|
||||||
export interface ItemProps {
|
export interface ItemProps {
|
||||||
icon?: string;
|
image?: string;
|
||||||
type?: string;
|
type?: string;
|
||||||
name: string;
|
name: string;
|
||||||
|
isPremium?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Item({ icon, type, name }: ItemProps) {
|
export function Item({ image, type, name, isPremium }: ItemProps) {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
flex: 1,
|
|
||||||
minWidth: 128,
|
|
||||||
height: 128,
|
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexDirection: 'column',
|
height: 32,
|
||||||
alignItems: 'center',
|
paddingLeft: 8,
|
||||||
justifyContent: 'center',
|
paddingRight: 8,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
|
alignItems: 'center',
|
||||||
|
borderRadius: 4,
|
||||||
|
backgroundColor: isPremium
|
||||||
|
? themeAmber.colors.componentInteractive
|
||||||
|
: theme.colors.componentInteractive,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{icon && <img src={icon} style={{ flex: 1, objectFit: 'contain' }} />}
|
<div
|
||||||
|
style={{
|
||||||
<div style={{ display: 'flex', margin: 'auto', gap: 4 }}>
|
display: 'flex',
|
||||||
|
gap: 4,
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'flex-start',
|
||||||
|
overflow: 'hidden',
|
||||||
|
}}
|
||||||
|
>
|
||||||
{type && (
|
{type && (
|
||||||
<img src={TANK_ICONS[type]} style={{ width: 14, height: 14 }} />
|
<img
|
||||||
|
src={isPremium ? TANK_ICONS_PREMIUM[type] : TANK_ICONS[type]}
|
||||||
|
style={{ width: 14, height: 14 }}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<span
|
<span
|
||||||
style={{ fontSize: 16, textAlign: 'center', whiteSpace: 'nowrap' }}
|
style={{
|
||||||
|
fontSize: 16,
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
color: isPremium
|
||||||
|
? themeAmber.colors.textLowContrast
|
||||||
|
: theme.colors.textHighContrast,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{name}
|
{name}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{image && <img src={image} style={{ flex: 1 }} />}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -9,10 +9,7 @@ export function Root({ children }: RootProps) {
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flexWrap: 'wrap',
|
gap: 8,
|
||||||
gap: 16,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
|
export * from './components/Column.js';
|
||||||
export * from './components/Item.js';
|
export * from './components/Item.js';
|
||||||
export * from './components/Root.js';
|
export * from './components/Root.js';
|
||||||
@@ -35,6 +35,13 @@ export const TANK_ICONS: Record<string, string> = {
|
|||||||
heavyTank: 'https://i.imgur.com/ECeqlZa.png',
|
heavyTank: 'https://i.imgur.com/ECeqlZa.png',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const TANK_ICONS_PREMIUM: Record<string, string> = {
|
||||||
|
'AT-SPG': 'https://i.imgur.com/TCu3EdR.png',
|
||||||
|
lightTank: 'https://i.imgur.com/zdkpTRb.png',
|
||||||
|
mediumTank: 'https://i.imgur.com/3z7eHX6.png',
|
||||||
|
heavyTank: 'https://i.imgur.com/P3vbmyA.png',
|
||||||
|
};
|
||||||
|
|
||||||
export type Tier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
export type Tier = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
||||||
|
|
||||||
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
|
export const TIER_ROMAN_NUMERALS: Record<Tier, string> = {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { slate, slateDark } from '@radix-ui/colors';
|
import { amberDark, slate, slateDark } from '@radix-ui/colors';
|
||||||
import { createBorderStyles, createColors } from 'bepaint';
|
import { createBorderStyles, createColors } from 'bepaint';
|
||||||
|
|
||||||
// this isn't really a stitches config, but the object is compliant
|
// this isn't really a stitches config, but the object is compliant
|
||||||
@@ -7,3 +7,4 @@ export const theme = {
|
|||||||
borderStyles: createBorderStyles(slateDark),
|
borderStyles: createBorderStyles(slateDark),
|
||||||
};
|
};
|
||||||
export const themeLight = { colors: createColors(slate) };
|
export const themeLight = { colors: createColors(slate) };
|
||||||
|
export const themeAmber = { colors: createColors(amberDark) };
|
||||||
Reference in new issue
Block a user