The Codex component library is primarily developed as a set of Vue.js components, meaning that users must have JavaScript enabled in their browser in order to interact with them properly. However, Codex will ultimately need to support a variety of use-cases where JS is either not available at all, or at least is not available immediately.
For these situations, our solution thus far has been to provide a collection of CSS-only components. For most Codex components, we ensure that the styles can be used independently from the Vue.js component code in order to create a "static" component in HTML and CSS that matches the "dynamic" Vue-based version. This is useful for presenting the user with a server-rendered interface that matches what they might see when the full JS-based UI initializes (which may happen some time after the initial page load, depending on various factors). This also allows developers to use Codex components in places where they cannot (or don't wish to) use JS for whatever reason.
Thus far, the developer experience of using CSS-only components has been less than ideal. We provide example markup on the Codex docs site that users must copy and paste into their own applications (potentially with some modifications, especially where things like HTML form submission is involved). This has been okay for small-scale adoption of CSS-only components in some parts of the MediaWiki ecosystem, but we must clearly do better here if we want to enable wider usage of Codex components in PHP-driven user interfaces. In the past we've discussed this problem (see T326850 and T330469) but so far we have not invested much time and energy into addressing it.
We have an opportunity now to make serious progress in this area. Volunteer developer @Dogu has put together a comprehensive prototype of a stand-alone PHP library that generates most of the existing Codex CSS-only components. After some discussion (T372811), the design system team has decided to adopt this prototype as another piece of the Codex design system. We will work with @Dogu and other members of the WMF developer community to move this code into the official Codex repo, conduct review and testing of the code-base, and (eventually) publish this code on Composer as a library that any PHP project can include. We will also maintain this code going forward (though support from the wider community will be particularly welcomed in this area, as the DST team skews more to the front-end in terms of experience and expertise).
We hope that this project will greatly simplify the process for both WMF and community developers to use Codex components in their projects, regardless of whether or not they are presenting rich JS applications to their users.
Engineering driver: @egardner
Steps
- Finalize the draft ADR about Codex PHP (T372811)
- Set up a new workspace within the Codex mono-repo in Gerrit suitable for @Dogu's initial Codex PHP code (https://gerrit.wikimedia.org/r/c/1069297)
- Prepare this codebase for the initial round of code review
- Initial round of code review (T373939)
- Put out a call for feedback internally
- Make necessary revisions, adding tests, demos, and documentation where necessary
- Publish an initial release in Composer (T376059)
- Announce initial release (T378363)