mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-11-20 04:14:12 +01:00
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
import { alias } from "@blitzkit/core";
|
|||
|
|
import type { GunDefinition } from "@blitzkit/protos";
|
||
|
|
import { useStrings } from "../../hooks/useStrings";
|
||
|
|
import { useUnwrapper } from "../../hooks/useUnwrapper";
|
||
|
|
import { IconButton } from "../IconButton";
|
||
|
|
import { LoadoutSection } from "../LoadoutSection";
|
||
|
|
import { Tooltip } from "../Tooltip";
|
||
|
|
import styles from "./index.module.css";
|
||
|
|
|
||
|
|
interface LoadoutShellsProps {
|
||
|
|
gun: GunDefinition;
|
||
|
|
selected: number;
|
||
|
|
onSelect: (id: number) => void;
|
||
|
|
}
|
||
|
|
|
||
|
|
export function LoadoutShells({ gun, selected, onSelect }: LoadoutShellsProps) {
|
||
|
|
const strings = useStrings();
|
||
|
|
const unwrap = useUnwrapper();
|
||
|
|
|
||
|
|
return (
|
||
|
|
<LoadoutSection title={strings.tanks.loadout.shells}>
|
||
|
|
<div className={styles.shells}>
|
||
|
|
{gun.shells.map((candidate) => {
|
||
|
|
const isSelected = candidate.id === selected;
|
||
|
|
const name = unwrap(candidate.name!);
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Tooltip key={candidate.id} tooltip={name}>
|
||
|
|
<IconButton
|
||
|
|
size="major"
|
||
|
|
radius="1"
|
||
|
|
color={isSelected ? undefined : "gray"}
|
||
|
|
variant={isSelected ? "surface" : "soft"}
|
||
|
|
parentListChild="horizontal"
|
||
|
|
onClick={() => onSelect(candidate.id)}
|
||
|
|
>
|
||
|
|
<img
|
||
|
|
alt={name}
|
||
|
|
src={alias("api", `/icons/shells/${candidate.icon}.webp`)}
|
||
|
|
/>
|
||
|
|
</IconButton>
|
||
|
|
</Tooltip>
|
||
|
|
);
|
||
|
|
})}
|
||
|
|
</div>
|
||
|
|
</LoadoutSection>
|
||
|
|
);
|
||
|
|
}
|