feat: better icons and sizing

This commit is contained in:
tresabhi committed 2024-12-16 13:30:35 -06:00
1 parent 3c9ba9ec53
commit 382f04229e
7 files changed
+24 -10

No files matched your search

+2
View File
@@ -1,5 +1,7 @@
import { asset } from '@blitzkit/core'; import { asset } from '@blitzkit/core';
export const BLITZKIT_TANK_ICON_SIZE = { width: 40 * 16, height: 30 * 16 };
export function tankIcon(id: number, size: 'big' | 'small' = 'big') { export function tankIcon(id: number, size: 'big' | 'small' = 'big') {
return asset(`icons/tanks/${size}/${id}.webp`); return asset(`icons/tanks/${size}/${id}.webp`);
} }
@@ -1,4 +1,4 @@
import { fetchTankDefinitions } from '@blitzkit/core'; import { BLITZKIT_TANK_ICON_SIZE, fetchTankDefinitions } from '@blitzkit/core';
import { exec } from 'child_process'; import { exec } from 'child_process';
import { launch } from 'puppeteer'; import { launch } from 'puppeteer';
import sharp from 'sharp'; import sharp from 'sharp';
@@ -17,7 +17,10 @@ export async function tankIcons() {
let index = 0; let index = 0;
for (const { id, name } of tanks) { for (const { id, name } of tanks) {
await page.setViewport({ width: 640 - 1, height: 480 }); await page.setViewport({
width: BLITZKIT_TANK_ICON_SIZE.width - 1,
height: BLITZKIT_TANK_ICON_SIZE.height,
});
await page.goto(`http://localhost:4321/api/tankopedia/tank-icon/${id}/`, { await page.goto(`http://localhost:4321/api/tankopedia/tank-icon/${id}/`, {
waitUntil: 'networkidle0', waitUntil: 'networkidle0',
}); });
@@ -34,7 +34,7 @@ export const TankCard = forwardRef<HTMLSpanElement, TankCardProps>(
<Text <Text
ref={ref} ref={ref}
tabIndex={onSelect ? 0 : undefined} tabIndex={onSelect ? 0 : undefined}
size="1" size="2"
color={ color={
tank.type === TankType.COLLECTOR tank.type === TankType.COLLECTOR
? 'blue' ? 'blue'
@@ -56,6 +56,7 @@ export const TankCard = forwardRef<HTMLSpanElement, TankCardProps>(
data-provide-link={provideLink} data-provide-link={provideLink}
style={{ style={{
backgroundImage: `url(${asset(`flags/scratched/${tank.nation}.webp`)})`, backgroundImage: `url(${asset(`flags/scratched/${tank.nation}.webp`)})`,
backgroundSize: '75%',
...style, ...style,
}} }}
{...props} {...props}
@@ -81,6 +82,7 @@ export const TankCard = forwardRef<HTMLSpanElement, TankCardProps>(
align="center" align="center"
overflow="hidden" overflow="hidden"
width="100%" width="100%"
mt="1"
> >
<Icon className="class-icon" /> <Icon className="class-icon" />
<Text align="center" className="name"> <Text align="center" className="name">
@@ -4,7 +4,10 @@ export function TankCardWrapper(props: GridProps) {
return ( return (
<Grid <Grid
py="4" py="4"
columns="repeat(auto-fill, minmax(100px, 1fr))" columns={{
initial: 'repeat(auto-fill, minmax(6rem, 1fr))',
sm: 'repeat(auto-fill, minmax(7rem, 1fr))',
}}
flow="dense" flow="dense"
gap="2" gap="2"
gapY="6" gapY="6"
@@ -39,8 +39,8 @@ type TankSearchProps = Omit<FlexProps, 'onSelect'> & {
onSelectAll?: (tanks: TankDefinition[]) => void; onSelectAll?: (tanks: TankDefinition[]) => void;
}; };
const PREVIEW_COUNT = 25; const PREVIEW_COUNT = 20;
const DEFAULT_LOADED_CARDS = 75; const DEFAULT_LOADED_CARDS = 64;
const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] = const [gameDefinitions, modelDefinitions, tankDefinitions, tankNames] =
await Promise.all([ await Promise.all([
@@ -1,3 +1,4 @@
import { BLITZKIT_TANK_ICON_SIZE } from '@blitzkit/core';
import { Canvas } from '@react-three/fiber'; import { Canvas } from '@react-three/fiber';
import { import {
forwardRef, forwardRef,
@@ -182,8 +183,8 @@ export const TankSandbox = forwardRef<HTMLCanvasElement, TankSandboxProps>(
}} }}
style={{ style={{
userSelect: 'none', userSelect: 'none',
width: naked ? 640 : '100%', width: naked ? BLITZKIT_TANK_ICON_SIZE.width : '100%',
height: naked ? 480 : '100%', height: naked ? BLITZKIT_TANK_ICON_SIZE.height : '100%',
outline: naked ? '1rem red solid' : undefined, outline: naked ? '1rem red solid' : undefined,
}} }}
> >
@@ -1,4 +1,4 @@
import { tankIcon } from '@blitzkit/core'; import { asset } from '@blitzkit/core';
import { Flex, type FlexProps, Progress } from '@radix-ui/themes'; import { Flex, type FlexProps, Progress } from '@radix-ui/themes';
import { useProgress } from '@react-three/drei'; import { useProgress } from '@react-three/drei';
@@ -11,7 +11,10 @@ export function TankSandboxLoader({ id, ...props }: TankSandboxLoaderProps) {
return ( return (
<Flex width="100%" height="100%" align="center" justify="center" {...props}> <Flex width="100%" height="100%" align="center" justify="center" {...props}>
<img src={tankIcon(id)} style={{ height: '60%', filter: 'blur(4px)' }} /> <img
src={asset(`icons/tanks/blitzkit/${id}.webp`)}
style={{ height: '60%', filter: 'blur(4px)' }}
/>
<Progress <Progress
size="3" size="3"
value={data.progress} value={data.progress}