feat: highlight top tier modules

This commit is contained in:
TrèsAbhi committed 2024-05-04 17:50:06 -05:00
1 parent def470e805
commit 03205d3659
1 file changed
+18 -1
@@ -26,11 +26,13 @@ function ModuleButton({
tier, tier,
selected, selected,
unlock, unlock,
top,
onClick, onClick,
}: { }: {
unlock: Unlock; unlock: Unlock;
tier: Tier; tier: Tier;
selected: boolean; selected: boolean;
top: boolean;
onClick: () => void; onClick: () => void;
}) { }) {
const numberFormat = Intl.NumberFormat(undefined, { const numberFormat = Intl.NumberFormat(undefined, {
@@ -43,7 +45,7 @@ function ModuleButton({
size="4" size="4"
radius="small" radius="small"
variant={selected ? 'surface' : 'soft'} variant={selected ? 'surface' : 'soft'}
color={selected ? undefined : 'gray'} color={top ? 'amber' : selected ? undefined : 'gray'}
onClick={onClick} onClick={onClick}
style={{ style={{
position: 'relative', position: 'relative',
@@ -129,6 +131,10 @@ export function Modules() {
const gun0 = turret0.guns[0]; const gun0 = turret0.guns[0];
const engine0 = tank.engines[0]; const engine0 = tank.engines[0];
const track0 = tank.tracks[0]; const track0 = tank.tracks[0];
const topTurret = tank.turrets.at(-1)!;
const topGun = topTurret.guns.at(-1)!;
const topEngine = tank.engines.at(-1)!;
const topTrack = tank.tracks.at(-1)!;
function setByUnlock(unlock: Unlock) { function setByUnlock(unlock: Unlock) {
mutateDuel((draft) => { mutateDuel((draft) => {
@@ -266,6 +272,17 @@ export function Modules() {
? track.id ? track.id
: -1) === unlock.id : -1) === unlock.id
} }
top={
unlock.type === 'turret'
? module.id == topTurret.id
: unlock.type === 'gun'
? module.id === topGun.id
: unlock.type === 'engine'
? module.id === topEngine.id
: unlock.type === 'chassis'
? module.id === topTrack.id
: false
}
onClick={() => setByUnlock(unlock)} onClick={() => setByUnlock(unlock)}
/> />