1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2025-01-11 21:52:14 +01:00

530 lines
13 KiB
SCSS
Raw Normal View History

////
2017-01-06 19:11:18 +01:00
/// Copyright (c) 2016-2017 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
////
2017-03-21 15:27:45 +01:00
// ----------------------------------------------------------------------------
// Variables
// ----------------------------------------------------------------------------
// Active (toggled) search
$md-toggle__search--checked:
"[data-md-toggle=\"search\"]:checked ~ .md-header";
2016-09-04 17:32:12 +02:00
// ----------------------------------------------------------------------------
// Rules
2016-09-04 17:32:12 +02:00
// ----------------------------------------------------------------------------
// Search container
.md-search {
2016-09-23 11:56:25 +02:00
// Hide search, if JavaScript is not available.
.no-js & {
display: none;
}
// [tablet landscape +]: Header-embedded search
@include break-from-device(tablet landscape) {
2016-12-15 20:04:30 +01:00
margin-right: 2.8rem;
2016-09-23 11:56:25 +02:00
padding: 0.4rem;
}
// Search modal overlay
&__overlay {
display: none;
pointer-events: none;
2016-10-23 19:31:54 +02:00
// [tablet portrait -]: Full-screen search bar
@include break-to-device(tablet portrait) {
display: block;
position: absolute;
top: 0.4rem;
left: 0.4rem;
2017-01-01 15:59:44 +01:00
width: 4rem;
height: 4rem;
transform-origin: center;
transition:
transform 0.3s 0.1s,
opacity 0.2s 0.2s;
2017-01-01 15:59:44 +01:00
border-radius: 2rem;
2016-12-17 12:53:24 +01:00
background-color: $md-color-white;
opacity: 0;
overflow: hidden;
z-index: 1;
// Expanded overlay
2017-03-21 15:27:45 +01:00
#{$md-toggle__search--checked} & {
transition:
transform 0.4s,
opacity 0.1s;
opacity: 1;
}
}
2016-10-23 19:31:54 +02:00
// Set scale factors
2017-03-21 15:27:45 +01:00
#{$md-toggle__search--checked} & {
// [mobile portrait -]: Scale up 45 times
@include break-to-device(mobile portrait) {
transform: scale(45);
}
// [mobile landscape]: Scale up 60 times
@include break-at-device(mobile landscape) {
transform: scale(60);
}
2016-10-23 19:31:54 +02:00
// [tablet portrait]: Scale up 75 times
@include break-at-device(tablet portrait) {
transform: scale(75);
}
}
}
// Search modal wrapper
&__inner {
width: 100%;
// [tablet portrait -]: Put search modal off-canvas by default
@include break-to-device(tablet portrait) {
position: fixed;
top: 0;
left: 100%;
height: 100%;
transform: translateX(5%);
transition:
left 0s 0.3s,
2017-01-01 15:59:44 +01:00
transform 0.15s 0.15s cubic-bezier(0.4, 0, 0.2, 1),
opacity 0.15s 0.15s;
opacity: 0;
z-index: 2;
// Active search modal
2017-03-21 15:27:45 +01:00
#{$md-toggle__search--checked} & {
left: 0;
transform: translateX(0);
transition:
left 0s 0s,
2017-01-01 15:59:44 +01:00
transform 0.15s 0.15s cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 0.15s 0.15s;
opacity: 1;
}
}
2016-10-23 19:31:54 +02:00
// [tablet landscape +]: Make relative for inner layout
@include break-from-device(tablet landscape) {
position: relative;
}
}
// Search form
&__form {
position: relative;
// [tablet landscape +]: Header-embedded search
@include break-from-device(tablet landscape) {
2017-01-01 15:59:44 +01:00
width: 23rem;
2016-10-23 19:31:54 +02:00
// Hack: omit jitter when form is resized
float: right;
2017-01-01 15:59:44 +01:00
transition: width 0.25s cubic-bezier(0.1, 0.7, 0.1, 1);
border-radius: 0.2rem;
}
// Set maximum width
2017-03-21 15:27:45 +01:00
#{$md-toggle__search--checked} & {
// [tablet landscape]: Do not overlay title
@include break-at-device(tablet landscape) {
width: 46.8rem;
}
// [screen +]: Match content width
@include break-from-device(screen) {
width: 68.8rem;
}
}
}
2016-10-23 19:31:54 +02:00
// Search input
&__input {
2016-10-23 19:31:54 +02:00
position: relative;
2017-03-19 19:49:19 +01:00
padding: 0 4.8rem 0 7.2rem;
2016-09-13 20:58:28 +02:00
text-overflow: ellipsis;
2016-10-23 19:31:54 +02:00
z-index: 1;
2016-09-04 17:32:12 +02:00
// Placeholder and icon color in active state
2017-03-19 19:49:19 +01:00
~ .md-search__icon,
&::placeholder {
color: $md-color-black--light;
}
2016-12-28 19:00:04 +01:00
// Remove the "x" rendered by Internet Explorer
&::-ms-clear {
display: none;
}
// [tablet portrait -]: Full-screen search bar
@include break-to-device(tablet portrait) {
width: 100%;
height: 5.6rem;
font-size: 1.8rem;
}
// [tablet landscape +]: Header-embedded search
@include break-from-device(tablet landscape) {
width: 100%;
2017-01-01 15:59:44 +01:00
height: 4rem;
padding-left: 4.8rem;
transition:
background-color 0.25s,
color 0.25s;
border-radius: 0.2rem;
2016-12-17 12:53:24 +01:00
background-color: $md-color-black--lighter;
color: $md-color-white;
font-size: ms(0);
2016-09-04 17:32:12 +02:00
// Placeholder color
+ .md-search__icon,
&::placeholder {
color: $md-color-white;
}
2016-09-08 19:43:23 +02:00
// Hovered search field
&:hover {
2016-12-17 12:53:24 +01:00
background-color: $md-color-white--lightest;
2016-09-08 19:43:23 +02:00
}
2016-10-23 19:31:54 +02:00
// Set light background on active search field
2017-03-21 15:27:45 +01:00
#{$md-toggle__search--checked} & {
border-radius: 0.2rem 0.2rem 0 0;
2016-12-17 12:53:24 +01:00
background-color: $md-color-white;
color: $md-color-black;
2016-09-13 20:58:28 +02:00
text-overflow: none;
2016-09-04 17:32:12 +02:00
// Placeholder and icon color in active state
+ .md-search__icon,
&::placeholder {
color: $md-color-black--light;
}
}
}
}
2016-10-23 19:31:54 +02:00
2016-12-16 09:21:31 +01:00
// Icons
2016-10-23 19:31:54 +02:00
&__icon {
position: absolute;
2017-03-21 15:27:45 +01:00
transition: opacity 0.25s;
2016-10-23 19:31:54 +02:00
font-size: $md-icon-size;
cursor: pointer;
z-index: 1;
2017-03-21 15:27:45 +01:00
// Hovered icon
&:hover {
opacity: 0.7;
}
2017-03-19 19:49:19 +01:00
// Search icon
&[for="search"] {
top: $md-icon-padding;
left: $md-icon-padding + $md-icon-margin;
// Set search icon on pseudo class, so it can be overridden for mobile
// and tablet when the search is rendered in an overlay
&::before {
content: "search";
}
// [tablet portrait -]: Full-screen search bar
@include break-to-device(tablet portrait) {
top: 1.6rem;
left: 1.6rem;
// Show back arrow instead of search icon
&[for="search"]::before {
content: "arrow_back";
}
}
2016-10-23 19:31:54 +02:00
}
2017-03-19 19:49:19 +01:00
// Reset button
&[type="reset"] {
top: $md-icon-padding;
right: $md-icon-padding + $md-icon-margin;
2017-03-21 15:27:45 +01:00
transform: scale(0.125);
2017-03-19 19:49:19 +01:00
transition:
2017-03-21 15:27:45 +01:00
transform 0.15s cubic-bezier(0.1, 0.7, 0.1, 1),
opacity 0.15s;
2017-03-19 19:49:19 +01:00
opacity: 0;
2016-10-23 19:31:54 +02:00
2017-03-19 19:49:19 +01:00
// [tablet portrait -]: Full-screen search bar
@include break-to-device(tablet portrait) {
top: 1.6rem;
right: 1.6rem;
}
2017-03-21 15:27:45 +01:00
// Show reset button if search is active and input non-empty
#{$md-toggle__search--checked} .md-search__input:valid ~ & {
transform: scale(1);
opacity: 1;
2017-03-19 19:49:19 +01:00
2017-03-21 15:27:45 +01:00
// Hovered icon
&:hover {
opacity: 0.7;
2017-03-19 19:49:19 +01:00
}
2016-10-23 19:31:54 +02:00
}
}
}
// Search output container
&__output {
position: absolute;
2016-10-23 19:31:54 +02:00
width: 100%;
border-radius: 0 0 0.2rem 0.2rem;
overflow: hidden;
// [tablet portrait -]: Full-screen search bar
@include break-to-device(tablet portrait) {
top: 5.6rem;
bottom: 0;
}
// [tablet landscape +]: Header-embedded search
@include break-from-device(tablet landscape) {
2017-01-01 15:59:44 +01:00
top: 4rem;
2016-10-23 19:31:54 +02:00
transition: opacity 0.4s;
opacity: 0;
// Show search output in active state
2017-03-21 15:27:45 +01:00
#{$md-toggle__search--checked} & {
@include z-depth(6);
2016-10-23 19:31:54 +02:00
opacity: 1;
}
}
}
// Wrapper for scrolling on overflow
&__scrollwrap {
height: 100%;
// Pure CSS scrolling shadows, taken from
// http://lea.verou.me/2012/04/background-attachment-local/
background:
2017-01-01 15:59:44 +01:00
linear-gradient(
2016-10-23 19:31:54 +02:00
to bottom,
$md-color-white 10%,
2017-01-01 15:59:44 +01:00
$md-color-white--transparent
),
2016-10-23 19:31:54 +02:00
linear-gradient(
to bottom,
$md-color-black--lighter,
$md-color-black--lightest 35%,
2017-01-01 15:59:44 +01:00
$md-color-black--transparent 60%
);
2016-10-23 19:31:54 +02:00
background-attachment: local, scroll;
background-color: $md-color-white;
background-repeat: no-repeat;
2017-01-01 15:59:44 +01:00
background-size: 100% 2rem, 100% 1rem;
2016-10-23 19:31:54 +02:00
2017-01-01 15:59:44 +01:00
// End of scrolling shadow definition
2016-10-23 19:31:54 +02:00
box-shadow: 0 0.1rem 0 $md-color-black--lightest inset;
overflow-y: auto;
2016-12-28 17:13:07 +01:00
-webkit-overflow-scrolling: touch;
2016-10-23 19:31:54 +02:00
2016-12-15 15:55:40 +01:00
// [tablet landscape]: Set absolute width to omit unnecessary reflow
@include break-at-device(tablet landscape) {
width: 46.8rem;
}
// [screen +]: Set absolute width to omit unnecessary reflow
@include break-from-device(screen) {
width: 68.8rem;
2016-12-15 15:55:40 +01:00
}
2016-10-23 19:31:54 +02:00
// [tablet landscape +]: Limit height to viewport
@include break-from-device(tablet landscape) {
max-height: 0;
// Expand in active state
2017-03-21 15:27:45 +01:00
#{$md-toggle__search--checked} & {
2016-10-23 19:31:54 +02:00
max-height: 75vh;
}
// Override native scrollbar styles
&::-webkit-scrollbar {
width: 0.4rem;
height: 0.4rem;
}
2016-10-23 19:31:54 +02:00
// Style scrollbar thumb
&::-webkit-scrollbar-thumb {
background-color: $md-color-black--lighter;
2016-10-23 19:31:54 +02:00
// Hovered scrollbar thumb
&:hover {
background-color: $md-color-accent;
2016-10-23 19:31:54 +02:00
}
}
}
}
}
2016-12-16 09:21:31 +01:00
// Search result
.md-search-result {
2017-03-12 17:58:34 +01:00
color: $md-color-black;
word-break: break-word;
2016-12-16 09:21:31 +01:00
// Search metadata
&__meta {
padding: 0 1.6rem;
2016-12-17 12:53:24 +01:00
background-color: $md-color-black--lightest;
2016-12-16 09:21:31 +01:00
color: $md-color-black--light;
font-size: ms(-1);
2017-01-01 15:59:44 +01:00
line-height: 4rem;
2016-12-16 09:21:31 +01:00
// [tablet landscape +]: Increase left indent
@include break-from-device(tablet landscape) {
padding-left: 4.8rem;
}
}
// List of items
&__list {
margin: 0;
padding: 0;
border-top: 0.1rem solid $md-color-black--lightest;
list-style: none;
}
// List item
&__item {
box-shadow: 0 -0.1rem 0 $md-color-black--lightest;
}
// Link inside item
&__link {
display: block;
transition: background 0.25s;
outline: 0;
2017-03-12 17:58:34 +01:00
overflow: hidden;
2016-12-16 09:21:31 +01:00
// Active or hovered link
&[data-md-state="active"],
2016-12-16 09:21:31 +01:00
&:hover {
2016-12-17 12:53:24 +01:00
background-color: transparentize($md-color-accent, 0.9);
2017-03-21 15:27:45 +01:00
// Slightly transparent icon
.md-search-result__article::before {
opacity: 0.7;
}
2016-12-16 09:21:31 +01:00
}
2017-03-12 17:58:34 +01:00
// Add a little spacing on the last link
&:last-child {
padding-bottom: 0.8rem;
}
}
// Article - document or section
&__article {
position: relative;
padding: 0 1.6rem;
overflow: auto;
2016-12-16 09:21:31 +01:00
// [tablet landscape +]: Increase left indent
@include break-from-device(tablet landscape) {
padding-left: 4.8rem;
}
2017-03-12 17:58:34 +01:00
// Document
&--document {
// Icon
&::before {
@extend %md-icon, %md-icon__button;
position: absolute;
left: 0;
2017-03-21 15:27:45 +01:00
transition: opacity 0.25s;
color: $md-color-black--light;
2017-03-12 17:58:34 +01:00
content: "find_in_page";
// [tablet portrait -]: Hide page icon
@include break-to-device(tablet portrait) {
display: none;
}
2017-03-12 17:58:34 +01:00
}
// Title
.md-search-result__title {
margin: 1.3rem 0;
font-size: ms(0);
font-weight: 400;
line-height: 1.4;
}
}
2016-12-16 09:21:31 +01:00
}
2017-03-12 17:58:34 +01:00
// Title
2016-12-16 09:21:31 +01:00
&__title {
2017-03-12 17:58:34 +01:00
margin: 0.5em 0;
font-size: ms(-1);
font-weight: 700;
2016-12-16 09:21:31 +01:00
line-height: 1.4;
}
// stylelint-disable value-no-vendor-prefix, property-no-vendor-prefix
2017-03-12 17:58:34 +01:00
// Teaser
2016-12-16 09:21:31 +01:00
&__teaser {
display: -webkit-box;
max-height: 3.3rem;
2017-01-01 15:59:44 +01:00
margin: 0.5em 0;
2016-12-16 09:21:31 +01:00
color: $md-color-black--light;
font-size: ms(-1);
line-height: 1.4;
text-overflow: ellipsis;
overflow: hidden;
-webkit-box-orient: vertical;
-webkit-line-clamp: 2;
// [mobile -]: Increase number of lines
@include break-to-device(mobile) {
max-height: 5rem;
-webkit-line-clamp: 3;
}
// [tablet landscape]: Increase number of lines
@include break-at-device(tablet landscape) {
max-height: 5rem;
-webkit-line-clamp: 3;
}
2017-03-12 17:58:34 +01:00
}
// stylelint-enable value-no-vendor-prefix, property-no-vendor-prefix
2017-03-21 15:27:45 +01:00
// Search term highlighting
2017-03-12 17:58:34 +01:00
em {
font-style: normal;
font-weight: 700;
text-decoration: underline;
2016-12-16 09:21:31 +01:00
}
}