Citizen MediaWiki Skin
website·Indexed 30 days ago
https://mwcitizen.skinA modern skin for MediaWiki featuring a keyboard-driven command palette, progressive web app (PWA) support, and a performance mode. Documentation covers installation, configuration, theming, and JavaScript hooks for extending functionality via gadgets and extensions.
What's inside Citizen
- The Citizen preferences panel allows readers to personalize the skin (e.g., theme, font size, page width). It is lazy-loaded to optimize initial page load. Configuration can be extended using on-wiki JSON (managed by admins) or a JavaScript API (for gadgets and user scripts). Changes to configuration take effect the next time the panel is opened without requiring a cache purge.
Overview of the Citizen MediaWiki skin
Citizen is an open-source, responsive MediaWiki skin designed to provide a modern interface where extensions are integrated into a cohesive user experience. Originally developed for the Star Citizen Wiki, it is designed to be flexible and compatible with various MediaWiki configurations.Prevent wide elements from pushing the page sideways with overflow handling
Citizen prevents wide elements (such as tables and code blocks) from forcing the entire page to scroll horizontally. Instead, it confines the sideways scrolling to the element itself. This is enhanced with navigation buttons for mouse/trackpad users and soft-fade scroll indicators at the edges of the content.Use the Command Palette for wiki navigation
The command palette is a keyboard-driven launcher used to jump to pages, run actions, and search the wiki. Press/to see all available entries or start typing to search. The palette consists of two entry types: Modes, which change the search context (indicated by a specific icon and placeholder), and Commands, which execute an action immediately upon selection.Use Semantic MediaWiki structured queries in the command palette
When Semantic MediaWiki is installed, Citizen automatically adds an Ask query mode to the command palette. Users can type/smw:to build structured queries with autocomplete support for properties, categories, and values.Understand Citizen Performance mode behavior
Performance mode is a skin-level toggle designed to make the wiki feel fast on any device. When enabled, it performs the following actions:
- Disables all site-wide transitions and animations (including those from custom styles).
- Disables smooth scrolling.
- Removes frosted-glass effects, such as the mobile header overlay.
By default, Citizen detects WebGL support on the first page load to determine if the device is capable of full visuals. This result is cached in the browser, but users can manually override this setting in their preferences.
Use ShortDescription for page titles and search results
The ShortDescription extension displays a brief description under the page title and within command palette results. If both ShortDescription and TextExtracts are installed, ShortDescription takes priority.Manage search tags in the command palette
Certain modes convert query parts into tags (e.g.,
Talk:becomes a namespace tag).- Select tag: Press Backspace on an empty input to highlight the last tag.
- Edit tag: Press Backspace a second time to convert the tag back into editable text to fix typos without retyping the entire query.
Migrate Command Palette registrations to the new API
Key changes include:
- Hook renamed from
skins.citizen.commandPalette.registerCommandtocitizen.commandPalette.register. - Callback method changed from
registerCommandtoregister. - Property
onCommandSelectrenamed toonResultSelect. - The
typeproperty should now be set on individual result items rather than the command object.
// BEFORE (Deprecated) mw.hook( 'skins.citizen.commandPalette.registerCommand' ).add( function ( data ) { data.registerCommand( myCommand ); } ); // AFTER (Current) mw.hook( 'citizen.commandPalette.register' ).add( function ( data ) { data.register( myCommand ); } );- Hook renamed from
Prevent first-paint jank with the animations-ready class
Citizen prevents transitions from firing during initial page load to avoid elements sliding around. The.citizen-animations-readyclass is added to the<html>element once deferred startup is complete. Gate your custom transitions under this class to ensure a smooth initial render..citizen-animations-ready .my-element { transition: opacity var( --transition-duration-medium ); }Register preferences using JavaScript
Use thecitizen.preferences.registerhook to programmatically add sections and preference entries to the preferences panel. Theregisterfunction accepts a configuration object containingsectionsandpreferences. Becausemw.hookreplays data to late subscribers, the registration will work regardless of when the script loads. The panel is reactive and updates in place without requiring a page reload.mw.hook( 'citizen.preferences.register' ).add( function ( register ) { register( { sections: { gadgets: { label: 'Gadgets' } }, preferences: { 'gadget-enhanced-rc': { section: 'gadgets', type: 'switch', options: [ '0', '1' ], label: 'Enhanced recent changes', description: 'Use the enhanced recent changes interface' } } } ); } );Enable CSS variables in TemplateStyles
If you use the TemplateStyles extension, install TemplateStylesExtender to enable the use of CSS variables, including Citizen's design tokens, within your styles.