-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#55: added autosugest, restructure, created search multiple index, ap…
…ply easy style, refactoring
- Loading branch information
1 parent
e9f0fcb
commit c1f1760
Showing
6 changed files
with
349 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,164 @@ | ||
.ais-Highlight-highlighted | ||
@apply text-celeste | ||
.page-search-reesult | ||
.ais-Highlight-highlighted | ||
@apply text-celeste | ||
|
||
.seacrh-header | ||
display: inline-block | ||
width: 100% | ||
margin-bottom: 30px | ||
|
||
.left-panel | ||
float: left | ||
width: 65% | ||
|
||
.providers, | ||
.pages, | ||
.blog | ||
display: inline-block | ||
|
||
ul | ||
li | ||
float: left | ||
width: 100% | ||
margin: 10px 0 | ||
padding: 30px 10px 10px 10px | ||
position: relative | ||
|
||
&:first-of-type | ||
margin-top: 0 | ||
|
||
&:after | ||
position: absolute | ||
top: 0 | ||
right: 5px | ||
font-size: 20px | ||
font-weight: bold | ||
text-transform: uppercase | ||
|
||
.providers | ||
ul | ||
li | ||
border: 1px solid deeppink | ||
|
||
&:after | ||
content: 'provider' | ||
color: deeppink | ||
|
||
.pages | ||
ul | ||
li | ||
border: 1px solid darkgreen | ||
|
||
&:after | ||
content: 'page' | ||
color: darkgreen | ||
|
||
.blog | ||
ul | ||
li | ||
border: 1px solid dodgerblue | ||
|
||
&:after | ||
content: 'blog post' | ||
color: dodgerblue | ||
|
||
.ais-Pagination | ||
clear: left | ||
display: inline-block | ||
margin-bottom: 50px | ||
|
||
ul | ||
li | ||
float: left | ||
padding: 5px 10px | ||
margin: 0 10px | ||
border: 1px solid dimgrey | ||
line-height: 1 | ||
|
||
&:first-of-type | ||
margin-left: 0 | ||
|
||
&:last-of-type | ||
margin-right: 0 | ||
|
||
.right-panel | ||
float: right | ||
width: 30% | ||
padding: 10px | ||
border: 1px solid darkslategrey | ||
|
||
#stats | ||
text-align: center | ||
|
||
.ais-ClearRefinements | ||
display: inline-block | ||
margin: 30px 0 | ||
|
||
.filter | ||
h2 | ||
float: left | ||
width: 100% | ||
clear: left | ||
padding-bottom: 10px | ||
margin-bottom: 10px | ||
border-bottom: 1px solid darkred | ||
|
||
.ais-RefinementList | ||
display: inline-block | ||
margin-bottom: 20px | ||
|
||
ul | ||
li | ||
display: block | ||
width: 100% | ||
clear: left | ||
bordr-bottom: 1px solid grey | ||
|
||
label | ||
display: block | ||
width: 100% | ||
padding: 3px 0 | ||
|
||
input | ||
float: left | ||
width: auto | ||
margin: 3px 10px 0 0 | ||
|
||
span | ||
float: left | ||
line-height: 1 | ||
|
||
&.ais-RefinementList-count | ||
margin: 0 0 0 10px | ||
|
||
&:before | ||
content: '(' | ||
|
||
&:after | ||
content: ')' | ||
|
||
.react-autosuggest__container | ||
.react-autosuggest__input | ||
margin: 0 | ||
|
||
&.react-autosuggest__input--focused, | ||
&.react-autosuggest__input--open | ||
border-radius: 0.25rem 0.25rem 0 0 | ||
|
||
.react-autosuggest__suggestions-container | ||
display: none | ||
border: 1px solid yellowgreen | ||
border-top: unset | ||
padding: 10px | ||
|
||
&.react-autosuggest__suggestions-container--open | ||
display: block | ||
|
||
.react-autosuggest__section-title | ||
font-weight: bold | ||
text-transform: uppercase | ||
border-bottom: 1px solid dimgrey | ||
|
||
ul.react-autosuggest__suggestions-list | ||
li | ||
border-bottom: 1px solid lightgrey |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import { Highlight, connectAutoComplete } from 'react-instantsearch-dom'; | ||
// @ts-ignore | ||
import AutoSuggest from 'react-autosuggest'; | ||
|
||
class AutoComplete extends React.Component<{}> { | ||
// @ts-ignore | ||
state = { value: this.props.currentRefinement }; | ||
|
||
onChange = (event: any, { newValue }: any) => { | ||
this.setState({ | ||
value: newValue, | ||
}); | ||
}; | ||
|
||
onSuggestionsFetchRequested = ({ value }: any) => { | ||
// @ts-ignore | ||
this.props.refine(value); | ||
}; | ||
|
||
onSuggestionsClearRequested = () => { | ||
// @ts-ignore | ||
this.props.refine(); | ||
}; | ||
|
||
getSuggestionValue(hit: any) { | ||
return hit.name; | ||
} | ||
|
||
renderSuggestion(hit: any) { | ||
let result: any; | ||
if (hit.name) { | ||
result = <Highlight attribute="name" hit={hit} tagName="mark" />; | ||
} else if (hit.title) { | ||
result = <Highlight attribute="title" hit={hit} tagName="mark" />; | ||
} else { | ||
result = false; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
renderSectionTitle(section: any) { | ||
return section.index; | ||
} | ||
|
||
getSectionSuggestions(section: any) { | ||
return section.hits; | ||
} | ||
|
||
render() { | ||
const { hits, onSuggestionSelected }: any = this.props; | ||
const { value } = this.state; | ||
|
||
const inputProps = { | ||
placeholder: 'Cauta...', | ||
onChange: this.onChange, | ||
value, | ||
}; | ||
|
||
return ( | ||
<AutoSuggest | ||
suggestions={hits} | ||
multiSection={true} | ||
onSuggestionsFetchRequested={this.onSuggestionsFetchRequested} | ||
onSuggestionsClearRequested={this.onSuggestionsClearRequested} | ||
onSuggestionSelected={onSuggestionSelected} | ||
getSuggestionValue={this.getSuggestionValue} | ||
renderSuggestion={this.renderSuggestion} | ||
inputProps={inputProps} | ||
renderSectionTitle={this.renderSectionTitle} | ||
getSectionSuggestions={this.getSectionSuggestions} | ||
/> | ||
); | ||
} | ||
} | ||
|
||
// @ts-ignore | ||
export default connectAutoComplete(AutoComplete); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.