Skip to content

Commit

Permalink
Animation for search-popup (#1427)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang committed Mar 19, 2020
1 parent 34d8274 commit 960155b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
33 changes: 23 additions & 10 deletions source/css/_common/components/third-party/search.styl
@@ -1,12 +1,19 @@
.search-pop-overlay {
background: rgba(0, 0, 0, .3);
display: none;
background: rgba(0, 0, 0, 0);
height: 100%;
left: 0;
position: fixed;
top: 0;
transition: visibility 0s linear .2s, background .2s;
visibility: hidden;
width: 100%;
z-index: $zindex-4;

&.search-active {
background: rgba(0, 0, 0, .3);
transition: background .2s;
visibility: visible;
}
}

.search-popup {
Expand All @@ -16,9 +23,15 @@
left: calc(50% - 350px);
position: fixed;
top: 10%;
transform: scale(0);
transition: transform .2s;
width: 700px;
z-index: $zindex-5;

.search-active & {
transform: scale(1);
}

+mobile() {
border-radius: 0;
height: 100%;
Expand Down Expand Up @@ -49,16 +62,16 @@
display: flex;
padding: 5px;
}
}

.site-search input.search-input {
background: transparent;
border: 0;
outline: 0;
width: 100%;
input.search-input {
background: transparent;
border: 0;
outline: 0;
width: 100%;

&::-webkit-search-cancel-button {
display: none;
&::-webkit-search-cancel-button {
display: none;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion source/css/_common/scaffolding/highlight/highlight.styl
Expand Up @@ -51,7 +51,7 @@ code {
}

figcaption {
background: $code-background;
background: $highlight-gutter.bg-color;
color: $highlight-foreground;
display: flex;
font-size: $table-font-size;
Expand Down
4 changes: 2 additions & 2 deletions source/js/algolia-search.js
Expand Up @@ -98,15 +98,15 @@ window.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.popup-trigger').forEach(element => {
element.addEventListener('click', () => {
document.body.style.overflow = 'hidden';
document.querySelector('.search-pop-overlay').style.display = 'block';
document.querySelector('.search-pop-overlay').classList.add('search-active');
document.querySelector('.search-input').focus();
});
});

// Monitor main search box
const onPopupClose = () => {
document.body.style.overflow = '';
document.querySelector('.search-pop-overlay').style.display = '';
document.querySelector('.search-pop-overlay').classList.remove('search-active');
};

document.querySelector('.search-pop-overlay').addEventListener('click', event => {
Expand Down
4 changes: 2 additions & 2 deletions source/js/local-search.js
Expand Up @@ -255,7 +255,7 @@ window.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('.popup-trigger').forEach(element => {
element.addEventListener('click', () => {
document.body.style.overflow = 'hidden';
document.querySelector('.search-pop-overlay').style.display = 'block';
document.querySelector('.search-pop-overlay').classList.add('search-active');
input.focus();
if (!isfetched) fetchData();
});
Expand All @@ -264,7 +264,7 @@ window.addEventListener('DOMContentLoaded', () => {
// Monitor main search box
const onPopupClose = () => {
document.body.style.overflow = '';
document.querySelector('.search-pop-overlay').style.display = '';
document.querySelector('.search-pop-overlay').classList.remove('search-active');
};

document.querySelector('.search-pop-overlay').addEventListener('click', event => {
Expand Down

0 comments on commit 960155b

Please sign in to comment.