diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 000000000..75fa13412 --- /dev/null +++ b/.prettierrc @@ -0,0 +1,3 @@ +{ + "tabWidth": 2 +} diff --git a/packages/website-ue/src/components/Button/index.module.css b/packages/website-ue/src/components/Button/index.module.css index 4442b77bf..07bd5704f 100644 --- a/packages/website-ue/src/components/Button/index.module.css +++ b/packages/website-ue/src/components/Button/index.module.css @@ -32,6 +32,18 @@ } } + &[data-parent-array="true"] { + *:first-child > & { + border-top-right-radius: 0; + border-bottom-right-radius: 0; + } + + *:last-child > & { + border-top-left-radius: 0; + border-bottom-left-radius: 0; + } + } + svg, img { width: 1em; diff --git a/packages/website-ue/src/components/Button/index.tsx b/packages/website-ue/src/components/Button/index.tsx index f0dc66fa9..21bd11545 100644 --- a/packages/website-ue/src/components/Button/index.tsx +++ b/packages/website-ue/src/components/Button/index.tsx @@ -9,6 +9,7 @@ export interface ButtonProps extends ComponentProps<"button"> { variant?: "solid" | "surface" | "soft" | "inverted" | "ghost" | "outline"; size?: "regular" | "minor"; array?: boolean; + parentArray?: boolean; } export const LIGHT_TEXT_COLORS = new Set([ @@ -34,6 +35,7 @@ export function Button({ radius = "max", size = "regular", array = false, + parentArray = false, ...props }: ButtonProps) { return ( @@ -45,6 +47,7 @@ export function Button({ data-radius={radius} data-size={size} data-array={array} + data-parent-array={parentArray} {...props} /> ); diff --git a/packages/website-ue/src/components/TankopediaLoadout/index.tsx b/packages/website-ue/src/components/TankopediaLoadout/index.tsx index 1db14ddee..d9ba62e0e 100644 --- a/packages/website-ue/src/components/TankopediaLoadout/index.tsx +++ b/packages/website-ue/src/components/TankopediaLoadout/index.tsx @@ -35,6 +35,8 @@ import { Section } from "../Section"; import { Text } from "../Text"; import styles from "./index.module.css"; import type { ComputedCharacteristics } from "../../tankopedia/computeCharacteristics"; +import { Tooltip } from "../Tooltip"; +import { useGameStrings } from "../../hooks/useGameStrings"; interface TankopediaLoadoutProps { characteristics: ComputedCharacteristics; @@ -178,6 +180,7 @@ function EquipmentOption({ const equipment = useEquipment(tank.tank!); const slot = equipment.preset.slots[equipmentIndex]; const id = slot.options_catalog_i_ds[optionIndex]; + const gameStrings = useGameStrings("EquipmentEntity"); const isSelected = Tankopedia.use( (state) => @@ -186,25 +189,27 @@ function EquipmentOption({ ); return ( - + + + ); } @@ -362,6 +367,7 @@ function LineElement({ index, lineName, stage }: LineElementProps) { const alternates = Tankopedia.use((state) => state.protagonist.alternates); const tank = useProtagonist(); const strings = useStrings(); + const gameStrings = useGameStrings("TankEntity"); const upgradePreset = useUpgradePreset(tank.tank!.tank_upgrade_preset); let price: StandardPrice | undefined; @@ -405,93 +411,94 @@ function LineElement({ index, lineName, stage }: LineElementProps) { } return ( -
- + let i = draft.protagonist.upgrades[line.name]; - {} -
+ while (i > 0) { + const currentStage = line.stages[i]; + + const valid = currentStage.required_upgrades.every( + (required) => { + for (const otherLine of tankData.upgrade_lines) { + const idx = draft.protagonist.upgrades[otherLine.name]; + + if (otherLine.stages[idx]?.tech_name === required) { + return true; + } + } + + return false; + }, + ); + + if (valid) break; + + i--; + } + + draft.protagonist.upgrades[line.name] = i; + } + }); + }} + > + + + + {isAlternativeLine(lineName) + ? strings.tanks.loadout.alternative + : romanize(stage.number)} + + + + {} + + ); } diff --git a/packages/website-ue/src/components/Tooltip/index.module.css b/packages/website-ue/src/components/Tooltip/index.module.css new file mode 100644 index 000000000..5367ce91f --- /dev/null +++ b/packages/website-ue/src/components/Tooltip/index.module.css @@ -0,0 +1,30 @@ +.tooltip { + position: relative; + + .text { + display: none; + + position: absolute; + bottom: 100%; + left: 50%; + transform: translateX(-50%); + + z-index: 1; + background-color: var(--gray-12); + color: var(--gray-1); + border-radius: var(--space-3); + + padding: var(--space-2) var(--space-3); + margin-bottom: var(--space-3); + + white-space: nowrap; + } + + &:hover, + &:active, + &:focus-within { + .text { + display: block; + } + } +} diff --git a/packages/website-ue/src/components/Tooltip/index.tsx b/packages/website-ue/src/components/Tooltip/index.tsx new file mode 100644 index 000000000..5d1e9d81e --- /dev/null +++ b/packages/website-ue/src/components/Tooltip/index.tsx @@ -0,0 +1,16 @@ +import type { ReactNode } from "react"; +import styles from "./index.module.css"; + +interface Props { + children: ReactNode; + tooltip: string; +} + +export function Tooltip({ children, tooltip }: Props) { + return ( +
+
{tooltip}
+ {children} +
+ ); +}