File tree 5 files changed +52
-0
lines changed
__tests__/shared/components/challenge-listing/Filters/__snapshots__
src/shared/components/challenge-listing/Filters
5 files changed +52
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ exports[`Matches shallow shapshot shapshot 1`] = `
9
9
>
10
10
<ChallengeSearchBar
11
11
label = " Search Challenges:"
12
+ onClearSearch = { [Function ]}
12
13
onSearch = { [Function ]}
13
14
placeholder = " Type the challenge name here"
14
15
query = " "
@@ -100,6 +101,7 @@ exports[`Matches shallow shapshot shapshot 2`] = `
100
101
>
101
102
<ChallengeSearchBar
102
103
label = " Search Challenges:"
104
+ onClearSearch = { [Function ]}
103
105
onSearch = { [Function ]}
104
106
placeholder = " Type the challenge name here"
105
107
query = " "
Original file line number Diff line number Diff line change @@ -17,6 +17,13 @@ exports[`Matches shallow shapshot 1`] = `
17
17
type = " text"
18
18
value = " query"
19
19
/>
20
+ <span
21
+ className = " src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__ClearButton___u_e0r src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__active___8LjMb"
22
+ onClick = { [Function ]}
23
+ onKeyPress = { [Function ]}
24
+ >
25
+ ⨯
26
+ </span >
20
27
<span
21
28
className = " src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__SearchButton___3GzR0 src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__active___8LjMb"
22
29
onClick = { [Function ]}
@@ -53,6 +60,13 @@ exports[`Matches shallow shapshot 2`] = `
53
60
type = " text"
54
61
value = " "
55
62
/>
63
+ <span
64
+ className = " src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__ClearButton___u_e0r"
65
+ onClick = { [Function ]}
66
+ onKeyPress = { [Function ]}
67
+ >
68
+ ⨯
69
+ </span >
56
70
<span
57
71
className = " src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__SearchButton___3GzR0"
58
72
onClick = { [Function ]}
Original file line number Diff line number Diff line change @@ -57,11 +57,17 @@ export default function ChallengeFilters({
57
57
setFilterState ( filterObj ) ;
58
58
} ;
59
59
60
+ const clearSearch = ( ) => {
61
+ setFilterState ( Filter . setText ( filterState , '' ) ) ;
62
+ setSearchText ( '' ) ;
63
+ } ;
64
+
60
65
return (
61
66
< div styleName = "challenge-filters" >
62
67
< div styleName = "filter-header" >
63
68
< ChallengeSearchBar
64
69
onSearch = { text => setFilterState ( Filter . setText ( filterState , text ) ) }
70
+ onClearSearch = { ( ) => clearSearch ( ) }
65
71
label = { isReviewOpportunitiesBucket ? 'Search Review Opportunities:' : 'Search Challenges:' }
66
72
placeholder = { isReviewOpportunitiesBucket ? 'Search Review Opportunities' : 'Type the challenge name here' }
67
73
query = { searchText }
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ import ZoomIcon from './ui-zoom.svg';
19
19
20
20
export default function ChallengeSearchBar ( {
21
21
onSearch,
22
+ onClearSearch,
22
23
placeholder,
23
24
query,
24
25
setQuery,
@@ -35,6 +36,13 @@ export default function ChallengeSearchBar({
35
36
type = "text"
36
37
value = { query }
37
38
/>
39
+ < span
40
+ styleName = { `ClearButton ${ query ? 'active' : '' } ` }
41
+ onClick = { ( ) => onClearSearch ( ) }
42
+ onKeyPress = { ( ) => onClearSearch ( ) }
43
+ >
44
+ ⨯
45
+ </ span >
38
46
< span
39
47
styleName = { `SearchButton ${ query ? 'active' : '' } ` }
40
48
onClick = { ( ) => onSearch ( query . trim ( ) ) }
@@ -56,6 +64,7 @@ ChallengeSearchBar.defaultProps = {
56
64
57
65
ChallengeSearchBar . propTypes = {
58
66
onSearch : PT . func . isRequired ,
67
+ onClearSearch : PT . func . isRequired ,
59
68
label : PT . string ,
60
69
placeholder : PT . string ,
61
70
query : PT . string . isRequired ,
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ $challenge-space-15: $base-unit * 3;
4
4
$challenge-space-20 : $base-unit * 4 ;
5
5
$challenge-space-30 : $base-unit * 6 ;
6
6
$challenge-space-40 : $base-unit * 8 ;
7
+ $challenge-space-60 : $base-unit * 12 ;
7
8
$challenge-radius-1 : $corner-radius / 2 ;
8
9
$challenge-radius-4 : $corner-radius * 2 ;
9
10
@@ -77,4 +78,24 @@ $search-input-width: '100% - 56px';
77
78
width : 16px ;
78
79
}
79
80
}
81
+
82
+ .ClearButton {
83
+ display : none ;
84
+ cursor : pointer ;
85
+ position : absolute ;
86
+ right : $challenge-space-60 - 4 ;
87
+ padding : $base-unit ;
88
+ border-radius : 0 $challenge-radius-4 $challenge-radius-4 0 ;
89
+ vertical-align : middle ;
90
+ height : 40px ;
91
+ font-size : 25px ;
92
+
93
+ & .active {
94
+ display : inline-block ;
95
+ }
96
+
97
+ & :hover {
98
+ color : $tc-red-110 ;
99
+ }
100
+ }
80
101
}
You can’t perform that action at this time.
0 commit comments