All files / src/components/FontIcon FontIcon.react.js

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                                          1x                         2x                                 1x  
// @flow
 
import React from 'react';
 
import MUIFontIcon from 'material-ui/FontIcon';
import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme';
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider';
import getMuiTheme from 'material-ui/styles/getMuiTheme';
 
type Props = {
  /** id for the component */
  id?: string,
  /** font color of the font icon;
   * If not specified, this component will default
   * to muiTheme.palette.textColor
   * */
  color?: string,
  /** defines specific icon when using custom icon font
   * or defines font when using public icon font
   */
  className?: string,
  /** icon color when the mouse hovers over the icon */
  hoverColor?: string,
  /** defines specific icon when using public icon font */
  iconName?: string,
  /** override inline-styles of root element */
  style?: Object,
};
 
const defaultProps = {
  id: '',
  color: '',
  className: '',
  hoverColor: '',
  iconName: '',
  style: {},
};
 
export default class FontIcon extends React.Component<Props> {
  props: Props;
 
  render() {
    return (
      <div id={this.props.id}>
        <MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}>
          <MUIFontIcon
            color={this.props.color}
            className={this.props.className}
            hoverColor={this.props.hoverColor}
            style={this.props.style}
          >
            {this.props.iconName}
          </MUIFontIcon>
        </MuiThemeProvider>
      </div>
    );
  }
}
 
FontIcon.defaultProps = defaultProps;