mediawiki-skins-Vector/resources/skins.vector.styles/components/TableOfContentsUnpinned.less

182 lines
6.1 KiB
Plaintext
Raw Normal View History

@import '../../common/variables.less';
@import '../../common/mixins.less';
@height-collapsed-toc-button: 36px;
@padding-top-content-px: unit( @padding-top-content * @font-size-browser, px );
@selector-collapsed-toc-open: ~'#vector-toc-collapsed-checkbox:checked';
// Use calc so that the same max width can apply even when the TOC is in different containers
@max-width-collapsed-toc: 0.85 * @max-width-content-container; // 51em
.vector-feature-page-tools-enabled #vector-page-titlebar-toc-unpinned-container,
.vector-feature-page-tools-enabled #vector-sticky-header-toc-unpinned-container {
.vector-toc {
.vector-pinnable-header {
padding-left: @padding-horizontal-dropdown-menu-item + @spacing-subsection-toggle;
}
.vector-toc-contents {
padding-right: @padding-horizontal-dropdown-menu-item;
padding-left: @padding-horizontal-dropdown-menu-item + @spacing-subsection-toggle;
}
}
}
.mixin-toc-dropdown-button() {
display: none;
margin-right: 4px;
z-index: @z-index-menu;
// Override background color for when the TOC button overlaps content
// as a fixed element when the page is scrolled down.
background-color: @background-color-base;
}
#vector-toc-collapsed-button {
.mixin-toc-dropdown-button();
}
@media ( max-width: @max-width-tablet ) {
.client-nojs {
#vector-toc-collapsed-button {
display: block;
// Override the default button styles so the ToC button is slightly shorter when collapsed into the page title
padding: 7px 12px;
&:hover,
&:active {
background-color: @colorGray15;
}
}
#vector-toc-pinned-container {
// Override TOC container's sticky positioning
position: relative;
}
// FIXME: Remove all .sidebar-toc selectors after I5b9228380f5c4674ef424d33127a5cb4010822da is in prod for 5 days
.sidebar-toc,
.vector-toc {
display: none;
position: absolute;
width: auto;
min-width: 200px;
// using min() so that the TOC menu doesn't fully cover the text even on small viewports
max-width: ~'min( @{max-width-collapsed-toc}, 75vw )';
top: @height-collapsed-toc-button; // TOC button height
// FIXME: Don't use a magic number. This used to be tied to the private variable in core
// @icon-padding-md so perhaps this needs to make use of the flush classes?
left: -12px;
margin-top: @padding-top-content-px; // Account for padding-top from .mw-body
// FIXME: Collapsed TOC styles are not consistent with other vector dropdowns
border: @border-width-base @border-style-base @border-color-base;
z-index: @z-index-menu;
}
// FIXME: Remove all .sidebar-toc selectors after I5b9228380f5c4674ef424d33127a5cb4010822da is in prod for 5 days
@{selector-collapsed-toc-open} ~ .mw-table-of-contents-container .sidebar-toc,
@{selector-collapsed-toc-open} ~ .mw-table-of-contents-container .vector-toc {
// Hide the TOC when the button is not checked
display: block;
}
}
}
.vector-page-titlebar-toc {
.mixin-toc-dropdown-button();
&.ve-active {
display: none !important; /* stylelint-disable-line declaration-no-important */
}
.vector-menu-heading {
// Override the default button styles so the ToC button is slightly shorter when collapsed into the page title
@media ( max-width: @max-width-tablet ) {
padding: 7px 12px;
}
}
}
// Shared collapsed TOC styles, applies across all cases (page titlebar, sticky header, floating)
.mixin-toc-collapsed() {
// T316056 Use max-content because collapsed TOC is absolutely positioned, width is relative to the collapsed TOC button
// max-content doesn't account for padding even when we use box-sizing, so use content-box instead
// and manually account for horizontal padding in the max width
width: max-content;
box-sizing: content-box;
// T316056 Remove TOC menu fixed width and apply min/max-width
// Account for padding so that the TOC has an effective max width of @max-width-collapsed-toc, or 51em
@padding-left-toc-em: unit( @padding-left-toc / @font-size-browser, em );
@padding-right-toc-em: unit( @padding-right-toc / @font-size-browser, em );
@max-width-collapsed-toc-content-box: @max-width-collapsed-toc - @padding-right-toc-em - @padding-left-toc-em;
min-width: 200px - @padding-right-toc - @padding-left-toc;
// using min() so that the TOC menu doesn't fully cover the text even on small viewports
max-width: ~'min( @{max-width-collapsed-toc-content-box}, 75vw )';
}
// TOC styles when in page titlebar
.mixin-toc-collapsed-page-titlebar() {
.vector-page-titlebar-toc {
display: block;
// FIXME: Remove all .sidebar-toc selectors after I5b9228380f5c4674ef424d33127a5cb4010822da is in prod for 5 days
.sidebar-toc,
.vector-toc {
.mixin-toc-collapsed();
}
}
}
.client-js {
@media ( max-width: @max-width-tablet ) {
// Prevent layout shift from the TOC being in the sidebar before JS loads and
// moves the TOC into the page titlebar on small screens
// FIXME: Remove all .sidebar-toc selectors after I5b9228380f5c4674ef424d33127a5cb4010822da is in prod for 5 days
#vector-toc-pinned-container .sidebar-toc,
#vector-toc-pinned-container .vector-toc {
display: none;
}
// Hide pin ToC toggles on smaller resolution
// FIXME: Remove all .sidebar-toc selectors after I5b9228380f5c4674ef424d33127a5cb4010822da is in prod for 5 days
.sidebar-toc .vector-pinnable-header-toggle-button,
.vector-toc .vector-pinnable-header-toggle-button {
display: none;
}
//
// TOC in page titlebar on narrow screens
//
.mixin-toc-collapsed-page-titlebar();
//
// TOC floating on narrow screens when below page title
//
.vector-below-page-title {
.vector-page-titlebar-toc {
position: fixed;
top: 0;
left: 0;
margin: 0;
}
}
}
@media ( min-width: @min-width-desktop ) {
//
// TOC in page titlebar
//
.vector-toc-unpinned:not( .vector-sticky-header-visible ) {
.mixin-toc-collapsed-page-titlebar();
}
//
// TOC in sticky header
//
// FIXME: Remove all .sidebar-toc selectors after I5b9228380f5c4674ef424d33127a5cb4010822da is in prod for 5 days
.vector-toc-unpinned.vector-sticky-header-visible .sidebar-toc,
.vector-toc-unpinned.vector-sticky-header-visible .vector-toc {
.mixin-toc-collapsed();
}
}
}