-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature suggestion: use mw.user.clientPrefs library and consistent classes with evolving skins #780
Comments
Thank you for the detailed message! As for Because Citizen has to maintain support for the latest MW LTS (1.39), this will be implemented on the next MW LTS stable release, along with a proper implementation of Codex design tokens. However, I am able to add the night mode classes right away if that is already standardized and ready for adoption.
The most important lesson that I learned was that: Because skins can't control most of the UI, skins need provide means to create a cohesive UI. I'm sure that you realized too because it is a recurring theme on WMF Phabricator for dark mode and DIP. Skins are only responsible for the outer frame of a page.
|
Regarding content styles - yes very similar approach is planned for Wikimedia with the caveat that currently TemplateStyles does not support CSS variables (https://phabricator.wikimedia.org/T320322) For extensions/MW core styles we plan to make use of Codex design tokens (we are currently exploring making them accessible as CSS variables in https://phabricator.wikimedia.org/T356537) A sneak peek of our incremental progress can be seen here: https://m.mediawiki.org/?minervanightmode=1 |
…ntPrefs This is the first step of migrating to the clientPrefs library when it is avaliable. Currently only themes are using it and the standard classes are added to the HTML element. Related: #780
Since clientPrefs and other related features are not avaliable until MW 1.42, many of them are backported as polyfill. Instead of using cookies, the polyfill are using localStorage only like Citizen in the past. There are many changes behind the scene, but the most important one being that `skin-citizen-*` theme classes are now soft-deprecated, and replaced by the standardized `skin-theme-clientpref-*` classes. There will be sufficient time before the hard deprecation. Related: #780
Since |
Also heads up after feedback the class has changed to skin-theme-clientpref-night and skin-theme-clientpref-os for night mode in Vector and Minerva. We realized we were making a theming system and were asked to have human readable classes instead of 0,1 and 2. |
Thanks for the heads-up! I have read the relevant patches and the new classes are the version that we implemented. On a side note, would the i18n messages for the theme ( |
Sorry for the delayed reply. There are no plans right now to move these messages to core as they are tied to the Vector and Minerva skins. If there was a way we could abstract things that made sense we could explore that. Are you planning to load the same controls in Citizen or will you continue to use your own interface? If the latter it is probably best to prefix - i believe translatewiki allows you to sync your messages with another message key. |
Apologies I have totally missed the reply. I was revising client prefs and found out about this comment.
We'll probably use our own interface for now since we are planning to support more themes in the future. On a side note, is there any plans to integrate client prefs into core in MW 1.43? |
There is a nice write up about this API from the MediaWiki platform team who maintain it at https://phabricator.wikimedia.org/T345664#9564663. - if you have any feature requests please feel free to request them!
If you want to use them or experiment using them we have an npm library (@wikimedia/mediawiki.skins.clientpreferences) for skins that you can make use of. |
The Problem
You don't need to do anything here, but you might benefit from the upstream changes that are occurring!
We've started implementing night mode in Vector 2022 and Minerva and one thing we're trying to do as part of that is standardize classes across skins for how night mode should behave.
You may want to use the same class names on the HTML element and the same API (mw.user.clientPrefs) for managing the mode for anonymous users (it works very similar to your existing window.applyPref)
Let me know if you have any questions or curiosities or lessons learned from implementing night mode in Citizen!
You can check out the following patches to see how night mode is evolving in the Minerva skin:
The Solution
The classes we've landed on are skin-night-mode-clientpref-0 (night mode disabled) = skin-night-mode-clientpref-1 (night mode enabled), skin-night-mode-clientpref-2 (automatic night mode)
The benefit of using this class is that you can make night mode persist for anonymous users.
e.g. calling `mw.user.clientPrefs.set( 'skin-night-mode', '1' ); should enable night mode and persist it for anonymous users.
The text was updated successfully, but these errors were encountered: