Page MenuHomePhabricator

Provide a CSS framework for positioning elements at the edge of the "viewport"
Open, Needs TriagePublic

Description

Many extensions and gadgets position fixed elements relative to the edge of the viewport, using CSS position:fixed or position:sticky.

In vector-2022 (and some unsupported skins) there may be sticky elements that are part of the core skin, that get in the way of elements that may be positioned there (such as happened in T318474).

One solution to this would be to provide a CSS framework for positioning elements at the various edges of the viewport:

.mw-viewport-top {
  top: 0;
}
.mw-viewport-bottom {
  bottom: 0;
}
// -left, -right

Extra spacing from those edges could be achieved with margin, padding or translate.

Skins that implement sticky features could override these, e.g. vector-2022 could set the following when the sticky header is visible:

.mw-viewport-top {
  top: 50px;
}

Originally reported:

It’s also (and still) broken on Timeless, except that it’s not visible at all, since the Timeless sticky header isn’t transparent. Couldn’t we have a more general solution, which fixes Vector and Timeless as well as any third-party skins that have sticky headers?

Event Timeline

We have special handling for elements with the class mw-sticky-header-element. If the button has that class and it doesn't work, web team will look into it. The patch in https://gerrit.wikimedia.org/r/c/mediawiki/extensions/DiscussionTools/+/834641/3/modules/dt.ui.ReplyWidget.less#58 is likely to break in future as we plan to change the height of the sticky header (T314328) so please use the class which we support as a stable API.

Thanks, I see that was implemented in T289817. It looks like mw-sticky-header-element implements mw-viewport-top as described in this task, so that is probably good enough for now as there aren't common skin features that stick stuff to other parts of the viewport.

Timeless should implement this class too (cc @Isarra @matmarex)

I'm not sure the current name does the best job of describing what the class does though.

Also, as in the description, this class should be defined and documented in core, with a default value of top: 0.