Front end XWiki APIs
Description
Goal
Define for all non java resources:
- How do we mark an element public or internal?
- How do we deprecate them?
- How we do introduce a new element?
- How do we keep backward compatibility?
- What elements are public or internal
All non java resources:
- vms
- javascript API
- velocity macros
- CSS / LESS elements
Front end components
On Front End resources, we already have a list of components. The features![]()
![]()
, style
and architecture ![]()
of these components would be part of the API as they are meant to be exposed publicly, reused and augmented.
There's velocity macros bundled in the default flavor, some of them match the resources above.
DOM API
Any style attribute should never be considered as API: it's been a long time that we indicate in our documentation to not use inline style, so scripts should never rely on it, and it should always be ok to remove them in old code. Example of such change: https://github.com/xwiki/xwiki-platform/pull/2812/files/95f349912c19b66f00b684153dcf8be6ec526db1#r1504545037
The changes on this basic layout should be documented and backward compatible (CSS or DOM or both ?): https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/Tutorials/Skins/CSSLayout/
Discussed on https://forum.xwiki.org/t/front-end-api-html-ids/16947/4 :
Seems like using the `xwiki-` prefix on class and id names would make it clear classes and ids we consider as APIs (and also mean that all the others are not API and subject to changes
)) )
Here is the search I went with to find all of those classes and ids. It should be a bit too wide, finding a few things that are not of interest to us, but not miss any of the items we're looking for:
https://github.com/search?q=repo%3Axwiki%2Fxwiki-platform+%28language%3ACSS+OR+language%3ALess+OR+language%3Avelocity%29+%2F%5B%5C.%23%22%27%5Dxwiki-%2F&type=code
Good news, in XS, there's almost only classes starting with `xwiki-` and no useful IDs starting with `xwiki-`.
| Name | Semantics | Source filename | Keep in API? |
|---|---|---|---|
| .xwiki-whatsnew-container | Main node of the whatsnew template. | whatsnew.vm | Yes |
| .xwiki-whatsnew-item | Container for one piece of news displayed in the whatsnew template. | whatsnew.vm | No? |
| .xwiki-whatsnew-item-title | Title of one piece of news displayed in the whatsnew template. | whatsnew.vm | No |
| .xwiki-whatsnew-item-date | Publish date of one piece of news displayed in the whatsnew template. | whatsnew.vm | No |
| .xwiki-whatsnew-item-description | Content of one piece of news displayed in the whatsnew template. | whatsnew.vm | No |
| .xwiki-livedata | Container for a livedata | livedata webjar variables.less, general.less | Yes |
| .xwiki-flavor-select-small | Style only class for the flavorPicker | web template flavor macros.vm, picker.css | No? |
| .xwiki-flavor-select-medium | Style only class for the flavorPicker | web template flavor macros.vm, picker.css | No? |
| .xwiki-flavor-select-tall | Style only class for the flavorPicker | web template flavor macros.vm, picker.css | No? |
| .xwiki-flavor-picker | Main container of the flavorPicker velocimacro | web template flavor macros.vm, picker.css | Yes |
| .xwiki-flavor-picker-filter | Text input to filter entries displayed in the rich input of the flavorPicker velocimacro | web template flavor macros.vm, picker.css | No? |
| #xwiki-flavor-picker-progress-background | TODO, part of the flavorPicker velocimacro | web template flavor macros.vm | No? |
| #xwiki-flavor-picker-progress-bar | TODO, part of the flavorPicker velocimacro | web template flavor macros.vm | No? |
| .xwiki-flavor-picker-results-container | Container of the richselect used in the flavorPicker velocimacro. Style only class because repeated semantics with child? | web template flavor macros.vm, picker.css | No? |
| .xwiki-flavor-picker-noflavor | Button to not pick any flavor in the flavorPicker velocimacro | web template flavor macros.vm | No? |
| .xwiki-flavor-picker-results | Container of the richselect used in the flavorPicker velocimacro. | web template flavor macros.vm | No? |
| .xwiki-flavor-picker-option | Display of one flavor in the flavorPicker velocimacro. | web template flavor macros.vm, picker.css | No? |
| .xwiki-flavor-picker-option-selected | Display of one flavor in a specific state in the flavorPicker velocimacro. | web template flavor macros.vm, picker.css | No? |
| .xwiki-flavor-picker-option-icon | Icon of one flavor in the flavorPicker velocimacro. | web template flavor macros.vm, picker.css | No |
| .xwiki-livetable | Container of the table for the livetable. Does not include tagclouds and topfilters but does include pagination elements. | livetable.css, rightsUI.vm, flamingo misc.less, flamingo skin macros.vm, web templates macros.vm | No? |
| .xwiki-livetable-loader | Element displayed while waiting for a livetable content to be retrieved. | livetable.css, rightsUI.vm, flamingo skin macros.vm, web templates macros.vm | No |
| .xwiki-livetable-pagination | Container for the livetable pagination controls. | livetable.css, rightsUI.vm, flamingo skin macros.vm, web templates macros.vm | No? |
| .xwiki-livetable-pagination-content | Child of livedata-pagination. Probably layout only class. | livetable.css, rightsUI.vm, flamingo skin macros.vm, web templates macros.vm | No |
| .xwiki-livetable-pagination-text | Child of livedata-pagination. Probably layout only class. Quite an unspecific name... | livetable.css, rightsUI.vm, flamingo skin macros.vm | No |
| .xwiki-livetable-limits | Status of elements displayed currently in the livetable, next to pagination. | livetable.css, rightsUI.vm, flamingo skin macros.vm | No? |
| .xwiki-livetable-pagesize | Label and input to select the page size for a livetable, next to pagination. | livetable.css, flamingo skin macros.vm | No? |
| .xwiki-livetable-pagesize-content | Input to select the page size for a livetable, next to pagination. | flamingo skin macros.vm | No? |
| .xwiki-livetable-display-container | Main container for the livetable actual content. | livetable.css, rightsUI.vm, flamingo skin macros.vm | Yes? |
| .xwiki-livetable-display | Not sure? Could not find it quick. Might be layout only class and probably duplicated semantics with container... | livetable.css, rightsUI.vm, livetable.less, flamingo skin macros.vm | No? |
| .xwiki-livetable-display-header | thead of the live table. | livetable.css, rightsUI.vm, livetable.less, flamingo skin macros.vm | Yes? |
| .xwiki-livetable-display-header-text | Layout only class... elements in the first row of the thead | livetable.css, livetable.less, flamingo skin macros.vm | Yes? |
| .xwiki-livetable-display-header-filter | One filter in the second row of the thead. | livetable.css, xwiki.selectize.css, livetable.less | No? |
| .xwiki-livetable-display-filters | second row of the thead, containing filters. | livetable.css, livetable.less | Yes? |
| .xwiki-livetable-filter-active | Specific state on a livetable filter. | livetable.css | No |
| .xwiki-livetable-display-body | tbody of the livetable. | livetable.css, rightsUI.vm, livetable.less, flamingo skin macros.vm | No? |
| .xwiki-livetable-topfilters-container | Container for the optional HTML provided in the topFilters option | livetable.css, flamingo skin macros.vm | No? |
| .xwiki-livetable-tagcloud-container | Container for the optional tagcloud. Note that this contains a legacy icon still hardcoded... | livetable.css, flamingo skin macros.vm | No |
| .xwiki-livetable-tagcloud | Mostly used for layout/JS, no specific meaning added upon what's already meant by the container | livetable.css, flamingo skin macros.vm | No |
| .xwiki-livetable-topfilters-tip | Technical class added above the container, not sure what tip it's needed for though... Definitely internal | livetable.css, flamingo skin macros.vm | No |
| .xwiki-livetable-tagcloud-tip | Technical class added above the container, not sure what tip it's needed for though... Definitely internal | livetable.css, flamingo skin macros.vm | No |
| .xwiki-livetable-container | Container for live tables, | livetable.css, admin.less, general.less, flamingo skin macros.vm, web templates macros.vm | No? |
| .xwiki-livetable-initial-message | Container for a live table warning in the table head. | flamingo skin macros.vm, web templates macros.vm | No? |
| .xwiki-livetable-multilist | Container a specific kind of filter select node. | flamingo skin macros.vm, web templates macros.vm | No? |
| .xwiki-selectize-option | One entry int he selectize dropdown. | xwiki.selectize.css | No? |
| .xwiki-selectize-option-icon-wrapper | Layout only, duplicated semantics with selectize-option-icon | xwiki.selectize.css | No |
| .xwiki-selectize-option-icon | Icon used to represent one option | xwiki.selectize.css | No? |
| .xwiki-selectize-option-label | Anchor used for the name of the option | xwiki.selectize.css | No? |
| .xwiki-selectize-option-hint | Hint of the option? When selecting a page, this is the path to navigate to this page | xwiki.selectize.css | No? |
| .xwiki-select | Main node of the xwikiSelect component | web templates macros.vm, select.css | Yes |
| .xwiki-select-options | Container for all options in the rich select input component xwikiSelect | web templates macros.vm, select.css | Yes? |
| .xwiki-select-small | Styling only class, no semantics | select.css | No |
| .xwiki-select-medium | Styling only class, no semantics | select.css | No |
| .xwiki-select-tall | Styling only class, no semantics | select.css | No (would need a rename to use `large` instead of `tall`) |
| .xwiki-select-adaptable-medium | Styling only class, no semantics | select.css, createinline.vm | No |
| .xwiki-select-option | Option in the rich select input component xwikiSelect | web templates macros.vm, select.css | Yes? |
| .xwiki-export-3-columns | Styling only class, no semantics | export_modal.vm, select.css | No |
| .xwiki-select-option-icon | Icon of the option in the rich select input component xwikiSelect | web templates macros.vm, select.css | No? |
| .xwiki-metadata-container | Technical class for inline editable properties in inline edit mode. | messages.less | No |
| .xwiki-select-option-highlighted | Status for option in xwikiSelect | flamingo misc.less | No |
| .xwiki-select-option-selected | Status for option in xwikiSelect | flamingo misc.less | No |
| .xwiki-form-listclass | Class used on the label of a form listclass field? Could not find doc, name is not clear to me (because too generic) | forms.less,delete.vm | No |
| .xwiki-export-formats | This is a class but could is only used to identify one element in the content of the export modal. | export_modal.vm | No? |
| .xwiki-select-3-columns | Style only class. Could probably be factorized with xwiki-export-3-columns... | export_modal.vm | No |
| .xwiki-select-filter | Text input to filter entries displayed in the rich input of xwikiSelect | web templates macros.vm | Yes? |
| .xwiki-select-category | Group of options in the rich select input component xwikiSelect | web templates macros.vm | Yes? |
| .xwiki-select-category-count | Count display for the group of options in the rich select input component xwikiSelect | web templates macros.vm | No |
I (CharpentierLucas) used four types of annotations when commenting my idea of whether we should keep those in the API:
- Yes: Keep it in the API, the class is common and nicely named, I expect it to be used in a lot of customizations. The class has a clear meaning for an existing concept.
- Yes? : Can keep it in the API, not strongly against removing it. The class is clear, but usually it's not really useful for much, selectors can already rely on another class.
- No? Should probably remove from the API (renaming the class), but not strongly opposed to keeping it. The class is never useful for customization IMO, poorly worded or very specific with easy selectors on the parent. Often those classes are used in XS only for a couple styles.
- No: Should remove from the API, keeping good support and backward compatibility for those will have a relatively high timecost for relatively low usefulness. The class is either very poorly worded, its scope is very very specific and it's purely cosmetic. In order to apply styles, XS developers should instead use 1. a standard styling class. 2. a non API custom class.
IMO it'd make sense we only support classes as API for now, most of XS interface element IDs do not have any naming rules.
What should we support?
For every single class starting with xwiki- in XS, we ensure that we keep backward compatibility on:
- the node architecture under it (node nature + how they are nested/ordered)
- the styles associated to this class
- the styles associated to the expected children of this class
I don't think it's a good idea to engage ourselves to respect backward compatibility on:
- the content of this element and its children
- the attributes of this element and its children
The first one is very often contained in a translation, which AFAIK are not API (i.e. we can edit them without making an announcement and waiting for feedback). The second one should be something only XS relies on IMO. Customizations don't need it much, and it's very difficult to make any change to the UI if we block ourselves on this. Customizations shouldn't need to rely on those, either they have enough with the class and node structure, or they use their own component. E.g. if I want to style livetable, I can make CSS selectors with the API classes and the way their children are arranged. If I want to have a custom script run when a livetable filter is selected, what I'm doing is an extension of the livetable behaviour, and the XS devs can't assure full backward compatibility for this one (if for one reason or another, we need to remove the `selected` attribute, it won't go through the API breakage process).
CSS API
Elements to include in the API:
1. Bootstrap 3 classes: used everywhere, for a long time. When moving to a new design system, we want to consider how to keep support for those classes. E.g. `.btn`, `.btn-default`, ...
2. Special CSS classes defined in https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/SpecialCSSClasses/
Javascript API
Already pretty well defined in https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/JavaScriptAPI/
Resources
Previous research about defining a CSS API: https://design.xwiki.org/xwiki/bin/view/Standards/CSSAPI
Lucas Charpentier
Simon Urli