Skip to content

deriveDarkVariant

deriveDarkVariant(lightColor): string

A client-only heuristic for pre-filling a dark-mode color from a light one — spec 955-forms-look-and-feel. Used by a settings UI (ebitex’s own hosted-page/embed look-and-feel settings, or any third-party consumer building their own) to suggest a starting dark value the moment a light color is picked, before the organization ever saves; the suggestion is always editable afterward. Deliberately the only place this derivation exists — Forms.Api never computes one, it only ever stores what it’s given (see SPEC.md’s Business Logic) — so there is exactly one implementation to keep correct, not two kept in sync across languages.

Only understands #rrggbb hex, which is what a native <input type="color"> produces and therefore what any color-picker-driven settings UI will actually pass in. A non-hex CSS color string (oklch(...), a named color, transparent, …) is returned unchanged — deriving a dark variant of an arbitrary CSS color generically needs a real color-management library, which this zero-runtime-dependency package deliberately doesn’t carry (see README’s “no font stack, no imposed max-width” posture, one level up).

string

string