Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(bem): support block modifier class names
Browse files Browse the repository at this point in the history
  • Loading branch information
rayrutjes committed Apr 7, 2017
1 parent 826bbc9 commit 7bde05c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/vue-instantsearch-component/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,26 @@ export default {
if(!this.blockClassName) {
throw new Error('You need to provide \'blockClassName\' in your data.')
}

const blockClassName = this.blockClassName
if(!element) {
if(!element && !modifier) {
return this.customClassName(blockClassName)
}

if(!element) {
const blockModifierClassName = blockClassName + '--' + modifier

return this.customClassName(blockModifierClassName)
}

const elementClassName = blockClassName + '__' + element
if (!modifier) {
return this.customClassName(elementClassName)
}

const modifierClassName = elementClassName + '--' + modifier
const elementModifierClassName = elementClassName + '--' + modifier

return this.customClassName(elementClassName) + ' ' + this.customClassName(modifierClassName)
return this.customClassName(elementClassName) + ' ' + this.customClassName(elementModifierClassName)
},
customClassName (className) {
return !this.classNames[className] ? className : this.classNames[className]
Expand Down

0 comments on commit 7bde05c

Please sign in to comment.