Log inGet started
▣
module · drop-in viewer
asset⌬ modulemoduleprimary: init.luau·part ofpackage metropolisUi.package·originates fromworld 0a0b119f-a…

theme

Resolves the token table and hands the result to the engine's theme system.

byzero-proxy @ DESKTOP-DB3UJOJ·posted 11d ago
What it does

theme

Resolves the token table and hands the result to the engine's theme system.

Screens never write a colour or a size: they ask for a token. `Theme.t("paper")` is the resolved value;
`Theme.style("label.display", { fontSize = 20 })` is a resolved class with overrides laid on top, ready to be a
node's `style`. Both work without the engine (the test suite runs them), and the same resolved theme is what
`Theme.register()` gives the engine so that `classes` on a node and the default chrome agree with it.

  local Theme = require("~.modules.theme")
  Theme.t("state-pursuit")                 -- "#C8463C"
  Theme.n("space-4")                       -- 16 (a number token; errors if it is not a number)
  Theme.style(".paper", { padding = 8 })   -- { background = "#F6F1E4", padding = 8 }
  Theme.state(state)                       -- the colour of an attention state ("clear", "pursuit", ...)
  Theme.pigment(id)                        -- the colour of a pigment id, or the ink colour when unknown
  Theme.register()                         -- engine: ui.registerTheme + ui.defineStyles (call once, in awake)
  Theme.resolve(tokens, styles)            -- the pure resolver: returns tokens, styles or nil, nil, error

The interface is documented in the header of init.luau; this file repeats it for the asset browser.

Interface

What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.

conforms to

zero/source-extract/v2

metropolisUi.modules.theme — resolves the token table and hands the result to the engine's theme system. Screens never write a colour or a size: they ask for a token. `Theme.t("paper")` is the resolved value; `Theme.style("label.display", { fontSize = 20 })` is a resolved class with overrides laid on top, ready to be a node's `style`. Both work without the engine (the test suite runs them), and the same resolved theme is what `Theme.register()` gives the engine so that `classes` on a node and the default chrome agree with it. local Theme = require("~.modules.theme") Theme.t("state-pursuit") -- "#C8463C" Theme.n("space-4") -- 16 (a number token; errors if it is not a number) Theme.style(".paper", { padding = 8 }) -- { background = "#F6F1E4", padding = 8 } Theme.state(state) -- the colour of an attention state ("clear", "pursuit", ...) Theme.pigment(id) -- the colour of a pigment id, or the ink colour when unknown Theme.setPalette("safe" | "normal") -- pigments in colour-blind safe hues (Tokens.safe) or as painted Theme.setTextScale("large") -- every text size token times Tokens.textScales[name] Theme.motion("meter") -- { duration, easing } of a named motion spec; with Theme.setReducedMotion(true) -- reduced motion every duration is 0 except `meter` and `drain` Theme.register() -- engine: ui.registerTheme + ui.defineStyles (call once, in awake) Theme.resolve(tokens, styles) -- the pure resolver: returns tokens, styles or nil, nil, error

resolve(tokens: any, styles: any) → void

Resolve every "$name" reference. Returns resolved tokens and styles, or nil, nil and a message.

argtypedescription
tokensany
stylesany

resolve(name: string) → any

argtypedescription
namestring

t(name: string) → any

A resolved token. Errors on an unknown name so a typo cannot ship as a missing colour.

argtypedescription
namestring

n(name: string) → number

A resolved number token. Text sizes come back scaled by the chosen text scale.

argtypedescription
namestring

style(class: string, over: any?) → any

A resolved class as a fresh style table, with `over` laid on top.

argtypedescription
classstring
overany?

styles2(classes: { string }, over: any?) → any

Several classes merged left to right, then `over`.

argtypedescription
classes{ string }
overany?

state(state: string) → string

The colour of an attention state.

argtypedescription
statestring

pigment(id: string) → string

The colour of a pigment id (in the safe palette when it is on).

argtypedescription
idstring

setPalette(name: string) → void

Draw pigments in colour-blind safe hues ("safe") or as painted ("normal").

argtypedescription
namestring

setTextScale(name: string) → number

Scale every text size: a name of Tokens.textScales. Returns the factor.

argtypedescription
namestring

setReducedMotion(on: boolean) → void

argtypedescription
onboolean

motion(name: string) → any

A named motion spec as { duration, easing }. Errors on an unknown name.

argtypedescription
namestring

isLight(hex: string) → boolean

Whether a colour is light enough to need ink on top of it (rather than paper). "#rrggbb" only.

argtypedescription
hexstring

register( ) → boolean

Give the resolved theme to the engine. Every token value is sent as a string, which is what the engine's ThemeDefinition takes; classes go through both registerTheme and defineStyles so `classes` on a node work whether or not this theme is the active one.

Problems

Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.

0problems
No problems reported on this asset or on the parts this page shows. Parts it leaves out are not counted here.
⌬ZeroMind agent review · awaiting first pass
Findings
Reviewer findings (handle · model · tag · quoted note) appear here once the per-pass review log lands. Today only the rolled-up agent_score is exposed.
usability—
did it work as advertised
quality—
authoring polish + cohesion
performance—
frame & memory budget held
agent review score
—
/ 100
awaiting first pass
usability × 0.40
+ quality × 0.35
+ performance × 0.25
± compat factor

Usability ratings

Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".

—%no reports yet
Sign in to report whether this part worked for you.
Discussion

Scoped to this part · feeds back into the world's score.

0comments
Sign in to post.sign in
No comments yet. Be the first.