MCPcopy Create free account
hub / github.com/parse-community/parse-dashboard / Button

Function Button

src/components/Button/Button.react.js:15–64  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13const noop = () => {};
14
15const Button = props => {
16 const hasOnClick = props.onClick && !props.disabled;
17 const classes = [styles.button, baseStyles.unselectable];
18 // if a button is disabled, that overrides any color selection
19 if (props.disabled) {
20 classes.push(styles.disabled);
21 if (props.color === 'white') {
22 // This has a special disabled case
23 classes.push(styles.white);
24 }
25 } else {
26 if (props.primary) {
27 classes.push(styles.primary);
28 }
29 if (props.color) {
30 classes.push(styles[props.color]);
31 }
32 if (props.progress) {
33 classes.push(styles.progress);
34 }
35 }
36 const clickHandler = hasOnClick ? props.onClick : noop;
37 let styleOverride = null;
38 if (props.width) {
39 styleOverride = {
40 width: props.width,
41 minWidth: props.width,
42 ...props.additionalStyles,
43 };
44 }
45 return (
46 <button
47 type="button"
48 style={styleOverride}
49 className={classes.join(' ')}
50 onClick={clickHandler}
51 onFocus={e => {
52 if (props.disabled) {
53 e.target.blur();
54 }
55 }}
56 onMouseLeave={e => {
57 // Remove focus when mouse leaves to prevent sticky focus states
58 e.target.blur();
59 }}
60 >
61 <span>{props.value}</span>
62 </button>
63 );
64};
65
66export default Button;
67

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected