Skip to content

Commit 44c3d08

Browse files
committed
initial commit
1 parent 1d90f8e commit 44c3d08

4 files changed

Lines changed: 13 additions & 6 deletions

File tree

src/components/core/filters/filter-checkboxes.jsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ const FilterCheckboxes = (props: FilterTypeProps): Element<*> => {
99
const {
1010
onSelectFacet = (a, b, c) => {},
1111
values = [],
12+
omitParenthesesOnCounts,
1213
} = props;
1314

1415
const controls = values.map((facetValue) => {
1516
const { count, label, selected, value } = facetValue;
1617
const onSelect = () => onSelectFacet(term, value, !selected);
18+
const countText = omitParenthesesOnCounts ? count : `(${count})`;
1719

1820
return (
1921
<div styleName="filter-value" key={label}>
@@ -28,7 +30,7 @@ const FilterCheckboxes = (props: FilterTypeProps): Element<*> => {
2830
/>
2931
<div styleName="filter-label">
3032
{label}
31-
<span styleName="count">&nbsp;({count})</span>
33+
<span styleName="count">&nbsp;{countText}</span>
3234
</div>
3335
</label>
3436
</div>

src/components/core/filters/filter-group.jsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,26 +24,27 @@ export default class FilterGroup extends Component {
2424
};
2525

2626
getExpandedState = () => {
27-
return this.props.initialyExpanded ? !this.state.expanded : this.state.expanded;
27+
return this.props.initiallyExpanded ? !this.state.expanded : this.state.expanded;
2828
}
2929

3030
toggleExpansion = () => this.setState({ expanded: !this.state.expanded });
3131

3232
render() {
33-
const { children, label, term, values } = this.props;
33+
const { children, label, term, values, omitParenthesesOnCounts } = this.props;
3434
const {
3535
onClearFacet = () => {},
3636
onSelectFacet = () => {},
3737
} = this.props;
3838
const expanded = this.getExpandedState();
3939

4040
const updatedChildren = React.Children.map(children, (child) => {
41-
return React.cloneElement(child, { onSelectFacet, term, values });
41+
return React.cloneElement(child, { onSelectFacet, term, values, omitParenthesesOnCounts });
4242
});
4343

4444
return (
4545
<div styleName="group">
4646
<FilterHeader
47+
omitParenthesesOnCounts={omitParenthesesOnCounts}
4748
count={this.selectedCount()}
4849
expanded={expanded}
4950
onClear={onClearFacet}

src/components/core/filters/filter-header.jsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ type Props = {
99
expanded: boolean,
1010
onClear: Function,
1111
onClick: Function,
12+
omitParenthesesOnCounts?: boolean,
1213
};
1314

1415
const FilterHeader = (props: Props): Element<*> => {
15-
const { children, count, expanded, onClear, onClick } = props;
16+
const { children, count, expanded, onClear, onClick, omitParenthesesOnCounts } = props;
1617
const iconStyle = expanded ? 'icon-minus' : 'icon-plus';
18+
const countText = omitParenthesesOnCounts ? count : `(${count})`;
1719

1820
return (
1921
<div styleName="header">
@@ -26,7 +28,7 @@ const FilterHeader = (props: Props): Element<*> => {
2628
>
2729
{children}
2830
{count > 0 && (
29-
<span styleName="count">&nbsp;({count})</span>
31+
<span styleName="count">&nbsp;{countText}</span>
3032
)}
3133
</a>
3234
</span>

src/components/core/filters/types.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export type FilterTypeProps = {
1616
onSelectFacet?: Function,
1717
term?: string,
1818
values?: Array<FilterValue>,
19+
omitParenthesesOnCounts?: boolean,
1920
};
2021

2122

@@ -27,4 +28,5 @@ export type FilterGroupProps = {
2728
onClearFacet?: Function,
2829
onSelectFacet?: Function,
2930
initiallyExpanded?: boolean,
31+
omitParenthesesOnCounts?: boolean,
3032
};

0 commit comments

Comments
 (0)