1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2025-01-28 18:45:49 +01:00

259 lines
6.2 KiB
SCSS
Raw Normal View History

////
/// 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
////
2016-01-28 23:27:15 +01:00
2016-09-04 17:32:12 +02:00
// ----------------------------------------------------------------------------
// Rules
2016-09-04 17:32:12 +02:00
// ----------------------------------------------------------------------------
2016-01-28 23:27:15 +01:00
2016-09-04 17:32:12 +02:00
// Application header (stays always on top)
2016-08-07 18:01:56 +02:00
.md-header {
2020-01-25 14:25:50 +01:00
position: sticky;
2016-08-07 18:01:56 +02:00
top: 0;
right: 0;
left: 0;
z-index: 2;
height: px2rem(48px);
2020-02-25 20:25:05 +01:00
color: var(--md-primary-bg-color);
background-color: var(--md-primary-fg-color);
2020-03-01 00:11:30 +01:00
// 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;
2016-10-24 18:02:53 +02:00
// Always hide shadow, in case JavaScript is not available
.no-js & {
2017-11-19 17:41:06 +01:00
box-shadow: none;
transition: none;
}
2017-11-22 00:13:56 +01:00
// Show and animate shadow
&[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);
2017-11-22 00:13:56 +01:00
transition:
color 250ms,
background-color 250ms,
box-shadow 250ms;
}
2016-10-24 18:02:53 +02:00
// Hide for print
@media print {
display: none;
}
2016-09-13 20:58:28 +02:00
}
2016-01-28 23:27:15 +01:00
2016-09-13 20:58:28 +02:00
// Navigation within header
.md-header-nav {
display: flex;
padding: 0 px2rem(4px);
2017-01-14 20:13:10 +01:00
// Icon buttons
&__button {
2016-09-13 20:58:28 +02:00
position: relative;
z-index: 1;
2020-03-23 10:45:06 +01:00
display: block;
2020-02-27 11:37:02 +01:00
margin: px2rem(4px);
padding: px2rem(8px);
cursor: pointer;
transition: opacity 250ms;
2016-01-28 23:27:15 +01:00
// Adjust for right-to-left languages
[dir="rtl"] & {
// Flip icon vertically
svg {
transform: scaleX(-1);
}
}
// Focused or hovered icon
&:focus,
2016-09-13 20:58:28 +02:00
&:hover {
opacity: 0.7;
}
2016-08-08 23:33:06 +02:00
// Logo
&.md-logo {
margin: px2rem(4px);
padding: px2rem(8px);
// Image or icon
img,
svg {
display: block;
width: px2rem(24px);
height: px2rem(24px);
fill: currentColor;
}
2017-01-14 20:13:10 +01:00
}
// Hide search icon, if JavaScript is not available.
2020-02-24 22:44:12 +01:00
.no-js &[for="__search"] {
display: none;
}
// [tablet landscape +]: Hide the search button
@include break-from-device(tablet landscape) {
2016-08-08 23:33:06 +02:00
// Search button
&[for="__search"] {
display: none;
}
}
// [tablet -]: Hide the logo
@include break-to-device(tablet) {
// Logo
2017-01-14 20:13:10 +01:00
&.md-logo {
display: none;
}
}
// [screen +]: Hide the menu button
@include break-from-device(screen) {
// Menu button
&[for="__drawer"] {
2016-09-13 20:58:28 +02:00
display: none;
2016-08-08 23:33:06 +02:00
}
}
2016-09-13 20:58:28 +02:00
}
2017-11-19 16:46:01 +01:00
// Header topics
&__topic {
position: absolute;
2020-02-24 22:44:12 +01:00
width: 100%;
transition:
transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 150ms;
2017-11-19 16:46:01 +01:00
2020-03-23 10:45:06 +01:00
// Adjust for right-to-left languages
[dir="rtl"] & {
padding-right: px2rem(20px);
padding-left: initial;
}
2017-11-19 16:46:01 +01:00
// Page title
& + & {
z-index: -1;
2019-11-27 19:12:49 +01:00
transform: translateX(px2rem(25px));
opacity: 0;
transition:
transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),
opacity 150ms;
2017-11-19 16:46:01 +01:00
pointer-events: none;
// Adjust for right-to-left languages
[dir="rtl"] & {
2019-11-27 19:12:49 +01:00
transform: translateX(px2rem(-25px));
}
2017-11-19 16:46:01 +01:00
}
2017-11-19 17:41:06 +01:00
// Induce ellipsis, if no JavaScript is available
.no-js & {
position: initial;
}
2017-12-27 11:31:07 +01:00
// Hide page title as it is invisible anyway and will overflow the header
.no-js & + & {
display: none;
}
2017-11-19 16:46:01 +01:00
}
// Header title - set line height to match icon for correct alignment
2016-09-13 20:58:28 +02:00
&__title {
flex-grow: 1;
padding: 0 px2rem(20px);
font-size: px2rem(18px);
line-height: px2rem(48px);
2017-11-19 16:46:01 +01:00
// Show page title
&[data-md-state="active"] .md-header-nav__topic {
z-index: -1;
2019-11-27 19:12:49 +01:00
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"] & {
2019-11-27 19:12:49 +01:00
transform: translateX(px2rem(25px));
}
// Page title
& + .md-header-nav__topic {
z-index: 0;
2019-11-27 19:12:49 +01:00
transform: translateX(0);
opacity: 1;
2017-11-19 16:46:01 +01:00
transition:
transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 150ms;
pointer-events: initial;
2017-11-19 16:46:01 +01:00
}
}
// Patch ellipsis
> .md-header-nav__ellipsis {
position: relative;
width: 100%;
height: 100%;
}
2016-01-28 23:27:15 +01:00
}
// Repository containing source
&__source {
display: none;
// [tablet landscape +]: Show the reposistory from tablet
@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 +]: Increase 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);
}
}
}
}