mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-04-17 00:22:24 -06:00
Improved search input for mobile
- font size 16px to prevent zooming on iOS Safari - search input is scrolled into view on iOS Safari - box-shadow is displayed correctly
This commit is contained in:
parent
f5e6573e16
commit
da9276121a
@ -112,17 +112,16 @@ layout: table_wrappers
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
{% if site.search_enabled != false %}
|
{% if site.search_enabled != false %}
|
||||||
{% if site.search.button %}
|
{% if site.search.button %}
|
||||||
<a href="#" id="search-button" class="search-button">
|
<a href="#" id="search-button" class="search-button">
|
||||||
<svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-search"></use></svg>
|
<svg viewBox="0 0 24 24" class="icon"><use xlink:href="#svg-search"></use></svg>
|
||||||
</a>
|
</a>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div class="search-overlay"></div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</div>
|
||||||
<div class="search-overlay"></div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -21,12 +21,21 @@
|
|||||||
|
|
||||||
.search-input-wrap {
|
.search-input-wrap {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
height: $sp-8;
|
height: $sp-8;
|
||||||
|
border-radius: $border-radius;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.08);
|
||||||
|
overflow: hidden;
|
||||||
transition: height linear #{$transition-duration / 2};
|
transition: height linear #{$transition-duration / 2};
|
||||||
|
|
||||||
@include mq(md) {
|
@include mq(md) {
|
||||||
|
position: absolute;
|
||||||
|
width: 100%;
|
||||||
|
max-width: $search-results-width;
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
transition: none;
|
border-radius: 0;
|
||||||
|
box-shadow: none;
|
||||||
|
transition: width ease $transition-duration;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,20 +52,16 @@
|
|||||||
border-right: 0;
|
border-right: 0;
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
border-left: 0;
|
border-left: 0;
|
||||||
border-radius: $border-radius;
|
border-radius: 0;
|
||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.08);
|
font-size: 16px;
|
||||||
@include fs-4;
|
|
||||||
|
|
||||||
@include mq(md) {
|
@include mq(md) {
|
||||||
max-width: $search-results-width;
|
|
||||||
padding-top: $gutter-spacing-sm;
|
padding-top: $gutter-spacing-sm;
|
||||||
padding-bottom: $gutter-spacing-sm;
|
padding-bottom: $gutter-spacing-sm;
|
||||||
padding-left: #{$gutter-spacing + $sp-5};
|
padding-left: #{$gutter-spacing + $sp-5};
|
||||||
background-color: $body-background-color;
|
background-color: $body-background-color;
|
||||||
border-radius: 0;
|
transition: padding-left linear #{$transition-duration / 2};
|
||||||
box-shadow: none;
|
font-size: 14px;
|
||||||
transition: padding-left linear #{$transition-duration / 2}, width ease $transition-duration;
|
|
||||||
@include fs-3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&:focus {
|
&:focus {
|
||||||
@ -100,6 +105,7 @@
|
|||||||
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.08);
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.08);
|
||||||
|
|
||||||
@include mq(md) {
|
@include mq(md) {
|
||||||
|
top: 100%;
|
||||||
width: $search-results-width;
|
width: $search-results-width;
|
||||||
max-height: calc(100vh - 200%) !important;
|
max-height: calc(100vh - 200%) !important;
|
||||||
}
|
}
|
||||||
@ -265,15 +271,18 @@
|
|||||||
|
|
||||||
.search-input-wrap {
|
.search-input-wrap {
|
||||||
height: $sp-10;
|
height: $sp-10;
|
||||||
|
border-radius: 0;
|
||||||
|
|
||||||
|
@include mq(md) {
|
||||||
|
width: $search-results-width;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12), 0 3px 10px rgba(0, 0, 0, 0.08);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input {
|
.search-input {
|
||||||
background-color: $search-background-color;
|
background-color: $search-background-color;
|
||||||
border-radius: 0;
|
|
||||||
box-shadow: none;
|
|
||||||
|
|
||||||
@include mq(md) {
|
@include mq(md) {
|
||||||
width: $search-results-width;
|
|
||||||
padding-left: #{$sp-4 * 1.25 + $sp-5};
|
padding-left: #{$sp-4 * 1.25 + $sp-5};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -295,20 +304,17 @@
|
|||||||
transition: opacity ease $transition-duration, width 0s, height 0s;
|
transition: opacity ease $transition-duration, width 0s, height 0s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stylelint-disable selector-max-type
|
@include mq(md) {
|
||||||
|
.main {
|
||||||
body {
|
position: fixed;
|
||||||
overflow-y: hidden;
|
|
||||||
|
|
||||||
@include mq(md) {
|
|
||||||
overflow-y: scroll;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@include mq(md) {
|
.main-header {
|
||||||
.main {
|
padding-top: $sp-10;
|
||||||
height: 100vh;
|
|
||||||
overflow-y: hidden;
|
@include mq(md) {
|
||||||
|
padding-top: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,9 @@ function searchLoaded(index, docs) {
|
|||||||
hideSearch();
|
hideSearch();
|
||||||
} else {
|
} else {
|
||||||
showSearch();
|
showSearch();
|
||||||
window.scroll(0, window.scrollY + mainHeader.getBoundingClientRect().top);
|
// scroll search input into view, workaround for iOS Safari
|
||||||
|
window.scroll(0, -1);
|
||||||
|
setTimeout(function(){ window.scroll(0, 0); }, 0);
|
||||||
}
|
}
|
||||||
if (input === currentInput) {
|
if (input === currentInput) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user