Skip to content

Commit

Permalink
Added getDefaultProps, fixed getTheme method, changed color property …
Browse files Browse the repository at this point in the history
…to labelColor.
  • Loading branch information
Nick Baroni committed Nov 3, 2015
1 parent 37cbc1d commit cfd972d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/src/app/components/pages/components/badge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default class BadgePage extends React.Component {
desc: 'Override the badge\'s background color.',
},
{
name: 'color',
name: 'labelColor',
type: 'string',
header: 'optional',
desc: 'Override the badge\'s text color.',
Expand Down
20 changes: 14 additions & 6 deletions src/badge.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default React.createClass({
primary: React.PropTypes.bool,
secondary: React.PropTypes.bool,
primaryText: React.PropTypes.string.isRequired,
color: React.PropTypes.string,
labelColor: React.PropTypes.string,
backgroundColor: React.PropTypes.string,
style: React.PropTypes.object,
},
Expand All @@ -32,17 +32,25 @@ export default React.createClass({
muiTheme: this.context.muiTheme ? this.context.muiTheme : ThemeManager.getMuiTheme(DefaultRawTheme),
};
},
getDefaultProps() {
return {
className: '',
primary: false,
secondary: false,
primaryText: '',
labelColor: null,
backgroundColor: null,
style: null
};
}
componentWillReceiveProps(nextProps, nextContext) {
let newMuiTheme = nextContext.muiTheme ? nextContext.muiTheme : this.state.muiTheme;
this.setState({
muiTheme: newMuiTheme,
});
},
getThemeBadge() {
return this.state.muiTheme.badge;
},
getTheme() {
return this.state.muiTheme.raisedButton;
return this.state.muiTheme.badge;
},
getStyles() {
const backgroundColor = this.props.backgroundColor
Expand Down Expand Up @@ -102,7 +110,7 @@ export default React.createClass({
render() {
const style = this.getStyles();
return (
<div style={style.root}>
<div style={style.root} className={this.props.className}>
{this.props.children}
<span style={style.badge}>{this.props.primaryText}</span>
</div>
Expand Down

0 comments on commit cfd972d

Please sign in to comment.