From fecd6870f0961e7e8296be88d4a352dcbfbbf2cb Mon Sep 17 00:00:00 2001
From: Zadielerick
Date: Thu, 2 Jul 2015 11:14:34 -0500
Subject: [PATCH] Added support for font-icon to be able to use Google material
Icons
---
.../pages/components/icon-buttons.jsx | 13 ++++++++++---
src/icon-button.jsx | 17 ++++-------------
src/utils/children.js | 17 +++++++++--------
3 files changed, 23 insertions(+), 24 deletions(-)
diff --git a/docs/src/app/components/pages/components/icon-buttons.jsx b/docs/src/app/components/pages/components/icon-buttons.jsx
index bf276bf448a9e5..c984a091e3ef05 100644
--- a/docs/src/app/components/pages/components/icon-buttons.jsx
+++ b/docs/src/app/components/pages/components/icon-buttons.jsx
@@ -21,9 +21,9 @@ class IconButtonsPage extends React.Component {
'\n' +
' \n' +
'\n\n' +
- '//Adding tooltipPosition to Icon Button\n' +
- '\n';
+ '//Method 4: Using Google material-icons\n' +
+ ' settings_system_daydream';
let desc = (
@@ -50,6 +50,10 @@ class IconButtonsPage extends React.Component {
similiar to how the iconClassName prop from method 1 is
handled.
+
+ Google Material Icons: Now also supported for iconButtons by passing "material-icons" in
+ iconClassName prop.
+
);
@@ -168,6 +172,9 @@ class IconButtonsPage extends React.Component {
+
+
+ settings_system_daydream
);
diff --git a/src/icon-button.jsx b/src/icon-button.jsx
index 3eadd10a7b411a..46fa55862f7c6e 100644
--- a/src/icon-button.jsx
+++ b/src/icon-button.jsx
@@ -49,17 +49,6 @@ let IconButton = React.createClass({
};
},
- componentDidMount() {
- if (process.env.NODE_ENV !== 'production') {
- if (this.props.iconClassName && this.props.children) {
- let warning = 'You have set both an iconClassName and a child icon. ' +
- 'It is recommended you use only one method when adding ' +
- 'icons to IconButtons.';
- console.warn(warning);
- }
- }
- },
-
getStyles() {
let spacing = this.context.muiTheme.spacing;
let palette = this.context.muiTheme.palette;
@@ -71,7 +60,8 @@ let IconButton = React.createClass({
transition: Transitions.easeOut(),
padding: spacing.iconSize / 2,
width: spacing.iconSize*2,
- height: spacing.iconSize*2
+ height: spacing.iconSize*2,
+ fontSize: 0
},
tooltip: {
boxSizing: 'border-box',
@@ -133,7 +123,8 @@ let IconButton = React.createClass({
styles.icon,
disabled ? styles.disabled : {},
iconStyleFontIcon
- )}/>
+ )}>
+ {this.props.children}
);
}
diff --git a/src/utils/children.js b/src/utils/children.js
index bc82e3cc7ed072..2b644053c64944 100644
--- a/src/utils/children.js
+++ b/src/utils/children.js
@@ -4,17 +4,18 @@ module.exports = {
extend(children, extendedProps, extendedChildren) {
- return React.Children.map(children, (child) => {
+ return React.isValidElement(children) ?
+ React.Children.map(children, (child) => {
- let newProps = typeof(extendedProps) === 'function' ?
- extendedProps(child) : extendedProps;
+ let newProps = typeof(extendedProps) === 'function' ?
+ extendedProps(child) : extendedProps;
- let newChildren = typeof(extendedChildren) === 'function' ?
- extendedChildren(child) : extendedChildren ?
- extendedChildren : child.props.children;
+ let newChildren = typeof(extendedChildren) === 'function' ?
+ extendedChildren(child) : extendedChildren ?
+ extendedChildren : child.props.children;
- return React.cloneElement(child, newProps, newChildren);
- });
+ return React.cloneElement(child, newProps, newChildren);
+ }) : children;
}
};