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): refactor to flex and center icons #1452

Merged
merged 5 commits into from
Apr 11, 2024
Merged
Changes from 3 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
39 changes: 7 additions & 32 deletions src/components/Button/Button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,9 @@ $block: '.#{variables.$ns}button';
--_--border-color: currentColor;
--_--focus-outline-color: var(--g-color-line-focus);
--_--focus-outline-offset: 0;
--_--icon-space: calc(
var(--g-button-padding, var(--_--padding)) + var(--g-button-icon-size, var(--_--icon-size)) +
var(--g-button-icon-offset, var(--_--icon-offset))
);
--_--icon-position: calc(
var(--g-button-padding, var(--_--padding)) -
(
var(--g-button-height, var(--_--height)) - var(
--g-button-icon-size,
var(--_--icon-size)
)
) / 2
);
--_--font-size: var(--g-text-body-1-font-size);

@include mixins.button-reset();
display: inline-block;
position: relative;
amje marked this conversation as resolved.
Show resolved Hide resolved
overflow: visible;
box-sizing: border-box;
Expand All @@ -47,6 +33,10 @@ $block: '.#{variables.$ns}button';
transform 0.1s ease-out,
color 0.15s linear;
transform: scale(1);
display: inline-flex;
justify-content: center;
padding: 0 var(--g-button-padding, var(--_--padding));
gap: var(--g-button-icon-offset, var(--_--icon-offset));

&::before {
content: '';
Expand Down Expand Up @@ -266,13 +256,12 @@ $block: '.#{variables.$ns}button';
&__text {
display: inline-block;
white-space: nowrap;
padding: 0 var(--g-button-padding, var(--_--padding));
}

&__icon {
display: inline-block;
position: relative;
width: var(--g-button-height, var(--_--height));
width: var(--g-button-height, var(--_--icon-size));
amje marked this conversation as resolved.
Show resolved Hide resolved
height: var(--g-button-height, var(--_--height));
pointer-events: none;

Expand All @@ -289,26 +278,12 @@ $block: '.#{variables.$ns}button';
justify-content: center;
}

&_side_start,
&_side_end {
position: absolute;
inset-block-start: 0;
}

&_side_start {
inset-inline-start: var(--_--icon-position);

& ~ #{$block}__text {
padding-inline-start: var(--_--icon-space);
}
order: 0;
}

&_side_end {
inset-inline-end: var(--_--icon-position);

& ~ #{$block}__text {
padding-inline-end: var(--_--icon-space);
}
order: 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

Default value for order is 0, let's use-1 and 1 then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

}
}

Expand Down
Loading