@@ -67,6 +67,7 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
6767 ...focusRing ( ) ,
6868 ...staticColor ( ) ,
6969 ...controlStyle ,
70+ display : 'grid' ,
7071 justifyContent : 'center' ,
7172 flexShrink : {
7273 default : 1 ,
@@ -79,9 +80,21 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
7980 isJustified : 0
8081 } ,
8182 fontWeight : 'medium' ,
83+ width : 'fit' ,
8284 userSelect : 'none' ,
8385 transition : 'default' ,
8486 forcedColorAdjust : 'none' ,
87+ position : 'relative' ,
88+ gridTemplateAreas : {
89+ default : [ 'icon text' ] ,
90+ [ iconOnly ] : [ 'icon' ] ,
91+ [ textOnly ] : [ 'text' ]
92+ } ,
93+ gridTemplateColumns : {
94+ default : [ 'auto' , 'auto' ] ,
95+ [ iconOnly ] : [ 'auto' ] ,
96+ [ textOnly ] : [ 'auto' ]
97+ } ,
8598 backgroundColor : {
8699 default : {
87100 ...baseColor ( 'gray-100' ) ,
@@ -223,8 +236,7 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
223236 '--badgePosition' : {
224237 type : 'width' ,
225238 value : {
226- default : 'calc(self(paddingStart) + var(--iconWidth))' ,
227- [ iconOnly ] : 'calc(self(minWidth)/2 + var(--iconWidth)/2)' ,
239+ default : '--iconWidth' ,
228240 [ textOnly ] : 'full'
229241 }
230242 } ,
@@ -289,10 +301,10 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
289301 < Provider
290302 values = { [
291303 [ SkeletonContext , null ] ,
292- [ TextContext , { styles : style ( { order : 1 , truncate : true } ) } ] ,
304+ [ TextContext , { styles : style ( { truncate : true , gridArea : 'text' } ) } ] ,
293305 [ IconContext , {
294- render : centerBaseline ( { slot : 'icon' , styles : style ( { order : 0 } ) } ) ,
295- styles : style ( { size : fontRelative ( 20 ) , marginStart : '--iconMargin' , flexShrink : 0 } )
306+ render : centerBaseline ( { slot : 'icon' , styles : style ( { gridArea : 'icon' } ) } ) ,
307+ styles : style ( { size : fontRelative ( 20 ) , marginStart : '--iconMargin' } )
296308 } ] ,
297309 [ AvatarContext , {
298310 size : avatarSize [ size ] ,
@@ -301,15 +313,14 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
301313 default : '--iconMargin' ,
302314 ':last-child' : 0
303315 } ,
304- flexShrink : 0 ,
305- order : 0
316+ gridArea : 'icon'
306317 } )
307318 } ] ,
308319 [ NotificationBadgeContext , {
309320 staticColor : staticColor ,
310321 size : props . size === 'XS' ? undefined : props . size ,
311322 isDisabled : props . isDisabled ,
312- styles : style ( { position : 'absolute' , top : '--badgeTop' , insetStart : '--badgePosition' , marginTop : 'calc((self(height) * -1)/2)' , marginStart : 'calc(( self(height) * -1)/2) ' } )
323+ styles : style ( { position : 'absolute' , top : '--badgeTop' , marginTop : 'calc((self(height) * -1)/2)' , marginStart : 'calc(var(--iconMargin) * 2 + ( self(height) * -1)/4)' , gridColumnStart : 1 , insetStart : '--badgePosition '} )
313324 } ]
314325 ] } >
315326 { typeof props . children === 'string' ? < Text > { props . children } </ Text > : props . children }
0 commit comments