Skip to content

Hot fix x button to clear search #4274

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Apr 21, 2020
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
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ workflows:
filters:
branches:
only:
- develop
- feature-contentful
# This is beta env for production soft releases
- "build-prod-beta":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`Matches shallow shapshot shapshot 1`] = `
>
<ChallengeSearchBar
label="Search Challenges:"
onClearSearch={[Function]}
onSearch={[Function]}
placeholder="Type the challenge name here"
query=""
Expand Down Expand Up @@ -100,6 +101,7 @@ exports[`Matches shallow shapshot shapshot 2`] = `
>
<ChallengeSearchBar
label="Search Challenges:"
onClearSearch={[Function]}
onSearch={[Function]}
placeholder="Type the challenge name here"
query=""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ exports[`Matches shallow shapshot 1`] = `
type="text"
value="query"
/>
<span
className="src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__ClearButton___u_e0r src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__active___8LjMb"
onClick={[Function]}
onKeyPress={[Function]}
>
</span>
<span
className="src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__SearchButton___3GzR0 src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__active___8LjMb"
onClick={[Function]}
Expand Down Expand Up @@ -53,6 +60,13 @@ exports[`Matches shallow shapshot 2`] = `
type="text"
value=""
/>
<span
className="src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__ClearButton___u_e0r"
onClick={[Function]}
onKeyPress={[Function]}
>
</span>
<span
className="src-shared-components-challenge-listing-Filters-ChallengeSearchBar-___style__SearchButton___3GzR0"
onClick={[Function]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,17 @@ export default function ChallengeFilters({
setFilterState(filterObj);
};

const clearSearch = () => {
setFilterState(Filter.setText(filterState, ''));
setSearchText('');
};

return (
<div styleName="challenge-filters">
<div styleName="filter-header">
<ChallengeSearchBar
onSearch={text => setFilterState(Filter.setText(filterState, text))}
onClearSearch={() => clearSearch()}
label={isReviewOpportunitiesBucket ? 'Search Review Opportunities:' : 'Search Challenges:'}
placeholder={isReviewOpportunitiesBucket ? 'Search Review Opportunities' : 'Type the challenge name here'}
query={searchText}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import ZoomIcon from './ui-zoom.svg';

export default function ChallengeSearchBar({
onSearch,
onClearSearch,
placeholder,
query,
setQuery,
Expand All @@ -35,6 +36,13 @@ export default function ChallengeSearchBar({
type="text"
value={query}
/>
<span
styleName={`ClearButton ${query ? 'active' : ''}`}
onClick={() => onClearSearch()}
onKeyPress={() => onClearSearch()}
>
&#10799;
</span>
<span
styleName={`SearchButton ${query ? 'active' : ''}`}
onClick={() => onSearch(query.trim())}
Expand All @@ -56,6 +64,7 @@ ChallengeSearchBar.defaultProps = {

ChallengeSearchBar.propTypes = {
onSearch: PT.func.isRequired,
onClearSearch: PT.func.isRequired,
label: PT.string,
placeholder: PT.string,
query: PT.string.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ $challenge-space-15: $base-unit * 3;
$challenge-space-20: $base-unit * 4;
$challenge-space-30: $base-unit * 6;
$challenge-space-40: $base-unit * 8;
$challenge-space-60: $base-unit * 12;
$challenge-radius-1: $corner-radius / 2;
$challenge-radius-4: $corner-radius * 2;

Expand Down Expand Up @@ -43,6 +44,7 @@ $search-input-width: '100% - 56px';
margin-bottom: 0;
margin-left: 10px;
vertical-align: middle;
padding-right: 28px;

@include placeholder {
@include roboto-light;
Expand Down Expand Up @@ -77,4 +79,24 @@ $search-input-width: '100% - 56px';
width: 16px;
}
}

.ClearButton {
display: none;
cursor: pointer;
position: absolute;
right: $challenge-space-60 - 3;
padding: $base-unit;
border-radius: 0 $challenge-radius-4 $challenge-radius-4 0;
vertical-align: middle;
height: 38px;
font-size: 25px;

&.active {
display: inline-block;
}

&:hover {
color: $tc-red-110;
}
}
}