Module Configuration
Module Name:skins.citizen.preferences
Dependencies:
skins.citizen.preferences.codexmediawiki.storagemediawiki.utilvue
CdxFieldCdxIconCdxRadioCdxSelectCdxToggleSwitch
resources/skins.citizen.preferences/init.js
Initialization
The preferences module lazy-loads when the preferences button is first clicked:Automatic Initialization
The module auto-initializes on load:Architecture
Configuration System
Preferences use a structured configuration format:Default Configuration
Built-in preferences fromdefaultConfig.js:
Sections:
appearance- Visual appearance settingsbehavior- Interaction behavior settings
-
skin-theme - Theme selection
- Options:
os(Auto),day(Light),night(Dark) - Type: radio
- Section: appearance
- Options:
-
citizen-feature-custom-width - Page width
- Options:
standard,wide,full - Type: radio
- Section: appearance
- Options:
-
citizen-feature-custom-font-size - Font size
- Options:
small,standard,large,xlarge - Type: radio
- Section: appearance
- Options:
-
citizen-feature-pure-black - Pure black theme
- Type: switch
- Visibility:
dark-theme - Section: appearance
-
citizen-feature-image-dimming - Image dimming in dark mode
- Type: switch
- Visibility:
dark-theme - Section: appearance
-
citizen-feature-autohide-navigation - Auto-hide navigation
- Type: switch
- Section: behavior
-
citizen-feature-performance-mode - Performance mode
- Type: switch
- Section: behavior
Configuration Registry
FromconfigRegistry.js:
mergeConfigs(base, override)
Deep merges two configuration objects. Parameters:base(PreferencesConfig) - Base configurationoverride(PreferencesConfig) - Override configuration
normalizeConfig(config)
Normalizes and validates configuration. Parameters:config(PreferencesConfig) - Raw configuration
resolveLabel(obj, key)
Resolves label from message key or string. Parameters:obj(Object) - Object containing labelkey(string) - Key name (labelordescription)
Vue Components
App.vue
Root preferences component. Injected Props:preferencesConfig(NormalizedPreferencesConfig) - Reactive configthemeDefault(string) - Default theme value
sections- Computed sections with preferences
values(reactive) - Current preference valuesvisibilities(reactive) - Preference visibility states
featureName(string) - Preference keyvalue(string) - New value
- Updates
mw.storage - Fires
mw.hook('citizen.preferences.changed') - Dispatches window
resizeevent
RadioGroup.vue
Custom radio group component with theme preview. Props:modelValue(string) - Current valueoptions(Array<Option>) - Radio optionsfeatureName(string) - Preference keycolumns(number) - Number of columns (default: 2)
update:modelValue- Value changed
- Shows color preview for theme options
- Grid layout with configurable columns
- Uses CdxRadio components
Client Prefs Polyfill
FromclientPrefs.polyfill.js:
Provides compatibility with MediaWiki’s client preferences system.
clientPrefs()
Factory function returning client prefs interface. Methods: get(featureName) Gets preference value from storage or document. Parameters:featureName(string) - Preference key
featureName(string) - Preference keyvalue(string) - New value
- Updates
mw.storage - Updates document root classes
- Fires hooks
Visibility Composable
FromuseVisibility.js:
useVisibility(condition, themeValue)
Computes visibility based on condition. Parameters:condition(string) - Visibility condition (always|dark-theme)themeValue(Ref<string>) - Current theme value
always- Always visibledark-theme- Visible when theme isnight(notosorday)
Hooks
citizen.preferences.register
Allows extensions/gadgets to add preferences dynamically. Callback:citizen.preferences.changed
Fired when any preference changes. Parameters:featureName(string) - Changed preference keyvalue(string) - New value
Storage
Preferences are stored in:- MediaWiki Storage:
mw.storage.set('skin-client-pref-{featureName}', value) - Document Classes: Applied to
<html>element asskin-{featureName}-clientpref-{value}
Configuration Variables
Fromskin.json:
- wgCitizenEnablePreferences (boolean) - Enable preferences panel (default: true)
- wgCitizenThemeDefault (string) - Default theme (
auto|light|dark, default:auto)
Theme Preview Colors
The App component reads computed CSS properties for theme previews:Styling
Key CSS classes:.citizen-preferences- Main container.citizen-preferences-section- Section wrapper.citizen-preferences-section__heading- Section heading.citizen-preferences-section__content- Section content.citizen-preferences-group- Individual preference
Testing
The module exportsinitApp for testing:
Related Modules
- Scripts - Core skin scripts that initialize preferences
- Command Palette - Another Vue-based module