mediawiki-skins-Vector/resources/common/components/MenuDropdown.less
Jan Drewniak 3c0559a71d Refactor chevron across components + separate watchstar
Consolidates the CSS responsible for styling chevrons into one
implementation. This removes the need for custom padding and
background positioning for the following components:

- "more" menu
- user menu
- watchstar
- language button
- languge button in sticky header

Instead of absolutely positioning the chevron on these components,
the parent label element is set to `display: inline-flex` so that
the chevron is vertically aligned and given enough space by default.

The watchstar, although not a chevron, is also given the
`display: inline-flex` treatment so that it can be aligned with
other elements in the toolbar.

This new implementation requires splitting the watchstar
component into legacy and modern due to a quirk in Firefox that
causes a bug with the watchstar in legacy Vector.

NOTE: This change causes visual changes due to the difference in
centering the chevrons via flexbox vs percentage positions.

Bug: T308344, T310838
Change-Id: Ie9e0fce1366cd25a5899fee49770de4a09424fe2
2022-07-21 10:14:21 -04:00

131 lines
2.8 KiB
Plaintext

@import '../variables.less';
@import 'mediawiki.mixins.less';
/**
* Targets:
* - language variants, Actions menus
* - more menu, user menu
* - ULS button in sticky header
*/
.emptyPortlet .vector-menu-heading,
.vector-menu-dropdown .vector-menu-heading,
.mw-interlanguage-selector {
display: flex;
color: @color-base--subtle;
&:after {
content: '';
background: url( images/arrow-down.svg ) 100% 50% no-repeat;
width: unit( 16 / @font-size-tabs / @font-size-browser, em );
height: unit( 16 / @font-size-tabs / @font-size-browser, em );
// Modify the color of the image from the default #202122 to approx. #404244 to match the text.
opacity: 0.84;
}
&:hover,
&:focus {
color: @color-base;
&:after {
opacity: 1;
}
}
}
.vector-menu-dropdown {
direction: ltr;
float: left;
cursor: pointer;
position: relative;
// The menu itself.
.vector-menu-content {
background-color: @background-color-base;
list-style: none;
line-height: 1.125em;
// Match the width of the dropdown "heading" (the tab)
min-width: 100%;
position: absolute;
top: 100%;
left: -@border-width-base;
margin: 0;
border: @border-width-base @border-style-base @border-color-base;
padding: 0;
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
text-align: left;
opacity: 0;
visibility: hidden;
transition-property: opacity;
transition-duration: @transition-duration-base;
z-index: @z-index-menu;
}
// Hide and show menu content based off checked status.
.vector-menu-checkbox:checked ~ .vector-menu-content {
opacity: 1;
visibility: visible;
}
ul {
// display list style images introduced in typography.less.
list-style: none;
}
li {
padding: 0;
margin: 0;
text-align: left;
line-height: 1em;
a {
padding: 0.625em;
color: @color-link;
display: block;
white-space: nowrap;
cursor: pointer;
}
}
.selected a,
.selected a:visited {
color: @color-link-selected;
text-decoration: none;
}
}
// Invisible checkbox covering the dropdown menu handle
.vector-menu-checkbox {
cursor: pointer;
position: absolute;
top: 0;
left: 0;
z-index: @z-index-menu-checkbox;
opacity: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
// Hide the checkbox completely in browsers that don't support :checked
display: none;
:not( :checked ) > & {
// When the browser supports :checked, display it
display: block;
}
}
.vector-menu-dropdown-noicon {
.vector-menu-heading {
// `padding-top` needs to scale with font-size.
padding: 1.25em 8px 6px;
font-weight: normal;
}
// Add focus state to legacy menu dropdown buttons (i.e. p-variants, p-cactions)
.vector-menu-checkbox:focus + .vector-menu-heading {
// Simulate browser focus ring
outline: dotted 1px; // Firefox style
outline: auto -webkit-focus-ring-color; // Webkit style
}
}