Skip to content

Commit a7600dc

Browse files
author
Vikas Agarwal
committed
Merge branch 'master' into feature/merged-with-master
* master: Revert "Project search typeahead fix and styles clean up - connect-app issue #43" Conflicts: components/SearchBar/SearchBar.jsx components/SearchBar/SearchBar.scss components/SwitchButton/SwitchButton.scss
2 parents 81ef248 + 137a5c5 commit a7600dc

File tree

9 files changed

+88
-89
lines changed

9 files changed

+88
-89
lines changed

components/Panel/Panel.jsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class Panel extends Component {
4242

4343
return (
4444
<div className="Panel">
45-
{this.props.showHeader ? header : null}
45+
{header}
4646
{body}
4747
</div>
4848
)
@@ -54,8 +54,4 @@ Panel.propTypes = {
5454
expandTrigger: PropTypes.string
5555
}
5656

57-
Panel.defaultProps = {
58-
showHeader : true
59-
}
60-
6157
export default Panel

components/Panel/Panel.scss

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,5 @@ $panel-header-bg-color: #DFDFE1;
1919
border-right : 1px solid $tc-gray-40;
2020
border-bottom : 1px solid $tc-gray-40;
2121
padding: 10px;
22-
overflow-x: visible;
23-
overflow-y: scroll;
24-
max-height: 252px;
2522
}
26-
}
23+
}

components/SearchBar/SearchBar.jsx

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ class SearchBar extends Component {
2929
this.handleSuggestionsUpdate = this.handleSuggestionsUpdate.bind(this)
3030
}
3131

32-
getQueryStringValue (key) {
32+
getQueryStringValue (key) {
3333
return unescape(window.location.href.replace(new RegExp('^(?:.*[&\\?]' + escape(key).replace(/[\.\+\*]/g, '\\$&') + '(?:\\=([^&]*))?)?.*$', 'i'), '$1'))
34-
}
34+
}
3535

3636
componentDidMount() {
3737
window.addEventListener('click', this.handleOutsideClick)
@@ -73,7 +73,6 @@ class SearchBar extends Component {
7373

7474
handleSuggestionsUpdate(requestNo, data) {
7575
if (requestNo === this.state.maxRequestNo) {
76-
console.log('SUGGESTIONS', data)
7776
this.setState({loading: false, suggestions: data, selectedSuggestionIdx: null})
7877
}
7978
}
@@ -109,8 +108,6 @@ class SearchBar extends Component {
109108
this.refs.searchValue.value = ''
110109
this.setState({ searchValue: this.refs.searchValue.value, finalTerm: '' })
111110
this.setState({ searchState: 'empty' })
112-
this.setState({ suggestions: false })
113-
this.props.onClearSearch()
114111
}
115112

116113
onKeyUp(evt) {
@@ -207,14 +204,14 @@ class SearchBar extends Component {
207204

208205
const results = this.state.loading === true
209206
? <div className="loading-suggestions"><Loader /></div>
210-
: <SearchSuggestions hideSuggestionsWhenEmpty={ this.props.hideSuggestionsWhenEmpty } recentSearch={ recentList } searchTerm={ this.state.searchValue } popularSearch={ popularList } showPopularSearchHeader={ this.props.showPopularSearchHeader } onSuggestionSelect={ this.handleSuggestionSelect } />
207+
: <SearchSuggestions recentSearch={ recentList } searchTerm={ this.state.searchValue } popularSearch={ popularList } onSuggestionSelect={ this.handleSuggestionSelect } />
211208
return (
212209
<div className={ sbClasses }>
213-
<span className="search-typeahead-text">{ typeaheadText }</span>
214210
<input className="search-bar__text" onFocus={ this.onFocus } onChange={ this.onChange } onKeyUp={ this.onKeyUp } ref="searchValue" value={this.state.searchValue} />
211+
<span className="search-typeahead-text">{ typeaheadText }</span>
215212
<img className="search-bar__clear" src={ require('./x-mark.svg') } onClick={ this.clearSearch }/>
216-
<div className="search-icon-wrap" onClick={ this.handleClick }>
217-
<span className="search-txt">Search</span>
213+
<div className="search-icon-wrap" onClick={ this.search }>
214+
<img className="search-bar__icon" src={ require('./ico-mobile-search-selected.svg') } />
218215
</div>
219216
<div className="suggestions-panel">
220217
{results}
@@ -225,22 +222,17 @@ class SearchBar extends Component {
225222
}
226223
}
227224

225+
228226
SearchBar.propTypes = {
229-
hideSuggestionsWhenEmpty: PropTypes.bool,
230227
onSearch : PropTypes.func.isRequired,
231-
onClearSearch : PropTypes.func,
232228
onTermChange : PropTypes.func.isRequired,
233229
recentTerms : PropTypes.array,
234-
searchTermKey: PropTypes.string,
235-
showPopularSearchHeader: PropTypes.bool
230+
searchTermKey: PropTypes.string
236231
}
237232

238233
SearchBar.defaultProps = {
239-
hideSuggestionsWhenEmpty: false,
240234
recentTerms : [],
241-
searchTermKey : 'q',
242-
onClearSearch : () => {},
243-
showPopularSearchHeader: true
235+
searchTermKey : 'q'
244236
}
245237

246238
export default SearchBar
Lines changed: 59 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1-
@import 'tc-includes';
1+
@import "tc-includes";
2+
3+
$border-color: #D8D8DB;
4+
$active-icon-wrap-bg: #888894;
25

36
.SearchBar {
4-
@include roboto;
5-
background: $tc-gray-80;
6-
height: 30px;
7+
// @include roboto;
8+
// background: $tc-gray-80;
9+
// height: 30px;
10+
// width: 100%;
11+
// border: 0;
12+
// border-radius: 2px;
13+
14+
background-color: $tc-white;
15+
height: 40px;
716
width: 100%;
8-
border: 0;
9-
border-radius: 2px;
17+
border: 1px solid $border-color;
18+
border-radius: 4px;
1019
position: relative;
1120
padding-left: 15px;
1221
padding-right: 46px;
@@ -23,19 +32,22 @@
2332
}
2433

2534
&.state-empty:before {
26-
content: "Search for projects";
35+
content: "Search Topcoder for challenges, people or content";
2736
position: absolute;
2837
left: 15px;
2938
top: 50%;
30-
text-align: left;
3139
transform: translateY(-50%);
3240
color: $tc-gray-40;
33-
font-size: 13px;
41+
font-size: 15px;
3442
line-height: 20px;
3543
width: 75%;
3644
white-space: nowrap;
3745
overflow-x: hidden;
3846
text-overflow: ellipsis;
47+
48+
@media screen and (max-width: 768px) {
49+
content: "Search Topcoder";
50+
}
3951
}
4052

4153
&.state-focused:before,
@@ -45,9 +57,11 @@
4557

4658
&.state-filled,
4759
&.state-focused {
60+
// border-color: $tc-gray-40;
61+
// padding-right: 88px;
62+
// background-color: white;
63+
4864
border-color: $tc-gray-40;
49-
padding-right: 88px;
50-
background-color: white;
5165

5266
.search-txt {
5367
display: block;
@@ -58,12 +72,23 @@
5872
background-color: $tc-dark-blue-90;
5973
z-index: 20;
6074
cursor: pointer;
75+
background-color: $active-icon-wrap-bg;
76+
}
77+
.search-typeahead-text {
78+
display: block;
6179
}
6280
}
6381

64-
&.state-focused {
82+
&.state-filled {
83+
border-color: $border-color;
84+
6585
.search-typeahead-text {
66-
display: block;
86+
display: none;
87+
}
88+
89+
.search-icon-wrap {
90+
cursor: pointer;
91+
background-color: $active-icon-wrap-bg;
6792
}
6893

6994
.suggestions-panel {
@@ -73,24 +98,21 @@
7398

7499
.search-bar__text,
75100
.search-typeahead-text {
76-
@include roboto;
101+
font-family: "Roboto", Arial, Helvetica, sans-serif;
77102
outline: 0px;
78103
border: 0px none;
79104
font-size: 17px;
80105
color: $tc-gray-90;
81106
line-height: 20px;
82-
// NOTE: If uncommented, it causes problems with the proper alignment of
83-
// the typeahead text.
84-
// width: calc(100% - 15px - 46px);
107+
width: 90%;
85108
position: absolute;
86109
left: 0;
87110
text-indent: 15px;
88111
top: 50%;
89112
transform: translateY(-50%);
90-
background-color: transparent !important;
113+
background-color: transparent;
91114
z-index: 20;
92115
padding-left: 0px;
93-
height: 30px;
94116
}
95117

96118
.search-bar__text {
@@ -104,11 +126,10 @@
104126
}
105127

106128
.search-typeahead-text {
107-
position: absolute;
108129
color: $tc-gray-40;
109130
display: none;
110-
z-index: 20;
111-
top: 19px;
131+
z-index: 10;
132+
left: 16.5px;
112133
}
113134

114135
.search-bar__clear {
@@ -121,26 +142,27 @@
121142
}
122143

123144
.search-icon-wrap {
145+
width: 46px;
146+
height: 40px;
124147
position: absolute;
125-
right: 0;
126-
top: 0;
127-
height: 30px;
128-
width: 37px;
129-
background: $tc-gray-60 url("./ui-16px-2_zoom.svg") 10px 7px no-repeat;
130-
border-radius: 0 2px 2px 0;
131-
border-left: 1px solid $tc-black;
132-
@include roboto;
133-
font-size: 12px;
134-
color: $tc-white;
135-
padding-left: 36px;
136-
text-align: left;
137-
line-height: 30px;
148+
top: -1px;
149+
right: -1px;
150+
background-color: $tc-gray-neutral-light;
151+
border-top-right-radius: 4px;
152+
border-bottom-right-radius: 4px;
153+
154+
.search-bar__icon {
155+
position: absolute;
156+
top: 50%;
157+
left: 50%;
158+
transform: translate(-50%, -50%);
159+
}
138160
}
139161

140162
.suggestions-panel {
141163
display: none;
142164
position: absolute;
143-
top: 30px;
165+
top: 43px;
144166
left: 0;
145167
width: 100%;
146168
z-index: 1000;
@@ -154,4 +176,4 @@
154176
}
155177
}
156178
}
157-
}
179+
}

components/SearchBar/ico-mobile-search-selected.svg

Lines changed: 1 addition & 1 deletion
Loading
-1.57 KB
Binary file not shown.

components/SearchBar/x-mark.svg

Lines changed: 1 addition & 1 deletion
Loading

components/SearchSuggestions/SearchSuggestions.jsx

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class SearchSuggestions extends Component {
8383

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

103-
const hide = this.props.hideSuggestionsWhenEmpty &&
104-
(!recentList || !recentList.length) &&
105-
(!popularList || !popularList.length)
106-
107-
return hide ? (<div></div>) : (
103+
return (
108104
<div className={ ssClasses }>
109105
{ popularSearch }
110106
{ recentSearches }
@@ -114,20 +110,16 @@ class SearchSuggestions extends Component {
114110
}
115111

116112
SearchSuggestions.propTypes = {
117-
hideWhenEmpty : PropTypes.bool,
118113
onSuggestionSelect : PropTypes.func.isRequired,
119114
recentSearch : PropTypes.array,
120115
popularSearch : PropTypes.array,
121-
searchTerm : PropTypes.string,
122-
showPopularSearchHeader: PropTypes.bool
116+
searchTerm : PropTypes.string
123117
}
124118

125119
SearchSuggestions.defaultProps = {
126-
hideWhenEmpty : true,
127120
recentSearch : [],
128121
popularSearch : [],
129-
searchTerm : '',
130-
showPopularSearchHeader: true
122+
searchTerm : ''
131123
}
132124

133-
export default SearchSuggestions
125+
export default SearchSuggestions

0 commit comments

Comments
 (0)