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
10 changes: 4 additions & 6 deletions src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,13 @@ function Button({
onBlur={onBlur}
disabled={isButtonDisabled}
aria-label={ariaLabel}>
{shouldDisplaySpinner ? (
{children}

{shouldDisplaySpinner && (
<Spinner
customClassName={classNames("button__spinner", {
[`${customClassName}__spinner`]: customClassName
})}
customClassName={"button__spinner"}
aria-label={"Button spinner visible. Button inactivated."}
/>
) : (
children
)}
</button>
);
Expand Down
10 changes: 9 additions & 1 deletion src/button/_button.scss
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
.button {
--button-width: 100%;
--button-width: max-content;
--button-height: 35px;
--button-bg: black;
--button-color: white;

position: relative;

display: flex;
align-items: center;
justify-content: center;
Expand Down Expand Up @@ -31,7 +33,13 @@
cursor: not-allowed;
}

.button--is-pending {
color: var(--button-bg);
}

.button__spinner {
position: absolute;

.spinner__background {
background: var(--button-bg);
}
Expand Down
3 changes: 2 additions & 1 deletion src/dropdown/_dropdown.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ $dropdown-header-horizontal-padding: 8px;
}

.dropdown__header-button__text {
@include truncate-line(calc(100% - #{$dropdown-header-horizontal-padding}));
@include truncate-line();

flex: 1;

Expand All @@ -58,6 +58,7 @@ $dropdown-header-horizontal-padding: 8px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;

flex: 1;

Expand Down
2 changes: 2 additions & 0 deletions src/form/input/file/_file-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
align-items: center;
justify-content: center;

padding: 0 8px;

cursor: pointer;
}

Expand Down
17 changes: 11 additions & 6 deletions stories/3-Button.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {storiesOf} from "@storybook/react";
import Button from "../src/button/Button";
import FileUploadButton from "../src/button/file-upload/FileUploadButton";
import StoryFragment from "./utils/StoryFragment";
import StateProvider from "./utils/StateProvider";

storiesOf("Button", module).add("Button States", () => (
<StoryFragment>
Expand All @@ -19,12 +20,16 @@ storiesOf("Button", module).add("Button States", () => (

<br />

<Button
type={"button"}
onClick={(e) => alert("Thank You!")}
shouldDisplaySpinner={true}>
{"Click Me - shouldDisplaySpinner"}
</Button>
<StateProvider initialState={false}>
{(state, setState) => (
<Button
type={"button"}
onClick={() => setState(true)}
shouldDisplaySpinner={state}>
{"Click Me - shouldDisplaySpinner"}
</Button>
)}
</StateProvider>

<br />
<hr />
Expand Down