@@ -64,13 +64,14 @@ export interface LinkButtonProps extends Omit<LinkProps, 'className' | 'style' |
6464export const ButtonContext = createContext < ContextValue < ButtonProps , FocusableRefValue < HTMLButtonElement > > > ( null ) ;
6565export const LinkButtonContext = createContext < ContextValue < ButtonProps , FocusableRefValue < HTMLAnchorElement > > > ( null ) ;
6666
67+ const iconOnly = ':has([slot=icon]):not(:has([data-rsp-slot=text]))' ;
6768const button = style < ButtonRenderProps & ButtonStyleProps > ( {
6869 ...focusRing ( ) ,
6970 position : 'relative' ,
7071 display : 'flex' ,
7172 alignItems : {
7273 default : 'baseline' ,
73- ':has([slot=icon]):not(:has([data-rsp-slot=text]))' : 'center'
74+ [ iconOnly ] : 'center'
7475 } ,
7576 justifyContent : 'center' ,
7677 textAlign : 'start' ,
@@ -80,19 +81,19 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
8081 userSelect : 'none' ,
8182 minHeight : 'control' ,
8283 minWidth : {
83- ':has([slot=icon]):not(:has([data-rsp-slot=text]))' : 'control'
84+ [ iconOnly ] : 'control'
8485 } ,
8586 borderRadius : 'pill' ,
8687 boxSizing : 'border-box' ,
8788 width : 'fit' ,
8889 textDecoration : 'none' , // for link buttons
8990 paddingX : {
9091 default : 'pill' ,
91- ':has([slot=icon]):not(:has([data-rsp-slot=text]))' : 0
92+ [ iconOnly ] : 0
9293 } ,
9394 paddingY : 0 ,
9495 aspectRatio : {
95- ':has([slot=icon]):not(:has([data-rsp-slot=text]))' : 'square'
96+ [ iconOnly ] : 'square'
9697 } ,
9798 transition : 'default' ,
9899 borderStyle : 'solid' ,
@@ -110,7 +111,7 @@ const button = style<ButtonRenderProps & ButtonStyleProps>({
110111 type : 'marginTop' ,
111112 value : {
112113 default : fontRelative ( - 2 ) ,
113- ':has([slot=icon]):not(:has([data-rsp-slot=text]))' : 0
114+ [ iconOnly ] : 0
114115 }
115116 } ,
116117 borderColor : {
@@ -331,15 +332,18 @@ function Button(props: ButtonProps, ref: FocusableRef<HTMLButtonElement>) {
331332 < Provider
332333 values = { [
333334 [ SkeletonContext , null ] ,
334- [ TextContext , { styles : style ( {
335- paddingY : '--labelPadding' ,
336- order : 1 ,
337- opacity : {
338- default : 1 ,
339- isProgressVisible : 0
340- }
335+ [ TextContext , {
336+ styles : style ( {
337+ paddingY : '--labelPadding' ,
338+ order : 1 ,
339+ opacity : {
340+ default : 1 ,
341+ isProgressVisible : 0
342+ }
343+ } ) ( { isProgressVisible} ) ,
341344 // @ts -ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
342- } ) ( { isProgressVisible} ) , 'data-rsp-slot' : 'text' } ] ,
345+ 'data-rsp-slot' : 'text'
346+ } ] ,
343347 [ IconContext , {
344348 render : centerBaseline ( { slot : 'icon' , styles : style ( { order : 0 } ) } ) ,
345349 styles : style ( {
@@ -406,7 +410,11 @@ function LinkButton(props: LinkButtonProps, ref: FocusableRef<HTMLAnchorElement>
406410 < Provider
407411 values = { [
408412 [ SkeletonContext , null ] ,
409- [ TextContext , { styles : style ( { paddingY : '--labelPadding' , order : 1 } ) } ] ,
413+ [ TextContext , {
414+ styles : style ( { paddingY : '--labelPadding' , order : 1 } ) ,
415+ // @ts -ignore data-attributes allowed on all JSX elements, but adding to DOMProps has been problematic in the past
416+ 'data-rsp-slot' : 'text'
417+ } ] ,
410418 [ IconContext , {
411419 render : centerBaseline ( { slot : 'icon' , styles : style ( { order : 0 } ) } ) ,
412420 styles : style ( { size : fontRelative ( 20 ) , marginStart : '--iconMargin' , flexShrink : 0 } )
0 commit comments