Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix busy button dots to be smaller when button is small #7235

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/js/components/Button/BusyAnimation.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,18 @@ const bounceDelayRule = css`
animation: ${bounceDelay} 1.4s infinite ease-in-out both;
`;

/* When button is small size we need half the dot size to fit properly */
const Dot = styled(Box)`
background-color: currentColor;
width: 8px;
height: 8px;
width: ${(props) => (props.size.size === 'small' ? '4px' : '8px')};
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's not necessarily that the button has prop size="small" but rather that if the label is really short, the width of the button is more narrow, causing the "dots" to squish.

I'm wondering if instead these "Dot"s should just have a flex={false}?

Copy link
Collaborator

Choose a reason for hiding this comment

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

If the dots have flex={false} and the label is really short would the Button size grow horizontally when it enters the busy state?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

aw I didnt check the label so even on a medium size button with a small label this is happening

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

☝️
so yes when we have flex={false} then the dots are not in the correct space. We may need to check the size of the button if it is under 100px seems to be where it is happening then change the values.

Screen.Recording.2024-05-20.at.5.03.07.PM.mov

height: ${(props) => (props.size.size === 'small' ? '4px' : '8px')};
border-radius: 100%;
display: inline-block;
${bounceDelayRule}
${(props) => props.delay && `animation-delay: ${props.delay};`}
`;

export const EllipsisAnimation = () => (
export const EllipsisAnimation = (size) => (
<Box
style={{ position: 'absolute' }}
fill
Expand All @@ -35,9 +36,9 @@ export const EllipsisAnimation = () => (
<Box alignSelf="center" direction="row" gap="small">
{/* A negative delay starts the animation sooner. The first dot
should begin animating before the second and so on. */}
<Dot delay="-0.32s" />
<Dot delay="-0.16s" />
<Dot />
<Dot size={size} delay="-0.32s" />
<Dot size={size} delay="-0.16s" />
<Dot size={size} />
</Box>
</Box>
);
Expand Down
2 changes: 1 addition & 1 deletion src/js/components/Button/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ const Button = forwardRef(
// position relative is necessary to have the animation
// display over the button content
<RelativeBox flex={false}>
{busy && <EllipsisAnimation />}
{busy && <EllipsisAnimation size={sizeProp} />}
{success && (
<Box
style={{ position: 'absolute' }}
Expand Down