Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 22 additions & 5 deletions packages/@react-spectrum/s2/src/ActionButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,15 @@ export const btnStyles = style<ButtonRenderProps & ActionButtonStyleProps & Togg
paddingX: {
default: controlStyle.paddingX,
[avatarOnly]: 0
},
// `control` sets this, but we need to override it for avatar only buttons.
'--iconMargin': {
type: 'marginStart',
value: {
default: fontRelative(-2),
[iconOnly]: 0,
[avatarOnly]: 0
}
}
}, getAllowedOverrides());

Expand Down Expand Up @@ -325,10 +334,7 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
[AvatarContext, {
size: avatarSize[size],
styles: style({
marginStart: {
default: '--iconMargin',
':last-child': 0
},
marginStart: '--iconMargin',
flexShrink: 0,
order: 0
})
Expand All @@ -345,7 +351,17 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
staticColor: staticColor,
size: props.size === 'XS' ? undefined : props.size,
isDisabled: isDisabled,
styles: style({position: 'absolute', top: '--badgeTop', insetStart: '--badgePosition', marginTop: 'calc((self(height) * -1)/2)', marginStart: 'calc((self(height) * -1)/2)'})
styles: style({
position: 'absolute',
top: '--badgeTop',
insetStart: '--badgePosition',
marginTop: 'calc((self(height) * -1)/2)',
marginStart: 'calc((self(height) * -1)/2)',
opacity: {
default: 1,
isProgressVisible: 0
}
})({isProgressVisible})
}]
]}>
{typeof props.children === 'string' ? <Text>{props.children}</Text> : props.children}
Expand All @@ -369,6 +385,7 @@ export const ActionButton = forwardRef(function ActionButton(props: ActionButton
styles={style({
size: {
size: {
XS: 12,
S: 14,
M: 18,
L: 20,
Expand Down
4 changes: 3 additions & 1 deletion packages/@react-spectrum/s2/src/style-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ const allowedOverrides = [
'insetX',
'insetY',
'insetStart',
'insetEnd'
'insetEnd',
'opacity',
'visibility'
Comment on lines +306 to +307
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how valid do we think this is? I'm not sure how else I would hide the component and since it doesn't change layout, seems mostly safe to allow setting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm i feel like it should be fine? if we do add them, we should remember to add the properties to the list of supported css properties in the storybook intro docs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think adding these should be ok as well

] as const;

const widthProperties = [
Expand Down