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

refactor bpk-component-loading-button styles #3276

Closed
wants to merge 2 commits into from
Closed
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
11 changes: 3 additions & 8 deletions packages/bpk-component-loading-button/src/BpkLoadingButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,36 +113,31 @@ const BpkLoadingButton = (props: LoadingProps) => {
const loadingIcon = getLoadingIcon(props);

const classNames = getClassName(
loading && 'bpk-loading-button',
loading && (link || linkOnDark) && 'bpk-loading-button--link',
className,
);

const iconClassNames = getClassName(
'bpk-loading-button__icon',
large && 'bpk-loading-button__icon--large',
iconOnly &&
(large
? 'bpk-loading-button__icon--large-icon-only'
: 'bpk-loading-button__icon--icon-only'),
(link || linkOnDark) && 'bpk-loading-button__icon--link',
);

return (
// $FlowFixMe[cannot-spread-inexact] - inexact rest. See 'decisions/flowfixme.md'.
<BpkButton
Copy link
Member

Choose a reason for hiding this comment

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

We should also possibly use this as an opportunity to migrate this component to Buttonv2?

className={classNames}
iconOnly={iconOnly}
disabled={showBtnDisabled}
large={large}
className={classNames}
link={link}
linkOnDark={linkOnDark}
{...rest}
>
{loading && <span className={iconClassNames}>{loadingIcon}</span>}
<span className={loading && STYLES["content-invisible"]}>
{child0}
{child1}
{child2}
</span>
</BpkButton>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,50 +17,25 @@
*/

@use '../../unstable__bpk-mixins/tokens';
@use '../../unstable__bpk-mixins/utils';

.bpk-loading-button {
$button-padding-x: tokens.bpk-spacing-base() * 2;
$button-padding-y: tokens.bpk-spacing-lg() * 0.5;
$button-large-padding-y: tokens.bpk-spacing-lg();
$button-icon-only-padding-x: tokens.$bpk-button-height -
tokens.$bpk-icon-size-sm; // this is in order to ensure icons are centred in icon-only buttons
/* stylelint-disable-next-line scss/operator-no-newline-after */
$button-large-icon-only-padding-x: tokens.$bpk-button-large-height -
tokens.$bpk-icon-size-lg; // this is in order to ensure icons are centred in icon-only buttons

position: relative;
overflow: hidden;

&--link {
visibility: hidden;
}

&__icon {
position: absolute;
display: inline-flex;
display: flex;
visibility: visible;
z-index: 1;
width: calc(100% - #{$button-padding-x});
height: calc(100% - #{$button-padding-y});
justify-content: center;
align-items: center;
background-color: inherit;

&--large {
height: calc(100% - #{$button-large-padding-y});
}

&--icon-only {
width: calc(100% - #{$button-icon-only-padding-x});
}

&--large-icon-only {
width: calc(100% - #{$button-large-icon-only-padding-x});
}

&--link {
width: 100%;
background: unset;
}
}
}

.content-invisible {
@include utils.bpk-invisible();
height: 0px;
display: block;
}