feat(saju-ui-v2): _shell/helpers — hexA/daeunLabel/deriveTraits/colorMap + tests

This commit is contained in:
2026-05-27 01:58:26 +09:00
parent 7f42c40efc
commit 47b5eab3ff
5 changed files with 115 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
const TRAIT_DEFS = {
fire: { id: 'challenge', ko: '도전정신', icon: 'challenge', color: 'var(--el-fire)' },
metal: { id: 'lead', ko: '리더십', icon: 'lead', color: 'var(--el-metal)' },
wood: { id: 'adapt', ko: '적응력', icon: 'adapt', color: 'var(--el-wood)' },
water: { id: 'wisdom', ko: '지혜', icon: 'wisdom', color: 'var(--el-water)' },
earth: { id: 'wealth', ko: '풍부함', icon: 'wealth', color: 'var(--el-earth)' },
};
const WILL_TRAIT = { id: 'will', ko: '의지', icon: 'will', color: 'var(--purple)' };
export default function deriveTraits(elements, sipsin = []) {
const sorted = Object.entries(elements || {})
.filter(([, v]) => typeof v === 'number')
.sort((a, b) => b[1] - a[1]);
const traits = [];
for (const [el, score] of sorted) {
if (score >= 30 && TRAIT_DEFS[el]) {
traits.push(TRAIT_DEFS[el]);
}
}
if (!traits.find((t) => t.id === 'will')) traits.push(WILL_TRAIT);
for (const [el] of sorted) {
if (traits.length >= 6) break;
if (TRAIT_DEFS[el] && !traits.find((t) => t.id === TRAIT_DEFS[el].id)) {
traits.push(TRAIT_DEFS[el]);
}
}
return traits.slice(0, 6);
}