From cfd972ddc334be22bcaf176d76d6d7949840f296 Mon Sep 17 00:00:00 2001 From: Nick Baroni Date: Wed, 4 Nov 2015 08:54:23 +0900 Subject: [PATCH] Added getDefaultProps, fixed getTheme method, changed color property to labelColor. --- .../app/components/pages/components/badge.jsx | 2 +- src/badge.jsx | 20 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/docs/src/app/components/pages/components/badge.jsx b/docs/src/app/components/pages/components/badge.jsx index 5fa4d6d95cabc5..415fb8e8fa8f54 100644 --- a/docs/src/app/components/pages/components/badge.jsx +++ b/docs/src/app/components/pages/components/badge.jsx @@ -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.', diff --git a/src/badge.jsx b/src/badge.jsx index 77a68c83f63a23..043564ff2cfadc 100644 --- a/src/badge.jsx +++ b/src/badge.jsx @@ -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, }, @@ -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 @@ -102,7 +110,7 @@ export default React.createClass({ render() { const style = this.getStyles(); return ( -
+
{this.props.children} {this.props.primaryText}