Skip to main content

UI System Logic Check

Challenge on lesson: Checkpoint: UI System Logic

Implement three UI-system helpers: 1. resolveTokens(scopes)scopes is an array of token objects applied in order (earliest first). RETURN one merged object; later scopes override earlier ones token by token. 2. applyTheme(state, action) — state is { mode: "light" | "dark" | "system", explicit: boolean }. Actions: { type: "set", mode } sets an explicit mode, { type: "reset" } returns to { mode: "system", explicit: false }. RETURN the new state; never mutate the input. 3. motionPolicy(prefersReducedMotion, userSetting)userSetting is "system" | "reduced" | "full". RETURN "reduced" when the user explicitly chose reduced OR (user chose system AND prefersReducedMotion is true); otherwise "full".

Difficulty: intermediate

Back to lesson: Checkpoint: UI System Logic