@@ -24,27 +24,11 @@ import {
2424 EuiButtonContentType ,
2525} from '../_button_content_deprecated' ;
2626
27- import { validateHref } from '../../../services/security/href_validator' ;
28- import { useEuiButtonColorCSS } from '../../../themes/amsterdam/global_styling/mixins/button' ;
29-
30- export type EuiButtonEmptyColor =
31- | 'primary'
32- | 'danger'
33- | 'text'
34- | 'ghost'
35- | 'success'
36- | 'warning' ;
37-
38- const colorToClassNameMap : { [ color in EuiButtonEmptyColor ] : string } = {
39- primary : 'euiButtonEmpty--primary' ,
40- danger : 'euiButtonEmpty--danger' ,
41- text : 'euiButtonEmpty--text' ,
42- ghost : 'euiButtonEmpty--ghost' ,
43- success : 'euiButtonEmpty--success' ,
44- warning : 'euiButtonEmpty--warning' ,
45- } ;
46-
47- export const COLORS = keysOf ( colorToClassNameMap ) ;
27+ import {
28+ useEuiButtonColorCSS ,
29+ _EuiButtonColor ,
30+ } from '../../../themes/amsterdam/global_styling/mixins/button' ;
31+ import { isButtonDisabled } from '../button_display/_button_display' ;
4832
4933const sizeToClassNameMap = {
5034 xs : 'euiButtonEmpty--xSmall' ,
@@ -74,7 +58,7 @@ export interface CommonEuiButtonEmptyProps
7458 /**
7559 * Any of our named colors
7660 */
77- color ?: EuiButtonEmptyColor ;
61+ color ?: _EuiButtonColor | 'ghost' ;
7862 size ?: EuiButtonEmptySizes ;
7963 /**
8064 * Ensure the text of the button sits flush to the left, right, or both sides of its container
@@ -123,7 +107,7 @@ export const EuiButtonEmpty: FunctionComponent<EuiButtonEmptyProps> = ({
123107 size = 'm' ,
124108 flush,
125109 isDisabled : _isDisabled ,
126- disabled : _disabled ,
110+ disabled,
127111 isLoading,
128112 href,
129113 target,
@@ -135,31 +119,22 @@ export const EuiButtonEmpty: FunctionComponent<EuiButtonEmptyProps> = ({
135119 isSelected,
136120 ...rest
137121} ) => {
138- const isHrefValid = ! href || validateHref ( href ) ;
139- const disabled = _disabled || ! isHrefValid ;
140- const isDisabled = _isDisabled || ! isHrefValid ;
141-
142- // If in the loading state, force disabled to true
143- const buttonIsDisabled = isLoading || isDisabled || disabled ;
122+ const isDisabled = isButtonDisabled ( {
123+ isDisabled : _isDisabled || disabled ,
124+ href,
125+ isLoading,
126+ } ) ;
144127
145128 // eslint-disable-next-line no-nested-ternary
146- const color = buttonIsDisabled
147- ? 'disabled'
148- : _color === 'ghost'
149- ? 'text'
150- : _color ;
129+ const color = isDisabled ? 'disabled' : _color === 'ghost' ? 'text' : _color ;
151130 const buttonColorStyles = useEuiButtonColorCSS ( {
152131 display : 'empty' ,
153132 } ) [ color ] ;
154133
155134 const classes = classNames (
156135 'euiButtonEmpty' ,
157- // colorToClassNameMap[color],
158136 size ? sizeToClassNameMap [ size ] : null ,
159137 flush ? flushTypeToClassNameMap [ flush ] : null ,
160- {
161- // 'euiButtonEmpty-isDisabled': buttonIsDisabled,
162- } ,
163138 className
164139 ) ;
165140
@@ -192,7 +167,7 @@ export const EuiButtonEmpty: FunctionComponent<EuiButtonEmptyProps> = ({
192167
193168 // <a> elements don't respect the `disabled` attribute. So if we're disabled, we'll just pretend
194169 // this is a button and piggyback off its disabled styles.
195- if ( href && ! buttonIsDisabled ) {
170+ if ( href && ! isDisabled ) {
196171 const secureRel = getSecureRelForTarget ( { href, target, rel } ) ;
197172
198173 return (
@@ -212,7 +187,7 @@ export const EuiButtonEmpty: FunctionComponent<EuiButtonEmptyProps> = ({
212187
213188 return (
214189 < button
215- disabled = { buttonIsDisabled }
190+ disabled = { isDisabled }
216191 className = { classes }
217192 css = { cssStyles }
218193 type = { type }
0 commit comments