From b09b8308e5a36aa95a76ec0e3f8b9160065fa47a Mon Sep 17 00:00:00 2001 From: Pixelastic Date: Fri, 16 Oct 2015 14:29:49 +0200 Subject: [PATCH] feat(refinement-list): Add BEM naming --- README.md | 49 ++++++++++++++++++--- components/RefinementList.js | 15 ++++--- example/app.js | 7 +-- example/style.css | 4 ++ themes/debug.css | 13 +++++- widgets/refinement-list/defaultTemplates.js | 6 +-- widgets/refinement-list/refinement-list.css | 12 +++++ widgets/refinement-list/refinement-list.js | 32 ++++++++++---- 8 files changed, 111 insertions(+), 27 deletions(-) create mode 100644 widgets/refinement-list/refinement-list.css diff --git a/README.md b/README.md index 986054bd4a..abb04d2caa 100644 --- a/README.md +++ b/README.md @@ -556,14 +556,19 @@ search.addWidget( * @param {String} [options.limit=1000] How much facet values to get * @param {Object} [options.cssClasses] CSS classes to add to the wrapping elements: root, list, item * @param {String|String[]} [options.cssClasses.root] CSS class to add to the root element + * @param {String|String[]} [options.cssClasses.header] CSS class to add to the header element + * @param {String|String[]} [options.cssClasses.body] CSS class to add to the body element + * @param {String|String[]} [options.cssClasses.footer] CSS class to add to the footer element * @param {String|String[]} [options.cssClasses.list] CSS class to add to the list element * @param {String|String[]} [options.cssClasses.item] CSS class to add to each item element + * @param {String|String[]} [options.cssClasses.active] CSS class to add to each active element + * @param {String|String[]} [options.cssClasses.label] CSS class to add to each label element (when using the default template) + * @param {String|String[]} [options.cssClasses.checkbox] CSS class to add to each checkbox element (when using the default template) + * @param {String|String[]} [options.cssClasses.count] CSS class to add to each count element (when using the default template) * @param {Object} [options.templates] Templates to use for the widget - * @param {String|Function} [options.templates.header=''] Header template - * @param {String|Function} [options.templates.item=``] Item template, provided with `name`, `count`, `isRefined` - * @param {String|Function} [options.templates.footer=''] Footer template + * @param {String|Function} [options.templates.header] Header template + * @param {String|Function} [options.templates.item] Item template, provided with `name`, `count`, `isRefined` + * @param {String|Function} [options.templates.footer] Footer template * @param {Function} [options.transformData] Function to change the object passed to the item template * @param {boolean} [hideWhenNoResults=true] Hide the container when there's no results * @return {Object} @@ -585,6 +590,40 @@ search.addWidget( ); ``` +#### Styling + +```html +
+
+ +
+
+ +
+
+``` + +```css +.ais-refinement-list--list { +} +.ais-refinement-list--item { +} +.ais-refinement-list--item__active { +} +.ais-refinement-list--label { +} +.ais-refinement-list--checkbox { +} +.ais-refinement-list--count { +} +``` + ### menu ![Example of the menu widget][menu] diff --git a/components/RefinementList.js b/components/RefinementList.js index 1a84e9f267..60c073ea61 100644 --- a/components/RefinementList.js +++ b/components/RefinementList.js @@ -16,13 +16,19 @@ class RefinementList extends React.Component { : null; + var templateData = {...facetValue, cssClasses: this.props.cssClasses}; + + var cssClassItem = cx(this.props.cssClasses.item, { + [this.props.cssClasses.active]: facetValue.isRefined + }); + return (
-