1
0
mirror of https://github.com/squidfunk/mkdocs-material.git synced 2024-12-23 12:54:53 +01:00
mkdocs-material/src/assets/stylesheets/layout/_search.scss

318 lines
8.1 KiB
SCSS
Raw Normal View History

////
/// Copyright (c) 2016 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-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-09-23 11:56:25 +02:00
padding: 0.4rem;
padding-right: 3.2rem;
}
// 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;
width: 4.0rem;
height: 4.0rem;
transform-origin: center;
transition:
transform 0.3s 0.1s,
opacity 0.2s 0.2s;
border-radius: 2.0rem;
background: $md-color-white;
opacity: 0;
overflow: hidden;
z-index: 1;
// Expanded overlay
.md-toggle--search:checked ~ .md-header & {
transition:
transform 0.4s,
opacity 0.1s;
opacity: 1;
}
}
2016-10-23 19:31:54 +02:00
// Set scale factors
.md-toggle--search:checked ~ .md-header & {
// [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,
transform 0.15s 0.15s cubic-bezier(0.4, 0.0, 0.2, 1.0),
opacity 0.15s 0.15s;
opacity: 0;
z-index: 2;
// Active search modal
.md-toggle--search:checked ~ .md-header & {
left: 0;
transform: translateX(0);
transition:
left 0s 0s,
transform 0.15s 0.15s cubic-bezier(0.1, 0.7, 0.1, 1.0),
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 {
// [tablet landscape +]: Header-embedded search
@include break-from-device(tablet landscape) {
width: 23.0rem;
2016-10-23 19:31:54 +02:00
// Hack: omit jitter when form is resized
float: right;
transition: width 0.25s cubic-bezier(0.1, 0.7, 0.1, 1.0);
border-radius: 0.2rem;
2016-10-23 19:31:54 +02:00
// Enlarge search field when active
.md-toggle--search:checked ~ .md-header & {
width: 66.8rem;
}
}
}
2016-10-23 19:31:54 +02:00
// Search input
&__input {
2016-10-23 19:31:54 +02:00
position: relative;
padding: 0 1.6rem 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
+ .md-search__icon,
&::placeholder {
color: $md-color-black--light;
}
// [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%;
height: 4.0rem;
padding-left: 4.8rem;
transition:
background-color 0.25s,
color 0.25s;
border-radius: 0.2rem;
2016-09-13 20:58:28 +02:00
background: $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 {
transition: color 0.25s;
color: $md-color-white;
}
2016-09-08 19:43:23 +02:00
// Hovered search field
&:hover {
2016-09-13 20:58:28 +02:00
background: $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
.md-toggle--search:checked ~ .md-header & {
border-radius: 0.2rem 0.2rem 0 0;
background: $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
// Icon
&__icon {
position: absolute;
top: $md-icon-padding;
left: $md-icon-padding + $md-icon-margin;
transition: color 0.25s;
font-size: $md-icon-size;
cursor: pointer;
z-index: 1;
// 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
&::before {
content: "arrow_back";
}
}
}
// Search output container
&__output {
width: 100%;
border-radius: 0 0 0.2rem 0.2rem;
overflow: hidden;
// [tablet portrait -]: Full-screen search bar
@include break-to-device(tablet portrait) {
position: absolute;
top: 5.6rem;
bottom: 0;
}
// [tablet landscape +]: Header-embedded search
@include break-from-device(tablet landscape) {
@include z-depth(6);
transition: opacity 0.4s;
opacity: 0;
// Show search output in active state
.md-toggle--search:checked ~ .md-header & {
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:
linear-gradient(
to bottom,
$md-color-white 10%,
$md-color-white--transparent),
linear-gradient(
to bottom,
$md-color-black--lighter,
$md-color-black--lightest 35%,
$md-color-black--transparent 60%);
// Hack: Opera doesn't support this in the shorthand
background-attachment: local, scroll;
background-color: $md-color-white;
background-repeat: no-repeat;
background-size: 100% 2.0rem, 100% 1.0rem;
box-shadow: 0 0.1rem 0 $md-color-black--lightest inset;
overflow-y: auto;
// [tablet landscape +]: Limit height to viewport
@include break-from-device(tablet landscape) {
max-height: 0;
// Expand in active state
.md-toggle--search:checked ~ .md-header & {
max-height: 75vh;
}
// Override native scrollbar styles
&::-webkit-scrollbar {
width: 0.4rem;
height: 0.4rem;
// Style scrollbar thumb
&-thumb {
background-color: $md-color-black--lighter;
// Hovered scrollbar thumb
&:hover {
background-color: $md-color-accent;
}
}
}
}
}
}