Existing components
MediaWiki community:
- WVUI (used in Vector search, NearbyPages, GlobalWatchlist)
- MediaSearch (styles; copy used in WikiLambda)
- ContentTranslation
- Wikit
- Wikidata bridge
External libraries:
Wikimedia Design Style Guide links:
Implementation decisions
Primary style
- WVUI: Primary is one of three possible values for the type param (the others are "normal" and "quiet"). These types are captured in a ButtonType enum.
- Wikit: styles primary buttons exactly as prescribed in the design style guide, but it ignores type="progressive" or type="destructive" if the button doesn't also have variant="primary" or variant="quiet"
- MediaSearch: allows progressive/destructive buttons to be primary (white text on blue/red background) or non-primary (blue/red text on white background).
- CX: primary by default, but it supports the non-primary style through type="text"
- Wikidata Bridge: button is always primary when it is progressive.
Setting the action type and quietness
- WVUI: the button takes an action prop that can be set to default, progressive or destructive, and defines a TypeScript enum for this. As mentioned above, quiet is one of the three ButtonTypes that can be set via the type prop.
- Wikit: the button takes a type prop that can be set to neutral, progressive or destructive, and a variant prop that can be set to normal, primary or quiet. Even though Wikit is written in TypeScript, it doesn't use TypeScript types for these, they just take a string and use a validator.
- MediaSearch: similar to CX, the button takes progressive, destructive, and primary as boolean props, as well as a boolean frameless prop (which appears to be the same concept as "quiet").
- CX: the button takes progressive and destructive as boolean props; it doesn't have quiet buttons as such, but buttons with type="text" or type="icon" look similar (there is also an outlined prop but I'm not sure what it does).
- Wikidata Bridge: the button takes type="primaryProgressive", and does not support destructive (or non-primary progressive); it supports something similar to quiet buttons with type="link" (and type="close" and type="back"` are icon-only quiet buttons).
Other display modes
- Wikit: the button takes an icon-only prop.
- CX: the button takes type="icon" to make a button quiet and icon-only, type="text" to make it quiet and text-only, type="toggle" (which doesn't seem to do anything); it also takes a boolean prop large to make it bigger, and boolean outlined and depressed props whose behavior is unclear to me.
- Wikidata Bridge: the button takes a size prop (set to M, L or XL) and a squary prop (unclear what that does).
Which HTML tag to use / link support
- WVUI, Wikit, and MediaSearch: always use <button>
- CX: uses an <a> if the href prop is set, and a <span> otherwise
- Wikidata Bridge: always uses an <a> with a <span> inside it, and takes an href prop and and props to make the link open in a new tab (opens-in-new-tab) or prevent the href from being followed (prevent-default).
Setting the disabled state
- WVUI and Wikit: these implementations don't have a disabled prop, so setting them to disabled sets the native attribute on the <button>, which they then style through the :disabled selector.
- MediaSearch: has a disabled prop, but it's superfluous since it's only used to set the native attribute.
- CX and Wikidata Bridge: these implementations have a disabled prop, and set a CSS class on the button when it's disabled, in order to style it differently.
How content is injected
- WVUI: allows any content to be injected through a slot, and does not have explicit support for icons; a button with an icon can be made by manually passing in an icon as part of the slot content.
- Wikit: works the same way, but it also takes an icon-only prop that styles the button differently.
- MediaSearch: accepts arbitrary content via a slot, but also takes an icon prop that adds the specified icon before the slot content.
- CX: renders an icon, a plain text label and an indicator (smaller secondary icon) by default, but allows arbitrary content to be injected through a slot, which overrides all of that.
- Wikidata Bridge: only accepts text, through the message prop; it does not support arbitrary content, and support for icons is limited (type="back" and type="close" make the button icon-only with a pre-set icon).
How the icon color is controlled
- WVUI: button doesn't manage icons explicitly, so color-coordinating the icons is left up to the caller
- WiKit, MediaSearch, and CX: icon component uses inline SVG with fill="currentColor", so setting the text color (to blue for progressive, red for destructive, or white for primary) also changes the icon color.
- Wikidata Bridge: doesn't support changing the color of the icon.
Invisible label text
- WVUI and Wikit: don't put in their own icons or labels, so this feature isn't relevant for them.
- MediaSearch: takes an invisibleLabel prop that causes the label to be rendered but hidden (this is desirable for icon-only buttons, for accessibility reasons).
- CX: doesn't have this feature, the label isn't rendered at all for icon-only buttons.
- Wikidata Bridge: does this automatically when type="back" or type="close" are used (both result in an icon-only button).