MobDev.Style (mob_dev v0.6.16)

Copy Markdown View Source

The styles lane (MOB_STYLES.md), minimum-viable slice: token-only style packages. A style package ships priv/mob_style.exs declaring a theme module; activation is config :mob, :styles, [...] plus config :mob, :default_style, :name in mob.exs, and the runtime manifest carries the resolved set so core can apply the default style's theme at boot.

Tokens-only is the doc's smallest tier ("repalette-only styles"); the per-component native-override tier (cascade, _style dispatch — the mob_m3 case) is NOT implemented yet.

Summary

Functions

The activated styles as {style_dir, manifest} pairs. Names that don't resolve to a dep or whose manifest fails to load are skipped (surfaced by validation at build).

Activated style names from mob.exs's config :mob, :styles (Application env fallback, mirroring MobDev.Plugin.activated_names/0).

The configured :default_style name (or nil).

Loads a style manifest from style_dir. {:ok, map}, or {:error, reason} when the file is missing/unreadable/not a map (styles REQUIRE a manifest — there is no tier-0 equivalent).

The runtime-manifest entries for the activated styles: [%{name, theme}]. Raises at build when an activated style's manifest is invalid or the configured :default_style isn't among the activated styles — a misconfigured style must fail the BUILD, not silently render baseline.

Validates the four required fields (MOB_STYLES.md "Minimum viable manifest"): :name atom, :mob_version requirement string, :style_spec_version integer, :theme module atom.

Functions

activated()

@spec activated() :: [{Path.t(), map()}]

The activated styles as {style_dir, manifest} pairs. Names that don't resolve to a dep or whose manifest fails to load are skipped (surfaced by validation at build).

activated_names()

@spec activated_names() :: [atom()]

Activated style names from mob.exs's config :mob, :styles (Application env fallback, mirroring MobDev.Plugin.activated_names/0).

default_style()

@spec default_style() :: atom() | nil

The configured :default_style name (or nil).

load(style_dir)

@spec load(Path.t()) :: {:ok, map()} | {:error, String.t()}

Loads a style manifest from style_dir. {:ok, map}, or {:error, reason} when the file is missing/unreadable/not a map (styles REQUIRE a manifest — there is no tier-0 equivalent).

runtime_entries!()

@spec runtime_entries!() :: %{styles: [map()], default_style: atom() | nil}

The runtime-manifest entries for the activated styles: [%{name, theme}]. Raises at build when an activated style's manifest is invalid or the configured :default_style isn't among the activated styles — a misconfigured style must fail the BUILD, not silently render baseline.

validate(manifest)

@spec validate(map()) :: {:ok, map()} | {:error, [String.t()]}

Validates the four required fields (MOB_STYLES.md "Minimum viable manifest"): :name atom, :mob_version requirement string, :style_spec_version integer, :theme module atom.