Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | 5x 116x 116x 228x 224x 4x 116x 116x 116x 116x 116x 116x 1x 115x 228x 5x | import React, { useMemo } from "react";
import { FONT_FAMILY, KOREAN_COLORS } from "../../../types/constants";
import { hexToRgbaString, hexColorToCSS } from "../../../utils/colorUtils";
export interface Ability {
readonly korean: string;
readonly english: string;
readonly description?: {
readonly korean: string;
readonly english: string;
};
}
export interface AbilityListProps {
readonly abilities: readonly string[] | readonly Ability[];
readonly maxAbilities?: number; // Maximum abilities to show
readonly color?: number; // Accent color for abilities
readonly isMobile?: boolean;
}
/**
* AbilityList component - Displays a list of special abilities
* Used in archetype cards to show key techniques and skills
*/
export const AbilityList: React.FC<AbilityListProps> = React.memo(
({ abilities, maxAbilities = 3, color = KOREAN_COLORS.ACCENT_GOLD, isMobile = false }) => {
// Normalize abilities to consistent format
const normalizedAbilities = useMemo(() => {
return abilities.slice(0, maxAbilities).map((ability, index) => {
if (typeof ability === "string") {
// TEMPORARY: This fallback violates PRIO 2 bilingual support guidelines.
// All abilities should use the object format with Korean/English fields.
// See: src/systems/types.ts PLAYER_ARCHETYPES_DATA for correct format.
// Replace with proper bilingual objects as soon as translations are available.
return {
id: `ability-${index}`,
english: ability,
korean: ability, // TEMPORARY: English used as Korean fallback
};
} else {
// Object format with Korean/English
return {
id: `ability-${index}`,
english: ability.english,
korean: ability.korean,
description: ability.description,
};
}
});
}, [abilities, maxAbilities]);
// Memoize color calculations
const colors = useMemo(
() => ({
abilityBorder: hexToRgbaString(color, 0.5),
abilityBackground: hexToRgbaString(
KOREAN_COLORS.UI_BACKGROUND_MEDIUM,
0.7
),
abilityText: hexColorToCSS(color),
descriptionText: hexColorToCSS(KOREAN_COLORS.TEXT_SECONDARY),
}),
[color]
);
// Responsive sizing
const fontSize = isMobile ? 10 : 12;
const descFontSize = isMobile ? 8 : 10;
const padding = isMobile ? "6px 10px" : "8px 12px";
if (normalizedAbilities.length === 0) {
return null;
}
return (
<div
style={{
width: "100%",
display: "flex",
flexDirection: "column",
gap: "8px",
}}
data-testid="ability-list"
>
{/* Header */}
<div
style={{
fontSize: isMobile ? "12px" : "14px",
fontWeight: "bold",
fontFamily: FONT_FAMILY.KOREAN,
color: colors.abilityText,
}}
data-testid="ability-list-header"
>
특수 능력 | Special Abilities
</div>
{/* Ability items */}
<div
style={{
display: "flex",
flexDirection: "column",
gap: "6px",
}}
>
{normalizedAbilities.map((ability) => (
<div
key={ability.id}
style={{
padding,
background: colors.abilityBackground,
border: `1px solid ${colors.abilityBorder}`,
borderRadius: "4px",
display: "flex",
flexDirection: "column",
gap: "4px",
}}
data-testid={ability.id}
>
{/* Ability name */}
<div
style={{
fontSize: `${fontSize}px`,
fontWeight: "bold",
fontFamily: FONT_FAMILY.KOREAN,
color: colors.abilityText,
}}
data-testid={`${ability.id}-name`}
>
{ability.korean} | {ability.english}
</div>
{/* Ability description (if available) */}
{ability.description && (
<div
style={{
fontSize: `${descFontSize}px`,
fontStyle: "italic",
fontFamily: FONT_FAMILY.KOREAN,
color: colors.descriptionText,
lineHeight: "1.3",
}}
data-testid={`${ability.id}-description`}
>
{ability.description.korean}
{ability.description.english && (
<>
<br />
{ability.description.english}
</>
)}
</div>
)}
</div>
))}
</div>
</div>
);
}
);
AbilityList.displayName = "AbilityList";
export default AbilityList;
|