Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion components/Panel/Panel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Panel extends Component {

return (
<div className="Panel">
{header}
{this.props.showHeader ? header : null}
{body}
</div>
)
Expand All @@ -54,4 +54,8 @@ Panel.propTypes = {
expandTrigger: PropTypes.string
}

Panel.defaultProps = {
showHeader : true
}

export default Panel
5 changes: 4 additions & 1 deletion components/Panel/Panel.scss
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ $panel-header-bg-color: #DFDFE1;
border-right : 1px solid $tc-gray-40;
border-bottom : 1px solid $tc-gray-40;
padding: 10px;
overflow-x: visible;
overflow-y: scroll;
max-height: 252px;
}
}
}
15 changes: 10 additions & 5 deletions components/SearchBar/SearchBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class SearchBar extends Component {

handleSuggestionsUpdate(requestNo, data) {
if (requestNo === this.state.maxRequestNo) {
console.log('SUGGESTIONS', data)
this.setState({loading: false, suggestions: data, selectedSuggestionIdx: null})
}
}
Expand Down Expand Up @@ -102,6 +103,7 @@ class SearchBar extends Component {
this.refs.searchValue.value = null
this.setState({ searchValue: this.refs.searchValue.value })
this.setState({ searchState: 'empty' })
this.setState({ suggestions: false })
this.props.onClearSearch()
}

Expand Down Expand Up @@ -191,11 +193,11 @@ class SearchBar extends Component {

const results = this.state.loading === true
? <div className="loading-suggestions"><Loader /></div>
: <SearchSuggestions recentSearch={ recentList } searchTerm={ this.state.searchValue } popularSearch={ popularList } onSuggestionSelect={ this.handleSuggestionSelect } />
: <SearchSuggestions hideSuggestionsWhenEmpty={ this.props.hideSuggestionsWhenEmpty } recentSearch={ recentList } searchTerm={ this.state.searchValue } popularSearch={ popularList } showPopularSearchHeader={ this.props.showPopularSearchHeader } onSuggestionSelect={ this.handleSuggestionSelect } />
return (
<div className={ sbClasses }>
<input className="search-bar__text" onFocus={ this.onFocus } onChange={ this.onChange } onKeyUp={ this.onKeyUp } ref="searchValue" value={this.state.searchValue} />
<span className="search-typeahead-text">{ typeaheadText }</span>
<input className="search-bar__text" onFocus={ this.onFocus } onChange={ this.onChange } onKeyUp={ this.onKeyUp } ref="searchValue" value={this.state.searchValue} />
<img className="search-bar__clear" src={ require('./x-mark.svg') } onClick={ this.clearSearch }/>
<div className="search-icon-wrap" onClick={ this.search }>
<img className="search-bar__icon" src={ require('./icon-search.png') } />
Expand All @@ -209,19 +211,22 @@ class SearchBar extends Component {
}
}


SearchBar.propTypes = {
hideSuggestionsWhenEmpty: PropTypes.func.bool,
onSearch : PropTypes.func.isRequired,
onClearSearch : PropTypes.func,
onTermChange : PropTypes.func.isRequired,
recentTerms : PropTypes.array,
searchTermKey: PropTypes.string
searchTermKey: PropTypes.string,
showPopularSearchHeader: PropTypes.bool
}

SearchBar.defaultProps = {
hideSuggestionsWhenEmpty: false,
recentTerms : [],
searchTermKey : 'q',
onClearSearch : () => {}
onClearSearch : () => {},
showPopularSearchHeader: true
}

export default SearchBar
7 changes: 5 additions & 2 deletions components/SearchBar/SearchBar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@
font-size: 17px;
color: $tc-gray-90;
line-height: 20px;
width: calc(100% - 15px - 46px);
// NOTE: If uncommented, it causes problems with the proper alignment of
// the typeahead text.
// width: calc(100% - 15px - 46px);
position: absolute;
left: 15px;
top: 50%;
Expand All @@ -100,10 +102,11 @@
}

.search-typeahead-text {
position: absolute;
color: $tc-gray-40;
display: none;
z-index: 10;
left: 16.5px;
top: 19px;
}

.search-bar__clear {
Expand Down
18 changes: 13 additions & 5 deletions components/SearchSuggestions/SearchSuggestions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class SearchSuggestions extends Component {

const popularSearch = !popularList ? '' :(
<div className="popular-search-suggestions">
<Panel>
<Panel showHeader={this.props.showPopularSearchHeader}>
<div className="panel-header">
<div className="label">Popular</div>
</div>
Expand All @@ -100,7 +100,11 @@ class SearchSuggestions extends Component {
{ 'empty-state' : recentList && !popularList }
)

return (
const hide = this.props.hideSuggestionsWhenEmpty &&
(!recentList || !recentList.length) &&
(!popularList || !popularList.length)

return hide ? (<div></div>) : (
<div className={ ssClasses }>
{ popularSearch }
{ recentSearches }
Expand All @@ -110,16 +114,20 @@ class SearchSuggestions extends Component {
}

SearchSuggestions.propTypes = {
hideWhenEmpty : PropTypes.bool,
onSuggestionSelect : PropTypes.func.isRequired,
recentSearch : PropTypes.array,
popularSearch : PropTypes.array,
searchTerm : PropTypes.string
searchTerm : PropTypes.string,
showPopularSearchHeader: PropTypes.bool
}

SearchSuggestions.defaultProps = {
hideWhenEmpty : true,
recentSearch : [],
popularSearch : [],
searchTerm : ''
searchTerm : '',
showPopularSearchHeader: true
}

export default SearchSuggestions
export default SearchSuggestions
6 changes: 3 additions & 3 deletions components/SearchSuggestions/SearchSuggestions.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
border: 1px solid $tc-gray-30;
box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.3);
border-radius: 2px;
min-height: 303px;
// min-height: 303px;
position: relative;

.panel-header {
Expand Down Expand Up @@ -66,7 +66,7 @@
.panel-body {
border: none;
padding: 0;
padding-bottom: 5px;
// padding-bottom: 5px;

li.selected {
background-color: $tc-gray-neutral-dark;
Expand Down Expand Up @@ -127,4 +127,4 @@
.panel-body {
padding-bottom: 45px;
}
}
}
2 changes: 1 addition & 1 deletion components/SwitchButton/SwitchButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ require('./SwitchButton.scss')
const SwitchButton = ({label, ...props}) => {
return (
<div className="SwitchButton clearfix">
<span className="label">{label}</span>
<label>
<span className="label">{label}</span>
<input type="checkbox" {...props} />
<i/>
</label>
Expand Down
2 changes: 1 addition & 1 deletion components/SwitchButton/SwitchButton.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
display: flex;
.label{
width: 92px;
line-height: 30px;
line-height: 20px;
font-size: 12px;
@include roboto;
color: $tc-gray-60;
Expand Down