API / Minn\Admin / Appearance

Appearance final readonly class

Minn\Admin\Appearance · public/minn/src/Minn/Admin/Appearance.php · 82 lines

A person's Minn Admin appearance: the colour scheme and its custom token maps, stored where the app stores them (user meta minn_admin_appearance, a serialized array) so the choice survives an eject. The two WordPress-era switches, "Minn is the default admin" and "Minn admin bar on the site", are always on here: there is no other admin and no other bar, so the engine reports them true and ignores writes to them.

Constants and properties

constMETA = 'minn_admin_appearance'
constSCHEMES = array ( 0 => 'minn', 1 => 'ocean', 2 => 'forest', 3 => 'amber', 4 => 'rose', 5 => 'coral', 6 => 'teal', 7 => 'slate', 8 => 'dusk', )
constSLOTS = array ( 0 => 'bg', 1 => 'bg2', 2 => 'panel', 3 => 'panel2', 4 => 'hover', 5 => 'border', 6 => 'border2', 7 => 'text', 8 => 'text2', 9 => 'text3', 10 => 'accent', 11 => 'accent2', 12 => 'accentFg', )

Scheme slots in the order the app lists them.

constBASE = array ( 'dark' => array ( 'bg' => '#0b0b0d', 'bg2' => '#101013', 'panel' => '#151518', 'panel2' => '#1b1b1f', 'hover' => '#202027', 'border' => '#242429', 'border2' => '#31313a', 'text' => '#ececed', 'text2' => '#9d9da7', 'text3' => '#63636d', 'accent' => '#6e62f5', 'accent2' => '#8a80f8', 'accentFg' => '#ffffff', ), 'light' => array ( 'bg' => '#f6f6f7', 'bg2' => '#ffffff', 'panel' => '#ffffff', 'panel2' => '#f4f4f6', 'hover' => '#eeeef1', 'border' => '#e7e7ea', 'border2' => '#dadade', 'text' => '#1a1a1f', 'text2' => '#5e5e69', 'text3' => '#9696a0', 'accent' => '#6a5ef2', 'accent2' => '#5a4ef0', 'accentFg' => '#ffffff', ), )

The app's own Minn tokens, the fill for incomplete custom maps.

privatereadonly Minn\Content\Users $users

Promoted from the constructor.

Public

new__construct(Minn\Content\Users $users)#
methodread(int $userId): array#

A user's saved appearance, normalised.

@return array{scheme: string, custom: array, defaultAdmin: bool, frontBar: bool, font: string}
methodsave(int $userId, array $raw): array#

Merges the given keys over the stored map and writes it back; returns the normalised result.

staticnormalise(array $raw): array#

The appearance with every field valid and every missing one defaulted.

statichex(string $value): string#

#rgb or #rrggbb to lowercase #rrggbb, or '' for anything else.