import React from "react"; import DatingPreferencesViewer from "./dating-preferences"; import VoiceViewer from "./voice-viewer"; import PersonalityViewer from "./personality-viewer"; import { SwitchMiiInstructions } from "@/types"; import { Icon } from "@iconify/react"; import { COLORS } from "@/lib/switch"; interface Props { instructions: Partial; } interface SectionProps { name: string; instructions: Partial; children?: React.ReactNode; isSubSection?: boolean; } const ORDINAL_SUFFIXES: Record = { one: "st", two: "nd", few: "rd", other: "th", }; const ordinalRules = new Intl.PluralRules("en-US", { type: "ordinal" }); function GridPosition({ index, cols = 5 }: { index: number; cols?: number }) { const row = Math.floor(index / cols) + 1; const col = (index % cols) + 1; const rowSuffix = ORDINAL_SUFFIXES[ordinalRules.select(row)]; const colSuffix = ORDINAL_SUFFIXES[ordinalRules.select(col)]; return `${row}${rowSuffix} row, ${col}${colSuffix} column`; } function ColorPosition({ color }: { color: number }) { if (!color) return null; if (color <= 7) { return (
Color menu on left,
); } if (color >= 108) { return (
Outside color menu,
); } return (
Color menu on right,
); } interface TableCellProps { label: string; children: React.ReactNode; } function TableCell({ label, children }: TableCellProps) { return ( {label} {children} ); } function Section({ name, instructions, children, isSubSection }: SectionProps) { if (typeof instructions !== "object" || !instructions) return null; const color = "color" in instructions ? instructions.color : undefined; const height = "height" in instructions ? instructions.height : undefined; const distance = "distance" in instructions ? instructions.distance : undefined; const rotation = "rotation" in instructions ? instructions.rotation : undefined; const size = "size" in instructions ? instructions.size : undefined; const stretch = "stretch" in instructions ? instructions.stretch : undefined; return (

{name}

{color && ( )} {height && {height}} {distance && {distance}} {rotation && {rotation}} {size && {size}} {stretch && {stretch}} {children}
); } export default function MiiInstructions({ instructions }: Props) { if (Object.keys(instructions).length === 0) return null; const { head, hair, eyebrows, eyes, nose, lips, ears, glasses, other, height, weight, datingPreferences, voice, personality } = instructions; return (

Instructions

{head &&
} {hair && (
{hair.subColor && ( )} {hair.subColor2 && ( )} {hair.style && {hair.style}} {hair.isFlipped && {hair.isFlipped ? "Yes" : "No"}}
)} {eyebrows &&
} {eyes && (
)} {nose &&
} {lips && (
{lips.hasLipstick && {lips.hasLipstick ? "Yes" : "No"}}
)} {ears &&
} {glasses && (
{glasses.ringColor && ( )} {glasses.shadesColor && ( )}
)} {other && (
{other.moustache && other.moustache.isFlipped && {other.moustache.isFlipped ? "Yes" : "No"}}
)} {(height || weight || datingPreferences || voice || personality) && (

Misc

{height && (
)} {weight && (
)} {datingPreferences && (

Dating Preferences

)} {voice && (

Voice

)} {personality && (

Personality

)}
)}
); }