React Colors

A color palette manager built with React, Redux Toolkit and TypeScript. Create palettes, type in or randomize hex codes, and copy any color to your clipboard.

React colors

01

Overview.

React Colors is a small single-page app for building and keeping color palettes. You can create a palette, add or remove colors, type your own hex codes or generate random ones, and copy any value to the clipboard. Palettes are saved in the browser, so they’re still there when you come back.

I built it in JavaScript first, then migrated it to TypeScript later one file at a time. That was a good way to learn how a typed Redux store fits together. It also caught a few bugs the JavaScript version had been hiding.

02

Built with.

React

Component-driven interfaces

TypeScript

Typed, safer JavaScript

Git

Version control & deployment

Redux Toolkit

Predictable app state

Material UI

Ready-made React components

03

Challenges.

Challenge

Before

After

Saving palettes

Every refresh reset palettes back to the seed data.

Wrote a small localStorage layer using preloadedState and store.subscribe..

Keeping edits in sync

Typing a hex code and clicking randomize disagreed about the current color.

Kept a local draft in state, synced it from Redux with useEffect, and saved on blur.

Migrating to TypeScript

Plain JavaScript with quiet bugs, like a dead route prop and a misspelled className.

Converted file by file, and the type checker flagged each issue so I could fix it.

04

The results.

05

What I learned.

01

Types catch quiet bugs

Migrating to TypeScript surfaced mistakes that had gone unnoticed in plain JavaScript.

02

Redux is a data loop

Slices, actions and selectors clicked once I traced a single button press all the way through the store.

03

Dependency versions matter

An unpinned package silently jumped a major version and broke the linter, which taught me to control versions deliberately.

06

Next steps.

  • Validate hex input so only real colors are accepted.
  • Add the ability to delete and reorder palettes.
  • Write tests for the reducers and the Pane component.
  • Save palettes to a database so they sync across devices

Next case study

BitcoinChaser →

Homepage of BitcoinChaser.com