MCPcopy Index your code
hub / github.com/react-toolbox/react-toolbox / IconButton

Class IconButton

components/button/IconButton.js:9–74  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7
8const factory = (ripple, FontIcon) => {
9 class IconButton extends Component {
10 static propTypes = {
11 accent: PropTypes.bool,
12 children: PropTypes.node,
13 className: PropTypes.string,
14 disabled: PropTypes.bool,
15 href: PropTypes.string,
16 icon: PropTypes.oneOfType([
17 PropTypes.string,
18 PropTypes.element
19 ]),
20 inverse: PropTypes.bool,
21 neutral: PropTypes.bool,
22 onMouseLeave: PropTypes.func,
23 onMouseUp: PropTypes.func,
24 primary: PropTypes.bool,
25 theme: PropTypes.object,
26 type: PropTypes.string
27 };
28
29 static defaultProps = {
30 accent: false,
31 className: '',
32 neutral: true,
33 primary: false,
34 type: 'button'
35 };
36
37 handleMouseUp = (event) => {
38 this.refs.button.blur();
39 if (this.props.onMouseUp) this.props.onMouseUp(event);
40 };
41
42 handleMouseLeave = (event) => {
43 this.refs.button.blur();
44 if (this.props.onMouseLeave) this.props.onMouseLeave(event);
45 };
46
47 render () {
48 const {accent, children, className, href, icon, inverse, neutral,
49 primary, theme, type, ...others} = this.props;
50 const element = href ? 'a' : 'button';
51 const level = primary ? 'primary' : accent ? 'accent' : 'neutral';
52 const classes = classnames([theme.toggle], {
53 [theme[level]]: neutral,
54 [theme.inverse]: inverse
55 }, className);
56
57 const props = {
58 ...others,
59 href,
60 ref: 'button',
61 className: classes,
62 disabled: this.props.disabled,
63 onMouseUp: this.handleMouseUp,
64 onMouseLeave: this.handleMouseLeave,
65 type: !href ? type : null,
66 'data-react-toolbox': 'button'

Callers

nothing calls this directly

Calls 1

blurMethod · 0.45

Tested by

no test coverage detected