mirror of
https://github.com/squidfunk/mkdocs-material.git
synced 2024-06-14 11:52:32 +03:00
256 lines
6.6 KiB
SCSS
256 lines
6.6 KiB
SCSS
////
|
|
/// Copyright (c) 2016-2020 Martin Donath <martin.donath@squidfunk.com>
|
|
///
|
|
/// Permission is hereby granted, free of charge, to any person obtaining a
|
|
/// copy of this software and associated documentation files (the "Software"),
|
|
/// to deal in the Software without restriction, including without limitation
|
|
/// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
/// and/or sell copies of the Software, and to permit persons to whom the
|
|
/// Software is furnished to do so, subject to the following conditions:
|
|
///
|
|
/// The above copyright notice and this permission notice shall be included in
|
|
/// all copies or substantial portions of the Software.
|
|
///
|
|
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
|
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|
/// DEALINGS
|
|
////
|
|
|
|
// ----------------------------------------------------------------------------
|
|
// Rules
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Header - by default, the header will be sticky and stay always on top of the
|
|
// viewport. If this behavior is not desired, just set `position: static`.
|
|
.md-header {
|
|
position: sticky;
|
|
top: 0;
|
|
right: 0;
|
|
left: 0;
|
|
z-index: 2;
|
|
color: var(--md-primary-bg-color);
|
|
background-color: var(--md-primary-fg-color);
|
|
// Hack: reduce jitter by adding a transparent box shadow of the same size
|
|
// so the size of the layer doesn't change during animation
|
|
box-shadow:
|
|
0 0 px2rem(4px) rgba(0, 0, 0, 0),
|
|
0 px2rem(4px) px2rem(8px) rgba(0, 0, 0, 0);
|
|
transition:
|
|
color 250ms,
|
|
background-color 250ms;
|
|
|
|
// [print]: Hide header
|
|
@media print {
|
|
display: none;
|
|
}
|
|
|
|
// Header in shadow state, i.e. shadow is visible
|
|
&[data-md-state="shadow"] {
|
|
box-shadow:
|
|
0 0 px2rem(4px) rgba(0, 0, 0, 0.1),
|
|
0 px2rem(4px) px2rem(8px) rgba(0, 0, 0, 0.2);
|
|
transition:
|
|
transform 250ms cubic-bezier(0.1, 0.7, 0.1, 1),
|
|
color 250ms,
|
|
background-color 250ms,
|
|
box-shadow 250ms;
|
|
}
|
|
|
|
// Header in hidden state, i.e. moved out of sight
|
|
&[data-md-state="hidden"] {
|
|
transform: translateY(-100%);
|
|
transition:
|
|
transform 250ms cubic-bezier(0.8, 0, 0.6, 1),
|
|
color 250ms,
|
|
background-color 250ms,
|
|
box-shadow 250ms;
|
|
}
|
|
}
|
|
|
|
// Header navigation - if the header exceeds the default height of `48px`, i.e.
|
|
// by adding a bigger logo, the items are agned at the center
|
|
.md-header-nav {
|
|
display: flex;
|
|
align-items: center;
|
|
padding: 0 px2rem(4px);
|
|
|
|
// Header navigation button
|
|
&__button {
|
|
position: relative;
|
|
z-index: 1;
|
|
display: inline-block;
|
|
margin: px2rem(4px);
|
|
padding: px2rem(8px);
|
|
color: currentColor;
|
|
vertical-align: middle;
|
|
cursor: pointer;
|
|
transition: opacity 250ms;
|
|
|
|
// Button on focus/hover
|
|
&:focus,
|
|
&:hover {
|
|
opacity: 0.7;
|
|
}
|
|
|
|
// Hide outline for pointer devices
|
|
&:not(.focus-visible) {
|
|
outline: none;
|
|
}
|
|
|
|
// Button with logo, pointing to `config.site_url`
|
|
&.md-logo {
|
|
margin: px2rem(4px);
|
|
padding: px2rem(8px);
|
|
|
|
// [tablet -]: Hide button
|
|
@include break-to-device(tablet) {
|
|
display: none;
|
|
}
|
|
|
|
// Image or icon
|
|
img,
|
|
svg {
|
|
display: block;
|
|
width: px2rem(24px);
|
|
height: px2rem(24px);
|
|
fill: currentColor;
|
|
}
|
|
}
|
|
|
|
// Button for search
|
|
&[for="__search"] {
|
|
|
|
// [tablet landscape +]: Hide button
|
|
@include break-from-device(tablet landscape) {
|
|
display: none;
|
|
}
|
|
|
|
// [no-js]: Hide button
|
|
.no-js & {
|
|
display: none;
|
|
}
|
|
|
|
// Adjust for right-to-left languages
|
|
[dir="rtl"] & {
|
|
|
|
// Flip icon vertically
|
|
svg {
|
|
transform: scaleX(-1);
|
|
}
|
|
}
|
|
}
|
|
|
|
// Button for drawer
|
|
&[for="__drawer"] {
|
|
|
|
// [screen +]: Hide button
|
|
@include break-from-device(screen) {
|
|
display: none;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Header navigation topic
|
|
&__topic {
|
|
position: absolute;
|
|
display: flex;
|
|
max-width: 100%;
|
|
transition:
|
|
transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),
|
|
opacity 150ms;
|
|
|
|
// Second header topic - title of the current page
|
|
& + & {
|
|
z-index: -1;
|
|
transform: translateX(px2rem(25px));
|
|
opacity: 0;
|
|
transition:
|
|
transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),
|
|
opacity 150ms;
|
|
pointer-events: none;
|
|
|
|
// Adjust for right-to-left languages
|
|
[dir="rtl"] & {
|
|
transform: translateX(px2rem(-25px));
|
|
}
|
|
}
|
|
}
|
|
|
|
// Header navigation title
|
|
&__title {
|
|
flex-grow: 1;
|
|
height: px2rem(48px);
|
|
margin-right: px2rem(8px);
|
|
margin-left: px2rem(20px);
|
|
font-size: px2rem(18px);
|
|
line-height: px2rem(48px);
|
|
|
|
// Header title in active state, i.e. page title is visible
|
|
&[data-md-state="active"] .md-header-nav__topic {
|
|
z-index: -1;
|
|
transform: translateX(px2rem(-25px));
|
|
opacity: 0;
|
|
transition:
|
|
transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),
|
|
opacity 150ms;
|
|
pointer-events: none;
|
|
|
|
// Adjust for right-to-left languages
|
|
[dir="rtl"] & {
|
|
transform: translateX(px2rem(25px));
|
|
}
|
|
|
|
// Second header topic - title of the current page
|
|
+ .md-header-nav__topic {
|
|
z-index: 0;
|
|
transform: translateX(0);
|
|
opacity: 1;
|
|
transition:
|
|
transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),
|
|
opacity 150ms;
|
|
pointer-events: initial;
|
|
}
|
|
}
|
|
|
|
// Add ellipsis in case of overflowing text
|
|
> .md-header-nav__ellipsis {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
}
|
|
|
|
// Repository information container
|
|
&__source {
|
|
display: none;
|
|
|
|
// [tablet landscape +]: Show repository information
|
|
@include break-from-device(tablet landscape) {
|
|
display: block;
|
|
width: px2rem(234px);
|
|
max-width: px2rem(234px);
|
|
margin-left: px2rem(20px);
|
|
|
|
// Adjust for right-to-left languages
|
|
[dir="rtl"] & {
|
|
margin-right: px2rem(20px);
|
|
margin-left: initial;
|
|
}
|
|
}
|
|
|
|
// [screen +]: Adjust spacing of search bar
|
|
@include break-from-device(screen) {
|
|
margin-left: px2rem(28px);
|
|
|
|
// Adjust for right-to-left languages
|
|
[dir="rtl"] & {
|
|
margin-right: px2rem(28px);
|
|
}
|
|
}
|
|
}
|
|
}
|