From 9e9d438b0e4731e1511c91e3e7124fc7688e1dc7 Mon Sep 17 00:00:00 2001 From: Pixelastic Date: Fri, 16 Oct 2015 15:58:26 +0200 Subject: [PATCH] feat(headerFooter): Add BEM classes to header and footer All headers and footers will now receive a `ais-header` and `ais-footer` class. Additional classes can also be added through `cssClasses.{root,header,body,footer}`. It means that it is no longer necessary to pass a full HTML div in the `templates.header`. One can simply pass the header text content and pass a `cssClasses.header` custom class. So far only the `refinementList` widgets correctly add the `ais-widgetname-header`/`ais-widgetname-footer` classes. I'll update the other widgets once this gets merged. Fixes #259 Relies on https://github.com/algolia/instantsearch.js/pull/264 being merged first --- README.md | 30 +++++++++++-------- decorators/headerFooter.js | 35 ++++++++++++++-------- example/app.js | 20 +++++++++---- widgets/refinement-list/refinement-list.js | 4 +++ 4 files changed, 59 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index abb04d2caa..58398036ab 100644 --- a/README.md +++ b/README.md @@ -593,19 +593,25 @@ search.addWidget( #### Styling ```html -
-
- -
-
- +
+
[custom header template]
+
+
+
+ +
+
+ +
+
+
``` diff --git a/decorators/headerFooter.js b/decorators/headerFooter.js index 171f779af2..d002b34692 100644 --- a/decorators/headerFooter.js +++ b/decorators/headerFooter.js @@ -1,6 +1,6 @@ var React = require('react'); -var cx = require('classnames'); +var cx = require('classnames/dedupe'); var Template = require('../components/Template'); @@ -10,12 +10,25 @@ function headerFooter(ComposedComponent) { // override potential widget's defined transformData, // header and footer currently do not have it var transformData = null; + var templateProps = this.props.templateProps; + var classNames = { + root: this.props.cssClasses.root, + header: cx(this.props.cssClasses.header, 'ais-header'), + body: this.props.cssClasses.body, + footer: cx(this.props.cssClasses.footer, 'ais-footer') + }; return ( -
-