Skip to content

feat(utils): add isLightColor helper - #73

Open
lucasclgibson wants to merge 1 commit into
mainfrom
feat/is-light-color
Open

feat(utils): add isLightColor helper#73
lucasclgibson wants to merge 1 commit into
mainfrom
feat/is-light-color

Conversation

@lucasclgibson

Copy link
Copy Markdown

Adds a shared isLightColor(color) utility so apps can pick a readable text colour against the customer's accent colour instead of hardcoding one. Customers set screenly_color_accent themselves, so anything painted on top of it needs to know whether the brand is pale or deep. Nothing in the library covered this and no app had rolled its own.

It uses the WCAG relative luminance formula rather than averaging raw channels, so pure yellow and pure blue land on opposite sides of the threshold the way an eye sees them. Accepts hex and numeric rgb() / rgba() strings and ignores alpha. Unparseable input returns false rather than throwing, so a malformed setting cannot blank an unattended screen. Minor version bump since this is additive.

- Rank colors by WCAG relative luminance, not raw RGB averages
- Accept hex and numeric rgb()/rgba() strings, ignoring any alpha
- Return false for unparseable input so screens keep rendering
@nicomiguelino
nicomiguelino marked this pull request as ready for review August 12, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants