MishkaCmsCore.LanguageAccent (Mishka CMS Core v0.0.1)

Copy Markdown View Source

The colour a language's badge wears on an admin card.

The design names five — EN indigo, FA green, RU amber, FR pink, DE blue — but language is a free ISO-639-1 string, so an unnamed one (ar, zh, pt) is hashed into the same five rather than all falling back to one. :erlang.phash2/2 is stable, so a language keeps its colour for good (the same trick MishkaCmsCore.Activity.Helpers.avatar_tone/1 uses for actor avatars).

Colour is what makes an editions row legible: EN · Primary beside FA · 100% only reads if the two differ. An archived record ignores its language and goes grey — archived reads as inactive before it reads as Farsi.

Every value is a Tailwind class, not a hex string: the runtime CSS compiler only emits a class it can see written out, so the palette has to be literal.

iex> MishkaCmsCore.LanguageAccent.of(%{language: "en"}).chip
"border-[#dcdbf5] bg-[#eeedfb] text-[#5b57d6]"

Used by MishkaDocument.WorkspaceAccent and MishkaBlogWeb.Templates.CollectionCard. See MishkaCmsCore.LanguageEditions, which finds the siblings these colour.

Summary

Functions

The grey every archived record wears, whatever language it is in.

The colour a language code wears, whether or not the design names it.

The accent a record's language badge wears — its language's colour, or grey once archived.

Functions

archived()

@spec archived() :: map()

The grey every archived record wears, whatever language it is in.

for_language(language)

@spec for_language(String.t() | atom() | nil) :: map()

The colour a language code wears, whether or not the design names it.

Blank falls back to English, as the design does (LANGC[c.lang] || LANGC.EN) and as the attribute's own default says.

of(arg1)

@spec of(map()) :: map()

The accent a record's language badge wears — its language's colour, or grey once archived.