Problem
Build a traffic light UI that cycles Green → Yellow → Red with configurable durations, and supports multiple intersections in sync or offset.
Requirements
- Single light: auto-cycle
GREEN (3s) → YELLOW (1s) → RED (3s). - Display current color and countdown timer.
- Buttons: pause/resume, manual override (emergency all-red).
- (Bonus) two intersections where North-South green implies East-West red.
Hints / Approach
- State machine:
{ color, remainingMs }updated viarequestAnimationFrameor 100ms tick. - Store durations in config object; derive next state with a map.
- Cleanup timers on unmount.