Skip to content

Commit

Permalink
rename constants to styleMaps
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevor Robinson committed Apr 10, 2015
1 parent 4f28b2b commit a4168be
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/BootstrapMixin.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
import React from 'react';
import constants from './constants';
import styleMaps from './styleMaps';
import CustomPropTypes from './utils/CustomPropTypes';

const BootstrapMixin = {
propTypes: {
bsClass: CustomPropTypes.keyOf(constants.CLASSES),
bsStyle: CustomPropTypes.keyOf(constants.STYLES),
bsSize: CustomPropTypes.keyOf(constants.SIZES)
bsClass: CustomPropTypes.keyOf(styleMaps.CLASSES),
bsStyle: CustomPropTypes.keyOf(styleMaps.STYLES),
bsSize: CustomPropTypes.keyOf(styleMaps.SIZES)
},

getBsClassSet() {
let classes = {};

let bsClass = this.props.bsClass && constants.CLASSES[this.props.bsClass];
let bsClass = this.props.bsClass && styleMaps.CLASSES[this.props.bsClass];
if (bsClass) {
classes[bsClass] = true;

let prefix = bsClass + '-';

let bsSize = this.props.bsSize && constants.SIZES[this.props.bsSize];
let bsSize = this.props.bsSize && styleMaps.SIZES[this.props.bsSize];
if (bsSize) {
classes[prefix + bsSize] = true;
}

let bsStyle = this.props.bsStyle && constants.STYLES[this.props.bsStyle];
let bsStyle = this.props.bsStyle && styleMaps.STYLES[this.props.bsStyle];
if (this.props.bsStyle) {
classes[prefix + bsStyle] = true;
}
Expand All @@ -33,7 +33,7 @@ const BootstrapMixin = {
},

prefixClass(subClass) {
return constants.CLASSES[this.props.bsClass] + '-' + subClass;
return styleMaps.CLASSES[this.props.bsClass] + '-' + subClass;
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/Col.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import classNames from 'classnames';
import constants from './constants';
import styleMaps from './styleMaps';

const Col = React.createClass({
propTypes: {
Expand Down Expand Up @@ -33,8 +33,8 @@ const Col = React.createClass({
let ComponentClass = this.props.componentClass;
let classes = {};

Object.keys(constants.SIZES).forEach(function (key) {
let size = constants.SIZES[key];
Object.keys(styleMaps.SIZES).forEach(function (key) {
let size = styleMaps.SIZES[key];
let prop = size;
let classPart = size + '-';

Expand Down
4 changes: 2 additions & 2 deletions src/Glyphicon.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react';
import classNames from 'classnames';
import BootstrapMixin from './BootstrapMixin';
import constants from './constants';
import styleMaps from './styleMaps';

const Glyphicon = React.createClass({
mixins: [BootstrapMixin],

propTypes: {
glyph: React.PropTypes.oneOf(constants.GLYPHS).isRequired
glyph: React.PropTypes.oneOf(styleMaps.GLYPHS).isRequired
},

getDefaultProps() {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import Table from './Table';
import TabPane from './TabPane';
import Tooltip from './Tooltip';
import Well from './Well';
import constants from './constants';
import styleMaps from './styleMaps';

export default {
Accordion,
Expand Down Expand Up @@ -99,5 +99,5 @@ export default {
TabPane,
Tooltip,
Well,
constants
styleMaps
};
6 changes: 3 additions & 3 deletions src/constants.js → src/styleMaps.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const constants = {
const styleMaps = {
CLASSES: {
'alert': 'alert',
'button': 'btn',
Expand Down Expand Up @@ -32,7 +32,7 @@ const constants = {
'pills': 'pills'
},
addStyle: function(name) {
constants.STYLES[name] = name;
styleMaps.STYLES[name] = name;
},
SIZES: {
'large': 'lg',
Expand Down Expand Up @@ -303,4 +303,4 @@ const constants = {
]
};

export default constants;
export default styleMaps;
4 changes: 2 additions & 2 deletions test/BootstrapMixinSpec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactTestUtils from 'react/lib/ReactTestUtils';
import BootstrapMixin from '../src/BootstrapMixin';
import constants from '../src/constants';
import styleMaps from '../src/styleMaps';

let Component;

Expand Down Expand Up @@ -198,7 +198,7 @@ describe('BootstrapMixin', function () {
});

it('should return "btn btn-wacky"', function () {
constants.addStyle('wacky');
styleMaps.addStyle('wacky');
let instance = ReactTestUtils.renderIntoDocument(
<Component bsClass='button' bsStyle='wacky'>
content
Expand Down

0 comments on commit a4168be

Please sign in to comment.