1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2025-01-30 11:27:26 +01:00

251 lines
5.9 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;
height: px2rem(48px);
2017-11-19 17:41:06 +01:00
transition:
background-color 250ms,
color 250ms;
background-color: var(--md-color-primary);
color: var(--md-color-background);
2017-11-22 00:13:56 +01:00
box-shadow: none;
z-index: 2;
// Hack: putting the header on the GPU avoids unnecessary repaints
backface-visibility: hidden;
2016-10-24 18:02:53 +02:00
// Always hide shadow, in case JavaScript is not available
.no-js & {
2017-12-27 11:31:07 +01:00
transition: none;
2017-11-19 17:41:06 +01:00
box-shadow: none;
}
2017-11-22 00:13:56 +01:00
// Show and animate shadow
&[data-md-state="shadow"] {
transition:
background-color 250ms,
color 250ms,
box-shadow 250ms;
2017-11-22 00:13:56 +01:00
box-shadow:
0 0 px2rem(4px) rgba(0, 0, 0, 0.1),
0 px2rem(4px) px2rem(8px) rgba(0, 0, 0, 0.2);
}
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;
transition: opacity 250ms;
2016-09-13 20:58:28 +02:00
z-index: 1;
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 {
display: block;
position: absolute;
2020-02-24 22:44:12 +01:00
width: 100%;
padding: 0 px2rem(20px);
2017-11-19 16:46:01 +01:00
transition:
transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 150ms;
text-overflow: ellipsis;
white-space: nowrap;
overflow: hidden;
2017-11-19 16:46:01 +01:00
// Page title
& + & {
2019-11-27 19:12:49 +01:00
transform: translateX(px2rem(25px));
transition:
transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),
opacity 150ms;
2017-11-19 16:46:01 +01:00
opacity: 0;
z-index: -1;
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;
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 {
2019-11-27 19:12:49 +01:00
transform: translateX(px2rem(-25px));
transition:
transform 400ms cubic-bezier(1, 0.7, 0.1, 0.1),
opacity 150ms;
opacity: 0;
z-index: -1;
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 {
2019-11-27 19:12:49 +01:00
transform: translateX(0);
2017-11-19 16:46:01 +01:00
transition:
transform 400ms cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 150ms;
opacity: 1;
z-index: 0;
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);
}
}
}
}