feat: seperable buttons and remove antagonist configurer

This commit is contained in:
TrèsAbhi committed 2024-08-15 14:32:08 -05:00
1 parent f07aa9a2a7
commit 1132018d16
11 files changed
+22 -186

No files matched your search

@@ -1,15 +1,16 @@
import { Flex } from '@radix-ui/themes'; import { Flex, FlexProps } from '@radix-ui/themes';
import { ReactNode } from 'react'; import { ReactNode } from 'react';
interface ConfigurationChildWrapperProps { type ConfigurationChildWrapperProps = FlexProps & {
children: ReactNode; children: ReactNode;
} };
export function ConfigurationChildWrapper({ export function ConfigurationChildWrapper({
children, children,
...props
}: ConfigurationChildWrapperProps) { }: ConfigurationChildWrapperProps) {
return ( return (
<Flex gap="2" direction="column"> <Flex gap="2" direction="column" {...props}>
{children} {children}
</Flex> </Flex>
); );
@@ -47,8 +47,6 @@ export function Miscellaneous() {
left: '50%', left: '50%',
transform: 'translate(calc(-50% + 4px), calc(-50% + 4px))', transform: 'translate(calc(-50% + 4px), calc(-50% + 4px))',
}} }}
first
last
onClick={() => { onClick={() => {
mutateDuel((draft) => { mutateDuel((draft) => {
draft.protagonist.camouflage = !camouflage; draft.protagonist.camouflage = !camouflage;
@@ -59,8 +57,6 @@ export function Miscellaneous() {
<GenericTankComponentButton <GenericTankComponentButton
icon={asset('icons/boosters/equipment.webp')} icon={asset('icons/boosters/equipment.webp')}
selected={cooldownBooster > 0} selected={cooldownBooster > 0}
first
last
banner={ banner={
cooldownBooster === 0 cooldownBooster === 0
? undefined ? undefined
@@ -36,7 +36,7 @@ export function CharacteristicsSection() {
justify="center" justify="center"
direction={{ initial: 'column', sm: 'row' }} direction={{ initial: 'column', sm: 'row' }}
> >
<Flex direction="column" gap="4"> <Flex direction="column" gap="4" maxWidth="21rem">
<Heading>Configuration</Heading> <Heading>Configuration</Heading>
<Modules /> <Modules />
<Equipment /> <Equipment />
@@ -45,7 +45,6 @@ export function CharacteristicsSection() {
<Skills /> <Skills />
<Miscellaneous /> <Miscellaneous />
</Flex> </Flex>
<Flex <Flex
flexGrow="1" flexGrow="1"
maxWidth={{ maxWidth={{
@@ -1,5 +1,4 @@
import { import {
Cross1Icon,
EnterFullScreenIcon, EnterFullScreenIcon,
ExitFullScreenIcon, ExitFullScreenIcon,
EyeOpenIcon, EyeOpenIcon,
@@ -11,7 +10,6 @@ import {
Dialog, Dialog,
DropdownMenu, DropdownMenu,
Flex, Flex,
Heading,
IconButton, IconButton,
Popover, Popover,
SegmentedControl, SegmentedControl,
@@ -28,10 +26,7 @@ import { resolvePenetrationCoefficient } from '../../../../../../../core/blitz/r
import { asset } from '../../../../../../../core/blitzkit/asset'; import { asset } from '../../../../../../../core/blitzkit/asset';
import { imgur } from '../../../../../../../core/blitzkit/imgur'; import { imgur } from '../../../../../../../core/blitzkit/imgur';
import { Pose, poseEvent } from '../../../../../../../core/blitzkit/pose'; import { Pose, poseEvent } from '../../../../../../../core/blitzkit/pose';
import { import { TIER_ROMAN_NUMERALS } from '../../../../../../../core/blitzkit/tankDefinitions/constants';
SHELL_NAMES,
TIER_ROMAN_NUMERALS,
} from '../../../../../../../core/blitzkit/tankDefinitions/constants';
import { uniqueGuns } from '../../../../../../../core/blitzkit/uniqueGuns'; import { uniqueGuns } from '../../../../../../../core/blitzkit/uniqueGuns';
import { useEquipment } from '../../../../../../../hooks/useEquipment'; import { useEquipment } from '../../../../../../../hooks/useEquipment';
import { useFullScreen } from '../../../../../../../hooks/useFullScreen'; import { useFullScreen } from '../../../../../../../hooks/useFullScreen';
@@ -181,12 +176,11 @@ export function Options({ thicknessRange }: OptionsProps) {
</Popover.Trigger> </Popover.Trigger>
<Popover.Content side="left" align="center"> <Popover.Content side="left" align="center">
<Flex> <Flex gap="2">
{[...antagonistUniqueGuns] {[...antagonistUniqueGuns]
.reverse() .reverse()
.map(({ gun, turret }, index) => ( .map(({ gun, turret }, index) => (
<ModuleButton <ModuleButton
rowChild
module="gun" module="gun"
key={gun.id} key={gun.id}
onClick={() => onClick={() =>
@@ -196,8 +190,6 @@ export function Options({ thicknessRange }: OptionsProps) {
draft.antagonist.shell = gun.shells[0]; draft.antagonist.shell = gun.shells[0];
}) })
} }
first={index === 0}
last={index === antagonistUniqueGuns.length - 1}
selected={gun.id === antagonistGun.id} selected={gun.id === antagonistGun.id}
discriminator={TIER_ROMAN_NUMERALS[gun.tier]} discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
/> />
@@ -342,28 +334,6 @@ export function Options({ thicknessRange }: OptionsProps) {
value={tab} value={tab}
onValueChange={setTab} onValueChange={setTab}
style={{ position: 'relative' }} style={{ position: 'relative' }}
>
<Dialog.Close>
<Button
variant="ghost"
style={{ position: 'absolute', right: 0, top: 8 }}
>
<Cross1Icon />
</Button>
</Dialog.Close>
<Flex gap="4" direction="column">
<Tabs.List>
<Tabs.Trigger value="search">Search</Tabs.Trigger>
<Tabs.Trigger value="configure">Configure</Tabs.Trigger>
</Tabs.List>
<Tabs.Content value="search">
<Flex
direction="column"
gap="4"
style={{ flex: 1 }}
justify="center"
> >
<TankSearch <TankSearch
compact compact
@@ -375,104 +345,11 @@ export function Options({ thicknessRange }: OptionsProps) {
draft.antagonist.turret = tank.turrets.at(-1)!; draft.antagonist.turret = tank.turrets.at(-1)!;
draft.antagonist.gun = draft.antagonist.gun =
draft.antagonist.turret.guns.at(-1)!; draft.antagonist.turret.guns.at(-1)!;
draft.antagonist.shell = draft.antagonist.shell = draft.antagonist.gun.shells[0];
draft.antagonist.gun.shells[0];
}); });
setAntagonistSelectorOpen(false); setAntagonistSelectorOpen(false);
}} }}
/> />
</Flex>
</Tabs.Content>
<Tabs.Content value="configure">
<Flex direction="column" gap="4">
<Flex direction="column" gap="2" style={{ flex: 1 }}>
<Heading size="4">
{antagonistTank.name} modules
</Heading>
<Flex gap="2" wrap="wrap">
<Flex>
{antagonistTank.turrets.map((turret, index) => (
<ModuleButton
rowChild
first={index === 0}
last={
index === antagonistTank.turrets.length - 1
}
key={turret.id}
onClick={() => {
mutateDuel((draft) => {
draft.antagonist.turret = turret;
draft.antagonist.gun =
turret.guns.at(-1)!;
draft.antagonist.shell =
draft.antagonist.gun.shells[0];
});
mutateTankopediaEphemeral((draft) => {
draft.shot = undefined;
});
}}
selected={antagonistTurret.id === turret.id}
discriminator={
TIER_ROMAN_NUMERALS[turret.tier]
}
module="turret"
/>
))}
</Flex>
<Flex>
{antagonistTurret.guns.map((gun, index) => (
<ModuleButton
key={gun.id}
rowChild
first={index === 0}
last={
index === antagonistTurret.guns.length - 1
}
onClick={() => {
mutateDuel((draft) => {
draft.antagonist.gun = gun;
draft.antagonist.shell = gun.shells[0];
});
}}
selected={antagonistGun.id === gun.id}
discriminator={TIER_ROMAN_NUMERALS[gun.tier]}
module="gun"
/>
))}
</Flex>
</Flex>
</Flex>
<Flex direction="column" style={{ flex: 1 }}>
<Heading size="4">Properties</Heading>
<ul>
<li>
Turret: <b>{antagonistTurret.name}</b>
</li>
<li>
Gun: <b>{antagonistGun.name}</b>
</li>
<li>Shells:</li>
<ul>
{antagonistGun.shells.map((shell) => (
<li key={shell.id}>
{SHELL_NAMES[shell.type]}:{' '}
<b>
{resolveNearPenetration(shell.penetration)}
mm
</b>
, {shell.damage.armor}HP
</li>
))}
</ul>
</ul>
</Flex>
</Flex>
</Tabs.Content>
</Flex>
</Tabs.Root> </Tabs.Root>
</Dialog.Content> </Dialog.Content>
</Dialog.Root> </Dialog.Root>
+1 -11
View File
@@ -24,14 +24,7 @@ export function ConsumablesManager({
hasHighEndConsumables, hasHighEndConsumables,
}: ConsumablesManagerProps) { }: ConsumablesManagerProps) {
return ( return (
<Flex <Flex wrap="wrap" gap="2">
wrap="wrap"
style={{
maxWidth: 288,
borderRadius: 4,
overflow: 'hidden',
}}
>
{consumables.map((consumable, index) => { {consumables.map((consumable, index) => {
const isSelected = selected.some((id) => id === consumable.id); const isSelected = selected.some((id) => id === consumable.id);
@@ -53,9 +46,6 @@ export function ConsumablesManager({
: undefined : undefined
} }
key={consumable.id} key={consumable.id}
first={index === 0}
last={index === consumables.length - 1}
rowChild
disabled={disabled && !isSelected} disabled={disabled && !isSelected}
consumable={consumable.id} consumable={consumable.id}
selected={isSelected} selected={isSelected}
-2
View File
@@ -30,8 +30,6 @@ export function CrewSkillManager({
<GenericTankComponentButton <GenericTankComponentButton
key={skill} key={skill}
special={!permanentSkills.includes(skill)} special={!permanentSkills.includes(skill)}
first
last
selected={level > 0} selected={level > 0}
discriminator={ discriminator={
level === 0 ? undefined : TIER_ROMAN_NUMERALS[level as Tier] level === 0 ? undefined : TIER_ROMAN_NUMERALS[level as Tier]
+8 -4
View File
@@ -23,8 +23,10 @@ export function EquipmentManager({
<Flex key={columnIndex}> <Flex key={columnIndex}>
<EquipmentButton <EquipmentButton
equipment={equipment[0]} equipment={equipment[0]}
first style={{
rowChild borderTopRightRadius: 0,
borderBottomRightRadius: 0,
}}
selected={matrix[rowIndex][columnIndex] === -1} selected={matrix[rowIndex][columnIndex] === -1}
onClick={() => { onClick={() => {
const draft = cloneDeep(matrix); const draft = cloneDeep(matrix);
@@ -40,8 +42,10 @@ export function EquipmentManager({
/> />
<EquipmentButton <EquipmentButton
equipment={equipment[1]} equipment={equipment[1]}
last style={{
rowChild borderTopLeftRadius: 0,
borderBottomLeftRadius: 0,
}}
selected={matrix[rowIndex][columnIndex] === 1} selected={matrix[rowIndex][columnIndex] === 1}
onClick={() => { onClick={() => {
const draft = cloneDeep(matrix); const draft = cloneDeep(matrix);
@@ -23,17 +23,13 @@ export function ConsumableButton({
return ( return (
<GenericTankComponentButton <GenericTankComponentButton
icon={asset(`icons/consumables/${consumable}.webp`)} icon={asset(`icons/consumables/${consumable}.webp`)}
style={{
flex: 1,
minWidth: 'fit-content',
borderRadius: 0,
}}
{...props} {...props}
> >
{(cooldown || duration) && ( {(cooldown || duration) && (
<Flex direction="column" style={{ transform: 'translateX(-10px)' }}> <Flex direction="column" gap="1" ml="-2" mr="2">
{duration && ( {duration && (
<Text <Text
size="1"
color={ color={
durationDelta > 0 durationDelta > 0
? 'green' ? 'green'
@@ -50,6 +46,7 @@ export function ConsumableButton({
)} )}
{cooldown && ( {cooldown && (
<Text <Text
size="1"
color={ color={
cooldownDelta < 0 cooldownDelta < 0
? 'green' ? 'green'
@@ -4,9 +4,6 @@ import { ComponentProps, ReactNode } from 'react';
export interface TankComponentButtonProps export interface TankComponentButtonProps
extends ComponentProps<typeof Button> { extends ComponentProps<typeof Button> {
selected?: boolean; selected?: boolean;
first?: boolean;
last?: boolean;
rowChild?: boolean;
children?: ReactNode; children?: ReactNode;
discriminator?: ReactNode; discriminator?: ReactNode;
disabled?: boolean; disabled?: boolean;
@@ -17,9 +14,6 @@ export interface TankComponentButtonProps
export function TankComponentButton({ export function TankComponentButton({
variant, variant,
selected, selected,
first = false,
last = false,
rowChild,
discriminator, discriminator,
special, special,
children, children,
@@ -38,11 +32,6 @@ export function TankComponentButton({
minWidth: 48, minWidth: 48,
height: 40, height: 40,
position: 'relative', position: 'relative',
borderTopLeftRadius: first ? undefined : 0,
borderTopRightRadius: last ? undefined : 0,
borderBottomLeftRadius: first ? undefined : 0,
borderBottomRightRadius: last ? undefined : 0,
margin: rowChild ? -0.5 : 'unset',
overflow: 'hidden', overflow: 'hidden',
cursor: 'unset', cursor: 'unset',
pointerEvents: variant === 'ghost' ? 'none' : undefined, pointerEvents: variant === 'ghost' ? 'none' : undefined,
-12
View File
@@ -41,9 +41,6 @@ export function ModuleManager({
<ModuleButton <ModuleButton
module="turret" module="turret"
discriminator={TIER_ROMAN_NUMERALS[modules.turret.tier]} discriminator={TIER_ROMAN_NUMERALS[modules.turret.tier]}
first
last
rowChild
onClick={() => setTurretMenuOpen(true)} onClick={() => setTurretMenuOpen(true)}
/> />
@@ -85,9 +82,6 @@ export function ModuleManager({
<ModuleButton <ModuleButton
module="gun" module="gun"
discriminator={TIER_ROMAN_NUMERALS[modules.gun.tier]} discriminator={TIER_ROMAN_NUMERALS[modules.gun.tier]}
first
last
rowChild
onClick={() => setGunMenuOpen(true)} onClick={() => setGunMenuOpen(true)}
/> />
@@ -128,9 +122,6 @@ export function ModuleManager({
<ModuleButton <ModuleButton
module="engine" module="engine"
discriminator={TIER_ROMAN_NUMERALS[modules.engine.tier]} discriminator={TIER_ROMAN_NUMERALS[modules.engine.tier]}
first
last
rowChild
onClick={() => setEngineMenuOpen(true)} onClick={() => setEngineMenuOpen(true)}
/> />
@@ -170,9 +161,6 @@ export function ModuleManager({
<ModuleButton <ModuleButton
module="chassis" module="chassis"
discriminator={TIER_ROMAN_NUMERALS[modules.track.tier]} discriminator={TIER_ROMAN_NUMERALS[modules.track.tier]}
first
last
rowChild
onClick={() => setTrackMenuOpen(true)} onClick={() => setTrackMenuOpen(true)}
/> />
+1 -4
View File
@@ -15,16 +15,13 @@ export function ProvisionsManager({
disabled, disabled,
}: ProvisionsManagerProps) { }: ProvisionsManagerProps) {
return ( return (
<Flex wrap="wrap"> <Flex wrap="wrap" gap="2">
{provisions.map((provision, index) => { {provisions.map((provision, index) => {
const isSelected = selected.includes(provision); const isSelected = selected.includes(provision);
return ( return (
<ProvisionButton <ProvisionButton
key={provision} key={provision}
first={index === 0}
last={index === provisions.length - 1}
rowChild
disabled={disabled && !isSelected} disabled={disabled && !isSelected}
provision={provision} provision={provision}
selected={isSelected} selected={isSelected}