Skip to content

Commit

Permalink
Enable destructive footer buttons in Snap UI
Browse files Browse the repository at this point in the history
  • Loading branch information
david0xd committed Jan 29, 2025
1 parent 08365f0 commit f47b917
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
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'}
>
{isSnapAction && !hideSnapBranding && !loading && (
<SnapIcon snapId={snapId} avatarSize={IconSize.Sm} marginRight={2} />
Expand Down
5 changes: 3 additions & 2 deletions ui/components/app/snaps/snap-ui-renderer/components/footer.ts
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 ??
(providedChildren.length === 2 && index === 0
? ButtonVariant.Secondary
: ButtonVariant.Primary,
: ButtonVariant.Primary),
isSnapAction: true,
},
children: buttonMapped.children,
Expand Down

0 comments on commit f47b917

Please sign in to comment.