-
Notifications
You must be signed in to change notification settings - Fork 555
Expand file tree
/
Copy pathClearRefinements.js
More file actions
46 lines (40 loc) · 1.16 KB
/
ClearRefinements.js
File metadata and controls
46 lines (40 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import PropTypes from 'prop-types';
import React, { Component } from 'preact-compat';
import cx from 'classnames';
import Template from '../Template.js';
class ClearRefinements extends Component {
render() {
const { hasRefinements, cssClasses } = this.props;
const data = { hasRefinements };
const rootClassNames = cx(cssClasses.root);
const buttonClassNames = cx(cssClasses.button, {
[cssClasses.disabledButton]: !hasRefinements,
});
return (
<div className={rootClassNames}>
<Template
data={data}
templateKey="resetLabel"
rootTagName="button"
rootProps={{
className: buttonClassNames,
onClick: this.props.refine,
disabled: !hasRefinements,
}}
{...this.props.templateProps}
/>
</div>
);
}
}
ClearRefinements.propTypes = {
refine: PropTypes.func.isRequired,
cssClasses: PropTypes.shape({
root: PropTypes.string,
button: PropTypes.string,
disabledButton: PropTypes.string,
}),
hasRefinements: PropTypes.bool.isRequired,
templateProps: PropTypes.object.isRequired,
};
export default ClearRefinements;