Skip to content
This repository was archived by the owner on Jul 16, 2023. It is now read-only.

Commit

Permalink
chore: minor search improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed Aug 4, 2020
1 parent 976551b commit e3f3420
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 59 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"@emotion/core": "10.0.28",
"@emotion/styled": "10.0.27",
"@emotion/styled-base": "10.0.31",
"@loadable/component": "5.13.1",
"@mdx-js/loader": "1.6.14",
"@mdx-js/mdx": "1.6.14",
"@mdx-js/react": "1.6.14",
Expand Down
59 changes: 59 additions & 0 deletions src/components/Loader/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import React from 'react';
import { css } from '@emotion/core';

const spinner = css`
width: 40px;
height: 40px;
position: relative;
margin: 0 auto;
.double-bounce1,
.double-bounce2 {
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #333;
opacity: 0.6;
position: absolute;
top: 0;
left: 0;
-webkit-animation: sk-bounce 2s infinite ease-in-out;
animation: sk-bounce 2s infinite ease-in-out;
}
.double-bounce2 {
-webkit-animation-delay: -1s;
animation-delay: -1s;
}
@-webkit-keyframes sk-bounce {
0%,
100% {
-webkit-transform: scale(0);
}
50% {
-webkit-transform: scale(1);
}
}
@keyframes sk-bounce {
0%,
100% {
transform: scale(0);
-webkit-transform: scale(0);
}
50% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
`;

export default ({ ...props }) => (
<div css={spinner} {...props}>
<div className={'double-bounce1'}></div>
<div className={'double-bounce2'}></div>
</div>
);
8 changes: 6 additions & 2 deletions src/components/Search/Sidebar.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
/* eslint-disable react/display-name */
import Algolia from './algolia/index';
import styled from '@emotion/styled';
import React, { useRef } from 'react';
import config from 'config';
import VisibilitySensor from 'react-visibility-sensor';
import { X } from 'react-feather';
import loadable from '@loadable/component';

import { onMobile } from '../../styles/responsive';
import { visibleMobile, shadowAround } from '../../styles';

const Algolia = loadable(() => import('./algolia/'))

const SearchWrapper = styled.div`
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -43,6 +45,8 @@ width: 100%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
box-shadow: 0 3px 8px 0 ${(props) => props.theme.colors.shadow};
border-bottom: 1px solid ${(props) => props.theme.colors.border};
svg {
width: 1.2em;
Expand Down Expand Up @@ -72,7 +76,7 @@ const Search = React.forwardRef(({ onVisibleChange, closeSelf, ...props }, ref)
<SearchWrapper {...props}>
<CloseSearch css={visibleMobile} onClick={closeSelf}>
<X />
<span css={{marginLeft: '5px'}}>Close Search</span>
<span css={{marginLeft: '5px'}}>Close</span>
</CloseSearch>
<VisibilitySensor onChange={onVisibilityChange}>
<Algolia ref={searchRef} inputRef={inputRef} index={config.features.search.indexName} />
Expand Down
58 changes: 1 addition & 57 deletions src/components/Search/Status.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import styled from '@emotion/styled';
import { css } from '@emotion/core';
import { marginLeftRight } from './styles';
import Loading from '../Loader';

const queryToken = css`
font-weight: bold;
Expand All @@ -18,63 +19,6 @@ const StatusWrapper = styled.div`
}
`;

const spinner = css`
width: 40px;
height: 40px;
position: relative;
margin: 0 auto;
.double-bounce1,
.double-bounce2 {
width: 100%;
height: 100%;
border-radius: 50%;
background-color: #333;
opacity: 0.6;
position: absolute;
top: 0;
left: 0;
-webkit-animation: sk-bounce 2s infinite ease-in-out;
animation: sk-bounce 2s infinite ease-in-out;
}
.double-bounce2 {
-webkit-animation-delay: -1s;
animation-delay: -1s;
}
@-webkit-keyframes sk-bounce {
0%,
100% {
-webkit-transform: scale(0);
}
50% {
-webkit-transform: scale(1);
}
}
@keyframes sk-bounce {
0%,
100% {
transform: scale(0);
-webkit-transform: scale(0);
}
50% {
transform: scale(1);
-webkit-transform: scale(1);
}
}
`;

const Loading = ({ ...props }) => (
<div css={spinner} {...props}>
<div className={'double-bounce1'}></div>
<div className={'double-bounce2'}></div>
</div>
);

const SearchStatus = ({ searching, noHits, query }) => {
let text = '';
if (searching) {
Expand Down

0 comments on commit e3f3420

Please sign in to comment.