From a79d668cdd61bc966feba8a6607d3a56c6d35ef4 Mon Sep 17 00:00:00 2001 From: trafficlunar Date: Mon, 6 Apr 2026 16:10:07 +0100 Subject: [PATCH] fix: remove random zeros in instructions --- src/components/mii/instructions.tsx | 36 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/components/mii/instructions.tsx b/src/components/mii/instructions.tsx index f183dac..3385767 100644 --- a/src/components/mii/instructions.tsx +++ b/src/components/mii/instructions.tsx @@ -27,6 +27,10 @@ const ORDINAL_SUFFIXES: Record = { }; const ordinalRules = new Intl.PluralRules("en-US", { type: "ordinal" }); +function not(value: any) { + return value !== undefined && value !== null; +} + function GridPosition({ index, cols = 5 }: { index: number; cols?: number }) { const row = Math.floor(index / cols) + 1; const col = (index % cols) + 1; @@ -36,8 +40,8 @@ function GridPosition({ index, cols = 5 }: { index: number; cols?: number }) { return `${row}${rowSuffix} row, ${col}${colSuffix} column`; } -function ColorPosition({ color }: { color: number }) { - if (!color) return null; +function ColorPosition({ color }: { color: number | undefined | null }) { + if (color === undefined || color === null) return null; if (color <= 7) { return ( @@ -93,16 +97,16 @@ function Section({ name, instructions, children, isSubSection }: SectionProps) { - {color && ( + {not(color) && ( )} - {height && {height}} - {distance && {distance}} - {rotation && {rotation}} - {size && {size}} - {stretch && {stretch}} + {not(height) && {height}} + {not(distance) && {distance}} + {not(rotation) && {rotation}} + {not(size) && {size}} + {not(stretch) && {stretch}} {children} @@ -124,7 +128,7 @@ export default function MiiInstructions({ instructions }: Props) { {head && (
- {head.skinColor && ( + {not(head.skinColor) && ( @@ -133,18 +137,18 @@ export default function MiiInstructions({ instructions }: Props) { )} {hair && (
- {hair.subColor && ( + {not(hair.subColor) && ( )} - {hair.subColor2 && ( + {not(hair.subColor2) && ( )} - {hair.style && {hair.style}} - {hair.isFlipped && {hair.isFlipped ? "Yes" : "No"}} + {not(hair.style) && {hair.style}} + {not(hair.isFlipped) && {hair.isFlipped ? "Yes" : "No"}}
)} {eyebrows &&
} @@ -162,18 +166,18 @@ export default function MiiInstructions({ instructions }: Props) { {nose &&
} {lips && (
- {lips.hasLipstick && {lips.hasLipstick ? "Yes" : "No"}} + {not(lips.hasLipstick) && {lips.hasLipstick ? "Yes" : "No"}}
)} {ears &&
} {glasses && (
- {glasses.ringColor && ( + {not(glasses.ringColor) && ( )} - {glasses.shadesColor && ( + {not(glasses.shadesColor) && (