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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | 1x 7x 7x 3x 3x 3x 7x 7x 7x 1x | // @flow import React from 'react'; import MuiIconButton from 'material-ui/IconButton'; import lightBaseTheme from 'material-ui/styles/baseThemes/lightBaseTheme'; import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'; import getMuiTheme from 'material-ui/styles/getMuiTheme'; type Props = { /** Used to pass a FontIcon element as the icon for the button * See method 3 at http://www.material-ui.com/#/components/icon-button * Note: currently unable to pass in FontIcon component as child, you will need * to use method 3 at the above link */ children?: Node, /** The CSS class name of the root element */ className?: string, /** If true, the element's ripple effect will be disabled */ disableTouchRipple?: boolean, /** Disable the button? */ disabled?: boolean, /** Dash callback to trigger an event handler */ fireEvent?: () => void, /** Override the inline-styles of the root element when the component is hovered */ hoveredStyle?: Object, /** The URL to link to when the button is clicked */ href?: string, /** The CSS class name of the icon. Used for setting the icon with a stylesheet */ iconClassName?: string, /** Override the inline-styles of the icon element. * Note: you can specify iconHoverColor as a String inside this object. */ iconStyle?: Object, /** Element ID */ id?: string, /** An integer that represents the number fo times that this element has been clicked */ n_clicks?: number, /** An integer that represents the previous number of times this element has been clicked */ n_clicks_previous?: number, /** Dash callback to update props */ setProps?: () => void, /** Override the inline-styles of the root element. */ style?: Object, /** The text to supply to the element's tooltip */ tooltip?: Node, /** The vertical and horizontal positions, respectively, of the element's tooltip. * Possible values are: "bottom-center", "top-center", "bottom-right", "top-right", * "bottom-left", and "top-left". */ tooltipPosition?: propTypes.cornersAndCenter, /** Override the inline-styles of the tooltip element */ tooltipStyles?: Object, /** If true, increase the tooltip element's size. * Useful for increasing tooltip readability on mobile devices. */ touch?: boolean, }; const defaultProps = { children: null, className: '', disableTouchRipple: false, disabled: false, fireEvent: () => {}, hoveredStyle: {}, href: '', iconClassName: 'material-icons', iconStyle: {}, n_clicks: 0, n_clicks_previous: 0, setProps: () => {}, style: {}, tooltip: '', tooltipPosition: 'bottom-center', tooltipStyles: {}, touch: false, }; export default class IconButton extends React.Component<Props> { constructor(props: Props) { super(props); this.handleClick = this.handleClick.bind(this); } handleClick() { Eif (this.props.setProps) this.props.setProps({n_clicks: this.props.n_clicks + 1}); Eif (this.props.fireEvent) this.props.fireEvent({event: 'click'}); Eif (this.props.setProps) this.props.setProps({n_clicks_previous: this.props.n_clicks + 1}); } render() { const {className, disableTouchRipple, disabled, hoveredStyle, href, iconClassName, iconStyle, id, style, tooltip, tooltipPosition, tooltipStyles, touch} = this.props; Eif (this.props.fireEvent || this.props.setProps) { return ( <div id={id}> <MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}> <MuiIconButton className={className} disableTouchRipple={disableTouchRipple} disabled={disabled} hoveredStyle={hoveredStyle} href={href} iconClassName={iconClassName} iconStyle={iconStyle} onClick={this.handleClick} style={style} tooltip={tooltip} tooltipPosition={tooltipPosition} tooltipStyles={tooltipStyles} touch={touch} > {this.props.children} </MuiIconButton> </MuiThemeProvider> </div>); } return ( <div id={id}> <MuiThemeProvider muiTheme={getMuiTheme(lightBaseTheme)}> <MuiIconButton className={className} disableTouchRipple={disableTouchRipple} disabled={disabled} hoveredStyle={hoveredStyle} href={href} iconClassName={iconClassName} iconStyle={iconStyle} style={style} tooltip={tooltip} tooltipPosition={tooltipPosition} tooltipStyles={tooltipStyles} touch={touch} > {this.props.children} </MuiIconButton> </MuiThemeProvider> </div>); } } IconButton.defaultProps = defaultProps; |