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(snaps): Enable destructive footer buttons in Snap UI #29966

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 9 additions & 3 deletions ui/components/app/snaps/snap-ui-footer-button/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
&:not(.hide-snap-branding) {
&.mm-button-primary {
box-shadow: none;
color: var(--color-text-alternative);
background-color: var(--color-icon-default);

&:hover:not(&--disabled) {
opacity: 80%;
Expand All @@ -13,11 +11,15 @@
&:active:not(&--disabled) {
opacity: 60%;
}

&:not(.mm-button-primary--type-danger) {
color: var(--color-text-alternative);
background-color: var(--color-icon-default);
}
}

&.mm-button-secondary {
border-color: var(--color-icon-default);
color: var(--color-icon-default);

& span {
color: var(--color-icon-default);
Expand All @@ -42,6 +44,10 @@
color: var(--color-icon-default);
}
}

&:not(.mm-button-primary--type-danger) {
color: var(--color-icon-default);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import { useSnapInterfaceContext } from '../../../../contexts/snaps';
import { SnapIcon } from '../snap-icon';
import { getHideSnapBranding } from '../../../../selectors';

type SnapButtonVariant = ButtonVariant & 'destructive';

type SnapUIFooterButtonProps = {
name?: string;
variant?: ButtonVariant;
variant?: SnapButtonVariant;
isSnapAction?: boolean;
onCancel?: () => void;
};
Expand All @@ -40,7 +42,7 @@ export const SnapUIFooterButton: FunctionComponent<
loading = false,
isSnapAction = false,
type,
variant = ButtonVariant.Primary,
variant = ButtonVariant.Primary as SnapButtonVariant,
form,
...props
}) => {
Expand Down Expand Up @@ -88,6 +90,7 @@ export const SnapUIFooterButton: FunctionComponent<
flexDirection: FlexDirection.Row,
}}
data-theme={null}
danger={variant === 'destructive'}
Copy link
Member

Choose a reason for hiding this comment

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

It seems that this component uses a different color for the destructive state.

I think we want to mirror the confirmations screen, see below for comparison.

image
image

>
{isSnapAction && !hideSnapBranding && !loading && (
<SnapIcon snapId={snapId} avatarSize={IconSize.Sm} marginRight={2} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,10 @@ export const footer: UIComponentFactory<FooterElement> = ({
props: {
...buttonMapped.props,
variant:
providedChildren.length === 2 && index === 0
buttonMapped.props?.variant ??
Copy link
Member

Choose a reason for hiding this comment

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

@GuillaumeRx Should take a look at this, I'm assuming we weren't intending to let users override this in all cases

(providedChildren.length === 2 && index === 0
? ButtonVariant.Secondary
: ButtonVariant.Primary,
: ButtonVariant.Primary),
isSnapAction: true,
},
children: buttonMapped.children,
Expand Down
Loading