Resolves semantic color tokens to concrete class pairs, so the data layer
can say :primary or "brand" instead of hardcoding Tailwind strings.
Event.color and Layer.color accept, in priority order:
Semantic tokens — the eight daisyUI semantics as atoms (
:primary,:secondary,:accent,:neutral,:info,:success,:warning,:error), each resolving to itsbg-*/text-*-contentpair.App-defined tokens — configured once per host:
config :phoenix_live_calendar, :color_tokens, %{ "brand" => {"bg-[#5b21b6]", "text-white"}, :muted => "bg-base-300" }Values are a
{bg, text}pair or a bare bg class (text is then inferred). Keys match exactly (atom or string).Raw class strings — pass through unchanged, exactly as before.
An atom that matches neither a semantic nor a configured token resolves
to nil (the views fall back to their default color).
As with every class in this library, resolved classes must be complete names the host's Tailwind build can see.
Summary
Functions
The resolved background class for a color value, or nil.
event_colors/2 as a class list — the one-liner every bar render uses.
The {bg_class, text_class} an event renders with: the event's resolved
color (or default_bg when it has none), and its explicit text_color,
falling back to the token pair's text, falling back to inferring from the
APPLIED background.
Resolves a color value to a {bg_class, text_class | nil} pair, or nil
when there is nothing to apply (nil input or an unknown atom token).
The built-in semantic token atoms.
Functions
The resolved background class for a color value, or nil.
@spec event_color_classes(PhoenixLiveCalendar.Event.t(), String.t()) :: [String.t()]
event_colors/2 as a class list — the one-liner every bar render uses.
@spec event_colors(PhoenixLiveCalendar.Event.t(), String.t()) :: {String.t(), String.t()}
The {bg_class, text_class} an event renders with: the event's resolved
color (or default_bg when it has none), and its explicit text_color,
falling back to the token pair's text, falling back to inferring from the
APPLIED background.
This is the single merge rule for every event render path.
Resolves a color value to a {bg_class, text_class | nil} pair, or nil
when there is nothing to apply (nil input or an unknown atom token).
@spec semantic_tokens() :: [atom()]
The built-in semantic token atoms.