-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathButton.tsx
More file actions
80 lines (77 loc) · 2.78 KB
/
Copy pathButton.tsx
File metadata and controls
80 lines (77 loc) · 2.78 KB
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
import React from "react";
import Button from "../../components/Button/Button";
export const iconMappings: { [key: string]: any } = {
edit: "item-edit",
delete: "item-remove",
expand_more: "toggler-showmore",
expand_less: "toggler-showless",
arrow_nextpage: "navigation-forth",
arrow_back: "navigation-back",
};
/** @deprecated (v25) all legacy component support will be removed, switch to `<Button />` */
export function ButtonReplacement({
children,
className,
fabSize,
iconName,
tooltip,
progress,
disabled = false,
affirmative = false,
dismissive = true,
disruptive = false,
raised = false,
colored = false,
...otherProps
}: any) {
if (process.env.NODE_ENV === "development") {
const debugMsg = [
"This button element is a adhoc replacement for a legacy element. Usage is deprecated, please use a standard element (Button).",
];
if (typeof otherProps.accent !== "undefined") {
debugMsg.push("Button 'accent' property is not supported on legacy replacement element.");
delete otherProps.accent;
}
if (typeof otherProps.badge !== "undefined") {
debugMsg.push("Button 'badge' property is not supported on legacy replacement element.");
delete otherProps.badge;
}
if (typeof otherProps.ripple !== "undefined") {
debugMsg.push("Button 'ripple' property is not supported on legacy replacement element.");
delete otherProps.ripple;
}
if (typeof progress !== "undefined") {
debugMsg.push(
"Button 'progress' property is not fully supported on legacy replacement element, it only shows a loading spinner in the button."
);
}
// eslint-disable-next-line no-console
debugMsg.forEach((element) => console.debug(element));
}
if (typeof otherProps.accent !== "undefined") {
delete otherProps.accent;
}
if (typeof otherProps.badge !== "undefined") {
delete otherProps.badge;
}
if (typeof otherProps.ripple !== "undefined") {
delete otherProps.ripple;
}
return (
<Button
{...otherProps}
className={className}
minimal={!!iconName && raised === false ? true : false}
icon={iconName ? (iconName && iconMappings[iconName] ? iconMappings[iconName] : iconName) : undefined}
tooltip={tooltip ? tooltip : false}
disabled={disabled}
affirmative={affirmative}
disruptive={disruptive}
hasStatePrimary={!!fabSize || colored || !dismissive}
large={!!fabSize && fabSize !== "mini"}
loading={progress ? true : false}
>
{children}
</Button>
);
}