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

feat(button): Adjust dynamically button width #84

Merged
merged 8 commits into from
May 4, 2021
13 changes: 7 additions & 6 deletions src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ function Button({
}: ButtonProps) {
const isButtonDisabled = Boolean(isDisabled || shouldDisplaySpinner);
const containerClassName = classNames("button", customClassName, {
"button--is-inactive": isButtonDisabled,
"button--is-pending": shouldDisplaySpinner
"button--is-inactive": isButtonDisabled
});

return (
Expand All @@ -76,10 +75,12 @@ function Button({
{children}

{shouldDisplaySpinner && (
<Spinner
customClassName={"button__spinner"}
aria-label={"Button spinner visible. Button inactivated."}
/>
<div className={"button__spinner__container"}>
<Spinner
customClassName={"button__spinner"}
aria-label={"Button spinner visible. Button inactivated."}
/>
</div>
)}
</button>
);
Expand Down
10 changes: 6 additions & 4 deletions src/button/_button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
cursor: not-allowed;
}

.button--is-pending {
color: var(--button-bg);
.button__spinner__container {
position: absolute;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure but probably we need to set top,left,right,bottom to 0 make sure it's on correct position


width: 100%;

background-color: var(--button-bg);
}

.button__spinner {
position: absolute;

.spinner__background {
background: var(--button-bg);
}
Expand Down