mediawiki-skins-Vector/resources/skins.vector.styles/VectorMenu.less
Nicholas Ray 9823538683 Isolate Vector Styles to their Respective Component
This will help with the encapsulation/reusability of each component.

* Stylesheets were renamed to reflect their respective component name
(e.g. search.less became SearchBox.less)

* Styles were isolated to each component:

* navigation.less now only contains classes that are relevant to
Navigation.mustache.
  * personalNavigation.less, search.less, and tabs.less
    imports were removed and made first-class styles.
  * several selectors were moved into common.less
  * #p-logo was moved into sidebar

* tabs.less was renamed to VectorTabs.less and styles specific to
VectorMenu.less were put into VectorMenu.less

* Storybook was updated to reflect changes

Bug: T243281
Change-Id: Idf90ee2a0f1c1d08a31cf50099c0bebc7b67e619
2020-03-03 18:20:19 +00:00

161 lines
4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

@import '../../variables.less';
@import 'mediawiki.mixins.less';
/* Variants and Actions */
.vectorMenu {
direction: ltr;
float: left;
cursor: pointer;
position: relative;
line-height: 1.125em;
h3 {
color: @color-nav-subtle;
position: relative;
display: block;
.box-sizing( border-box );
// `padding-top` needs to scale with font-size.
padding-top: 1.25em;
padding-left: 8px;
padding-right: unit( 24 / @font-size-tabs / @font-size-browser, em );
font-size: @font-size-tabs;
font-weight: normal;
&:after {
content: '';
.background-image-svg( 'images/arrow-down.svg', 'images/arrow-down.png' );
background-position: 100% 50%;
background-repeat: no-repeat;
position: absolute;
top: unit( 10 / @font-size-tabs / @font-size-browser, em );
right: 8px;
bottom: 0;
width: unit( 16 / @font-size-tabs / @font-size-browser, em );
// Modify the color of the image from the default #222 to approx. #444 to match the text.
opacity: 0.85;
}
&:hover,
&:focus {
color: @color-base;
&:after {
opacity: 1;
}
}
}
.menu {
background-color: @background-color-base;
list-style: none none;
// Match the width of the dropdown "heading" (the tab)
min-width: 100%;
position: absolute;
top: 2.5em;
left: -@border-width-base;
margin: 0;
border: @border-width-base @border-style-base @border-color-base;
border-top-width: 0;
padding: 0;
box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
text-align: left;
opacity: 0;
visibility: hidden;
.transition( opacity 100ms );
// Menus must overlap indicators (z-index: 1) and VisualEditor toolbar (z-index: 2)
z-index: 2;
}
&:hover .menu {
opacity: 1;
visibility: visible;
}
// This is in a separate block, so that browsers supporting :hover but not :checked still apply the rule above
// Support: IE8
.vectorMenuCheckbox:checked ~ .menu {
opacity: 1;
visibility: visible;
}
li {
padding: 0;
margin: 0;
text-align: left;
line-height: 1em;
a {
color: @color-link;
display: block;
padding: 0.625em;
white-space: nowrap;
cursor: pointer;
font-size: @font-size-tabs;
}
}
.selected a,
.selected a:visited {
color: @color-link-selected;
text-decoration: none;
}
}
#mw-head .vectorMenu h3 {
// Tab separator: Outer end (right in LTR) border of "Actions" menu.
background-position: right bottom;
float: left;
height: unit( 40 / @font-size-tabs / @font-size-browser, em );
margin: 0 -@border-width-base 0 0;
// `padding-right` >= `1px` effectively moves the "background border" outside of the element to
// act like a real border. It is necessary for `.vectorMenu .menu` dropdown to align well.
// 0.5em equals `8px` at computed `font-size` of `14px` as visually harmonically with
// `padding-left` in `.vectorMenu h3 a`
padding-right: unit( 24 / @font-size-tabs / @font-size-browser, em );
}
// Tab Separators
// `.vectorTabs`: Outer start border (left in LTR) of tab row.
// `.vectorTabs a`: Border between tabs and outer end (right in LTR) border.
// `#mw-head .vectorMenu h3`: // Outer end (right in LTR) border of "Actions" menu.
.vectorTabs,
.vectorTabs a,
#mw-head .vectorMenu h3 {
background-image: url( images/tab-separator.png );
background-image: linear-gradient( to bottom, rgba( 167, 215, 249, 0 ) 0, @border-color-content 100% );
background-repeat: no-repeat;
// Contain gradient to 1px × 100% size and draw from top to bottom-left or -right corner.
background-size: @border-width-base 100%;
}
// Invisible checkbox covering the dropdown menu handle
.vectorMenuCheckbox {
cursor: pointer;
position: absolute;
top: 0;
left: 0;
z-index: 1;
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;
}
&:checked + h3:after {
transform: scaleY( -1 );
}
&:focus + h3 {
// Simulate browser focus ring
outline: dotted 1px; // Firefox style
outline: auto -webkit-focus-ring-color; // Webkit style
}
}