@@ -27,38 +27,25 @@ export const ButtonTypeOptions = [
27
27
} ,
28
28
] as const ;
29
29
30
- export const ButtonDisplayOptions = [
31
- {
32
- label : trans ( "table.text" ) ,
33
- value : "text" ,
34
- } ,
35
- {
36
- label : trans ( "table.icon" ) ,
37
- value : "icon" ,
38
- } ,
39
- {
40
- label : trans ( "table.textAndIcon" ) ,
41
- value : "textAndIcon" ,
42
- } ,
43
- ] as const ;
44
-
45
30
export const ButtonComp = ( function ( ) {
46
31
const childrenMap = {
47
32
text : StringControl ,
48
33
buttonType : dropdownControl ( ButtonTypeOptions , "primary" ) ,
49
34
onClick : ActionSelectorControlInContext ,
50
35
loading : BoolCodeControl ,
51
36
disabled : BoolCodeControl ,
52
- displayMode : dropdownControl ( ButtonDisplayOptions , "text" ) ,
53
- icon : IconControl ,
37
+ prefixIcon : IconControl ,
38
+ suffixIcon : IconControl ,
54
39
} ;
55
40
return new ColumnTypeCompBuilder (
56
41
childrenMap ,
57
42
( props ) => {
58
43
const ButtonStyled = ( ) => {
59
44
const style = useStyle ( ButtonStyle ) ;
60
- const showIcon = props . displayMode === "icon" || props . displayMode === "textAndIcon" ;
61
- const showText = props . displayMode === "text" || props . displayMode === "textAndIcon" ;
45
+ const hasText = ! ! props . text ;
46
+ const hasPrefixIcon = hasIcon ( props . prefixIcon ) ;
47
+ const hasSuffixIcon = hasIcon ( props . suffixIcon ) ;
48
+ const iconOnly = ! hasText && ( hasPrefixIcon || hasSuffixIcon ) ;
62
49
63
50
return (
64
51
< Button100
@@ -67,11 +54,16 @@ export const ButtonComp = (function () {
67
54
loading = { props . loading }
68
55
disabled = { props . disabled }
69
56
$buttonStyle = { props . buttonType === "primary" ? style : undefined }
70
- style = { { margin : 0 } }
71
- icon = { showIcon && hasIcon ( props . icon ) ? props . icon : undefined }
57
+ style = { {
58
+ margin : 0 ,
59
+ width : iconOnly ? 'auto' : undefined ,
60
+ minWidth : iconOnly ? 'auto' : undefined ,
61
+ padding : iconOnly ? '0 8px' : undefined
62
+ } }
63
+ icon = { hasPrefixIcon ? props . prefixIcon : undefined }
72
64
>
73
- { /* prevent the button from disappearing */ }
74
- { showText ? ( ! props . text ? " " : props . text ) : null }
65
+ { hasText ? props . text : ( iconOnly ? null : " " ) }
66
+ { hasSuffixIcon && ! props . loading && < span style = { { marginLeft : hasText ? '8px' : 0 } } > { props . suffixIcon } </ span > }
75
67
</ Button100 >
76
68
) ;
77
69
} ;
@@ -81,21 +73,16 @@ export const ButtonComp = (function () {
81
73
)
82
74
. setPropertyViewFn ( ( children ) => (
83
75
< >
84
- { children . displayMode . propertyView ( {
85
- label : trans ( "table.displayMode" ) ,
86
- radioButton : true ,
76
+ { children . text . propertyView ( {
77
+ label : trans ( "table.columnValue" ) ,
78
+ tooltip : ColumnValueTooltip ,
79
+ } ) }
80
+ { children . prefixIcon . propertyView ( {
81
+ label : trans ( "button.prefixIcon" ) ,
82
+ } ) }
83
+ { children . suffixIcon . propertyView ( {
84
+ label : trans ( "button.suffixIcon" ) ,
87
85
} ) }
88
- { ( children . displayMode . getView ( ) === "text" || children . displayMode . getView ( ) === "textAndIcon" ) &&
89
- children . text . propertyView ( {
90
- label : trans ( "table.columnValue" ) ,
91
- tooltip : ColumnValueTooltip ,
92
- } )
93
- }
94
- { ( children . displayMode . getView ( ) === "icon" || children . displayMode . getView ( ) === "textAndIcon" ) &&
95
- children . icon . propertyView ( {
96
- label : trans ( "table.icon" ) ,
97
- } )
98
- }
99
86
{ children . buttonType . propertyView ( {
100
87
label : trans ( "table.type" ) ,
101
88
radioButton : true ,
0 commit comments