Skip to content

Commit 0cdf701

Browse files
authored
Revert "fix: update action button to use grid area to position notification badge (#8409)" (#8552)
This reverts commit 02a90a1.
1 parent 488bb6b commit 0cdf701

File tree

1 file changed

+8
-19
lines changed

1 file changed

+8
-19
lines changed

packages/@react-spectrum/s2/src/ActionButton.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
6767
...focusRing(),
6868
...staticColor(),
6969
...controlStyle,
70-
display: 'grid',
7170
justifyContent: 'center',
7271
flexShrink: {
7372
default: 1,
@@ -80,21 +79,9 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
8079
isJustified: 0
8180
},
8281
fontWeight: 'medium',
83-
width: 'fit',
8482
userSelect: 'none',
8583
transition: 'default',
8684
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-
},
9885
backgroundColor: {
9986
default: {
10087
...baseColor('gray-100'),
@@ -236,7 +223,8 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
236223
'--badgePosition': {
237224
type: 'width',
238225
value: {
239-
default: '--iconWidth',
226+
default: 'calc(self(paddingStart) + var(--iconWidth))',
227+
[iconOnly]: 'calc(self(minWidth)/2 + var(--iconWidth)/2)',
240228
[textOnly]: 'full'
241229
}
242230
},
@@ -301,10 +289,10 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
301289
<Provider
302290
values={[
303291
[SkeletonContext, null],
304-
[TextContext, {styles: style({truncate: true, gridArea: 'text'})}],
292+
[TextContext, {styles: style({order: 1, truncate: true})}],
305293
[IconContext, {
306-
render: centerBaseline({slot: 'icon', styles: style({gridArea: 'icon'})}),
307-
styles: style({size: fontRelative(20), marginStart: '--iconMargin'})
294+
render: centerBaseline({slot: 'icon', styles: style({order: 0})}),
295+
styles: style({size: fontRelative(20), marginStart: '--iconMargin', flexShrink: 0})
308296
}],
309297
[AvatarContext, {
310298
size: avatarSize[size],
@@ -313,14 +301,15 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
313301
default: '--iconMargin',
314302
':last-child': 0
315303
},
316-
gridArea: 'icon'
304+
flexShrink: 0,
305+
order: 0
317306
})
318307
}],
319308
[NotificationBadgeContext, {
320309
staticColor: staticColor,
321310
size: props.size === 'XS' ? undefined : props.size,
322311
isDisabled: props.isDisabled,
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'})
312+
styles: style({position: 'absolute', top: '--badgeTop', insetStart: '--badgePosition', marginTop: 'calc((self(height) * -1)/2)', marginStart: 'calc((self(height) * -1)/2)'})
324313
}]
325314
]}>
326315
{typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}

0 commit comments

Comments
 (0)