diff --git a/src/BootstrapMixin.js b/src/BootstrapMixin.js index cc5e1f1a15..17c8e81d2b 100644 --- a/src/BootstrapMixin.js +++ b/src/BootstrapMixin.js @@ -1,3 +1,4 @@ +import React from 'react'; import styleMaps from './styleMaps'; import CustomPropTypes from './utils/CustomPropTypes'; @@ -12,7 +13,7 @@ const BootstrapMixin = { * Style variants * @type {("default"|"primary"|"success"|"info"|"warning"|"danger"|"link")} */ - bsStyle: CustomPropTypes.keyOf(styleMaps.STYLES), + bsStyle: React.PropTypes.oneOf(styleMaps.STYLES), /** * Size variants * @type {("xsmall"|"small"|"medium"|"large")} @@ -35,9 +36,8 @@ const BootstrapMixin = { } if (this.props.bsStyle) { - let bsStyle = styleMaps.STYLES[this.props.bsStyle]; - if (bsStyle) { - classes[prefix + bsStyle] = true; + if (styleMaps.STYLES.indexOf(this.props.bsStyle) >= 0) { + classes[prefix + this.props.bsStyle] = true; } else { classes[this.props.bsStyle] = true; } diff --git a/src/styleMaps.js b/src/styleMaps.js index a200286d33..49ad80f3f0 100644 --- a/src/styleMaps.js +++ b/src/styleMaps.js @@ -21,20 +21,20 @@ const styleMaps = { 'row': 'row', 'well': 'well' }, - STYLES: { - 'default': 'default', - 'primary': 'primary', - 'success': 'success', - 'info': 'info', - 'warning': 'warning', - 'danger': 'danger', - 'link': 'link', - 'inline': 'inline', - 'tabs': 'tabs', - 'pills': 'pills' - }, + STYLES: [ + 'default', + 'primary', + 'success', + 'info', + 'warning', + 'danger', + 'link', + 'inline', + 'tabs', + 'pills' + ], addStyle(name) { - styleMaps.STYLES[name] = name; + styleMaps.STYLES.push(name); }, SIZES: { 'large': 'lg', diff --git a/test/BootstrapMixinSpec.js b/test/BootstrapMixinSpec.js index 32eaf0e147..5190aec58e 100644 --- a/test/BootstrapMixinSpec.js +++ b/test/BootstrapMixinSpec.js @@ -222,4 +222,16 @@ describe('BootstrapMixin', function () { }); }); }); + + // todo: fix bad naming + describe('#prefixClass', function () { + it('allows custom sub-classes', function () { + let instance = ReactTestUtils.renderIntoDocument( + + content + + ); + assert.equal(instance.prefixClass('title'), 'btn-title'); + }); + }); });