Skip to content

Commit

Permalink
Merge pull request #1371 from nextstrain/filters
Browse files Browse the repository at this point in the history
Allow hiding of all filters in a category
  • Loading branch information
jameshadfield authored Jul 15, 2021
2 parents 35d90f1 + f05d78f commit c0ff4e4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/components/controls/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ class FilterData extends React.Component {
return {
filterName,
displayName: filterBadgeDisplayName(n, this.getFilterTitle(filterName)),
remove: () => {this.props.dispatch(applyFilter("set", filterName, []));}
anyFiltersActive: () => this.props.activeFilters[filterName].filter((f) => f.active).length>0,
remove: () => {this.props.dispatch(applyFilter("set", filterName, []));},
activate: () => {this.props.dispatch(applyFilter("add", filterName, this.props.activeFilters[filterName].map((f) => f.value)));},
inactivate: () => {this.props.dispatch(applyFilter("inactivate", filterName, this.props.activeFilters[filterName].map((f) => f.value)));}
};
});
}
Expand Down Expand Up @@ -138,9 +141,12 @@ class FilterData extends React.Component {
{inUseFilters.map((filter) => (
<div style={{display: 'inline-block', margin: '2px'}} key={filter.displayName}>
<FilterBadge
active
active={filter.anyFiltersActive()}
canMakeInactive
id={filter.displayName}
remove={filter.remove}
activate={filter.activate}
inactivate={filter.inactivate}
onHoverMessage={`Data is currently filtered by ${filter.displayName}`}
>
{filter.displayName}
Expand Down
2 changes: 1 addition & 1 deletion src/components/info/filterBadge.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const SelectedFilterTextContainer = styled(BaseContainer)`

const BadgeContainer = styled.div`
background-color: #E9F2F6;
${(props) => props.striped ? 'background: repeating-linear-gradient(135deg, #E9F2F6, #E9F2F6 5px, transparent 5px, transparent 10px);' : ''};
${(props) => props.striped ? 'background: repeating-linear-gradient(135deg, #E9F2F6, #E9F2F6 5px, #FFFFFF 5px, #FFFFFF 10px);' : ''};
display: inline-block;
font-size: 14px;
border-radius: 2px;
Expand Down

0 comments on commit c0ff4e4

Please sign in to comment.