66 ButtonProps as BlueprintButtonProps ,
77 Intent as BlueprintIntent ,
88} from "@blueprintjs/core" ;
9+ import { IntentTypes } from "common/Intent" ;
910
1011import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
1112import { ValidIconName } from "../Icon/canonicalIconNames" ;
@@ -15,6 +16,10 @@ import Badge, { BadgeProps } from "./../Badge/Badge";
1516import Tooltip , { TooltipProps } from "./../Tooltip/Tooltip" ;
1617
1718interface AdditionalButtonProps {
19+ /**
20+ * Intent state of the button.
21+ */
22+ intent ?: IntentTypes ;
1823 /**
1924 * Always use this when the button triggers an affirmative action, e.g. confirm a process.
2025 * The button is displayed with primary color scheme.
@@ -23,27 +28,33 @@ interface AdditionalButtonProps {
2328 /**
2429 * Always use this when the button triggers an disruptive action, e.g. delete or remove.
2530 * The button is displayed with primary color scheme.
31+ * @deprecated use `intent` instead.
2632 */
2733 disruptive ?: boolean ;
2834 /**
2935 * Use this when a button is important enough to highlight it in a set of other buttons.
3036 * The button is displayed with primary color scheme.
37+ * @deprecated use `intent` instead.
3138 */
3239 elevated ?: boolean ;
3340 /**
3441 * The button is displayed with primary color scheme.
42+ * @deprecated use `intent` instead.
3543 */
3644 hasStatePrimary ?: boolean ;
3745 /**
3846 * The button is displayed with success (some type of green) color scheme.
47+ * @deprecated use `intent` instead.
3948 */
4049 hasStateSuccess ?: boolean ;
4150 /**
4251 * The button is displayed with warning (some type of orange) color scheme.
52+ * @deprecated use `intent` instead.
4353 */
4454 hasStateWarning ?: boolean ;
4555 /**
4656 * The button is displayed with danger (some type of red) color scheme.
57+ * @deprecated use `intent` instead.
4758 */
4859 hasStateDanger ?: boolean ;
4960 /**
@@ -73,10 +84,12 @@ interface AdditionalButtonProps {
7384 //target?: string;
7485}
7586
76- interface ExtendedButtonProps extends AdditionalButtonProps , Omit < BlueprintButtonProps , "icon" | "rightIcon" > { }
87+ interface ExtendedButtonProps
88+ extends AdditionalButtonProps ,
89+ Omit < BlueprintButtonProps , "icon" | "rightIcon" | "intent" > { }
7790interface ExtendedAnchorButtonProps
7891 extends AdditionalButtonProps ,
79- Omit < BlueprintAnchorButtonProps , "icon" | "rightIcon" > { }
92+ Omit < BlueprintAnchorButtonProps , "icon" | "rightIcon" | "intent" > { }
8093
8194export type ButtonProps = ExtendedButtonProps & ExtendedAnchorButtonProps ;
8295
@@ -100,6 +113,7 @@ export const Button = ({
100113 tooltipProps,
101114 badge,
102115 badgeProps = { size : "small" , position : "top-right" , maxLength : 2 } ,
116+ intent,
103117 ...restProps
104118} : ButtonProps ) => {
105119 let intention ;
@@ -120,13 +134,13 @@ export const Button = ({
120134 break ;
121135 }
122136
123- const ButtonType : any = restProps . href ? BlueprintAnchorButton : BlueprintButton ;
137+ const ButtonType = restProps . href ? BlueprintAnchorButton : BlueprintButton ;
124138
125139 const button = (
126140 < ButtonType
127141 { ...restProps }
128142 className = { `${ eccgui } -button ` + className }
129- intent = { intention }
143+ intent = { ( intent || intention ) as BlueprintIntent }
130144 icon = { typeof icon === "string" ? < Icon name = { icon } /> : icon }
131145 rightIcon = { typeof rightIcon === "string" ? < Icon name = { rightIcon } /> : rightIcon }
132146 >
0 commit comments