mediawiki-skins-Citizen/resources/skins.citizen.styles/components/TableOfContents.less

226 lines
4.7 KiB
Plaintext
Raw Normal View History

.citizen-toc {
--size-icon: 1rem;
font-size: var( --font-size-small );
line-height: var( --line-height-xs );
&__top {
.citizen-ui-icon {
transform: rotate( 90deg );
}
}
2022-10-19 17:34:37 +00:00
&__contents {
margin-left: 1px;
}
&__contents,
&__list {
2022-11-15 15:43:56 +00:00
margin: 0;
list-style: none;
border-left: 1px solid var( --border-color-base );
2022-10-19 17:30:04 +00:00
.citizen-toc__link {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
2022-10-19 17:30:04 +00:00
}
}
&__list {
margin-left: var( --space-xs );
}
&__link {
display: flex;
gap: var( --space-xs );
padding-top: var( --space-xs );
2024-05-08 01:48:22 +00:00
padding-right: var( --space-xs );
padding-bottom: var( --space-xs );
font-weight: var( --font-weight-medium );
color: var( --color-base );
border-radius: var( --border-radius--small );
2022-10-19 17:30:04 +00:00
&.citizen-toc__top {
height: 0;
padding-top: 0;
padding-bottom: 0;
visibility: hidden;
opacity: 0;
transition-property: opacity, height, padding;
}
2022-10-19 17:30:04 +00:00
&:hover {
background-color: var( --background-color-quiet--hover );
}
&:active {
background-color: var( --background-color-quiet--active );
}
&:hover,
&:focus {
text-decoration: none;
}
}
&__indicator {
flex-shrink: 0;
width: 3px;
margin-left: -2px;
border-radius: var( --border-radius--pill );
}
&__text {
display: flex;
gap: var( --space-xs );
}
&__numb {
display: none;
color: var( --color-base--subtle );
}
&__listItem {
&--active {
> .citizen-toc__link {
color: var( --color-primary );
.citizen-toc__indicator {
background-color: var( --color-primary );
}
}
}
}
2024-05-08 01:48:22 +00:00
.citizen-menu__heading {
padding-left: 0;
}
}
// Sticky header styles
.citizen-body-header--sticky {
.citizen-toc__top.citizen-toc__link {
height: 2rem; // 1rem text + 1rem padding
padding-top: var( --space-xs );
padding-bottom: var( --space-xs );
visibility: visible;
opacity: 1;
}
}
@media ( max-width: ( @max-width-breakpoint-tablet ) ) {
.citizen-toc {
position: fixed;
bottom: ~'calc( var( --header-size ) + var( --space-xs ) )';
left: 0;
z-index: @z-index-page-header;
// Allow click through
pointer-events: none;
transition: var( --transition-menu );
transition-property: transform;
will-change: transform;
&__card {
// This is not bulletproof since it will get covered by page header
// in extremely short height. but it should be good for now
max-height: ~'calc( var( --header-card-maxheight ) - 8rem )';
padding: var( --space-md );
margin: var( --space-xs );
overflow: auto;
overscroll-behavior: contain;
-webkit-user-select: none;
user-select: none;
.citizen-card;
.citizen-card-hide( bottom left, '', false );
.citizen-card-transition();
}
// Move down when site header is hidden
.citizen-scroll--down & {
transform: translateY( var( --header-size ) );
}
}
#citizen-toc {
&__checkbox:checked {
~ .citizen-toc__card {
.citizen-card-show( false );
}
}
&__buttonCheckbox {
position: absolute;
bottom: 0;
left: 0;
display: grid;
place-content: center;
width: var( --toolbar-size );
height: var( --toolbar-size );
margin: var( --space-xs );
pointer-events: auto;
background-color: var( --color-surface-1 );
border-radius: var( --border-radius--medium );
box-shadow: var( --box-shadow-dialog );
transition: var( --transition-menu );
transition-property: transform;
transform: none;
transform-origin: bottom left;
// The hover state colors are not great but it will do for now
&:hover {
background-color: var( --color-surface-3 );
}
&:active {
background-color: var( --color-surface-1 );
}
}
}
// Hide dismiss button when JS is enabled
// Since clicking outside will dismiss ToC already
.client-js {
#citizen-toc {
&__checkbox:checked {
// Fake seamless transition
~ #citizen-toc__buttonCheckbox {
pointer-events: none;
background-color: transparent;
box-shadow: none;
transform: scale( 1.2 );
.citizen-ui-icon {
display: none;
}
}
}
}
}
}
@media ( min-width: @min-width-breakpoint-desktop ) {
.citizen-toc {
--toc-margin-top: var( --space-xs );
position: -webkit-sticky;
position: sticky;
top: var( --toc-margin-top );
max-height: ~'calc( 100vh - var( --toc-margin-top ) - var( --space-md ) )';
overflow-y: auto;
overscroll-behavior: contain;
// Sticky header styles
.citizen-body-header--sticky & {
--toc-margin-top: ~'calc( var( --header-size ) + var( --space-xxl ) )';
2022-10-19 17:30:04 +00:00
// Sticky header is shorter without buttons
@media ( max-height: 800px ) {
--toc-margin-top: ~'calc( var( --header-size ) + var( --space-md ) )';
}
}
}
// Hide button in desktop viewport
#citizen-toc__buttonCheckbox {
display: none;
}
}