Skip to content

Commit

Permalink
Make hidden branding button color primary and fix footer margin
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeRx committed Sep 20, 2024
1 parent 27d8a54 commit efc5fdd
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 72 deletions.
2 changes: 1 addition & 1 deletion ui/components/app/app-components.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
@import 'snaps/insight-warnings/index';
@import 'snaps/snap-authorship-header/index';
@import 'snaps/snap-authorship-pill/index';
@import 'snaps/snap-footer-button/index';
@import 'snaps/snap-ui-footer-button/index';
@import 'hold-to-reveal-button/index';
@import 'home-notification/index';
@import 'info-box/index';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ import { SnapUITooltip } from '../snaps/snap-ui-tooltip';
import { SnapUICard } from '../snaps/snap-ui-card';
import { SnapUIAddress } from '../snaps/snap-ui-address';
import { SnapUISelector } from '../snaps/snap-ui-selector';
import { SnapFooterButton } from '../snaps/snap-footer-button';
import { SnapUIFooterButton } from '../snaps/snap-ui-footer-button';
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
import { SnapAccountSuccessMessage } from '../../../pages/confirmations/components/snap-account-success-message';
import { SnapAccountErrorMessage } from '../../../pages/confirmations/components/snap-account-error-message';
Expand Down Expand Up @@ -106,7 +106,7 @@ export const safeComponentList = {
SnapUICard,
SnapUISelector,
SnapUIAddress,
SnapFooterButton,
SnapUIFooterButton,
FormTextField,
///: BEGIN:ONLY_INCLUDE_IF(keyring-snaps)
CreateSnapAccount,
Expand Down
45 changes: 0 additions & 45 deletions ui/components/app/snaps/snap-footer-button/index.scss

This file was deleted.

1 change: 0 additions & 1 deletion ui/components/app/snaps/snap-footer-button/index.ts

This file was deleted.

51 changes: 51 additions & 0 deletions ui/components/app/snaps/snap-ui-footer-button/index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
.snap-ui-renderer__footer-button {
&: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%;
box-shadow: none;
}

&:active:not(&--disabled) {
opacity: 60%;
}
}

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

& span {
color: var(--color-icon-default);
}

&:hover:not(&--disabled) {
border-color: var(--color-icon-default);
color: var(--color-background-default);
background-color: var(--color-background-default-hover);
box-shadow: none;

& span {
color: var(--color-icon-default);
}
}

&:active:not(&--disabled) {
border-color: var(--color-icon-default);
opacity: 60%;

& span {
color: var(--color-icon-default);
}
}
}
}

&--disabled {
cursor: default !important;
}
}
1 change: 1 addition & 0 deletions ui/components/app/snaps/snap-ui-footer-button/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './snap-ui-footer-button';
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ import {
import { useSnapInterfaceContext } from '../../../../contexts/snaps';
import { SnapIcon } from '../snap-icon';
import { getHideSnapBranding } from '../../../../selectors';
import classnames from 'classnames';

type SnapFooterButtonProps = {
type SnapUIFooterButtonProps = {
name?: string;
isSnapAction?: boolean;
onCancel?: () => void;
};

export const SnapFooterButton: FunctionComponent<
SnapFooterButtonProps & ButtonLinkProps<'button'>
export const SnapUIFooterButton: FunctionComponent<
SnapUIFooterButtonProps & ButtonLinkProps<'button'>
> = ({
onCancel,
name,
children,
disabled = false,
isSnapAction = false,
type,
form,
Expand All @@ -57,12 +59,16 @@ export const SnapFooterButton: FunctionComponent<

return (
<Button
className="snap-footer-button"
className={classnames('snap-ui-renderer__footer-button', {
'snap-ui-renderer__footer-button--disabled': disabled,
'no-snap-branding': hideSnapBranding,
})}
type={type}
form={form}
{...props}
size={ButtonSize.Lg}
block
disabled={disabled}
variant={isSnapAction ? ButtonVariant.Primary : ButtonVariant.Secondary}
onClick={handleClick}
textProps={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export const container: UIComponentFactory<BoxElement> = ({
className: 'snap-ui-renderer__footer-centered',
},
children: {
element: 'SnapFooterButton',
element: 'SnapUIFooterButton',
key: 'default-button',
props: {
onCancel,
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 @@ -17,6 +17,7 @@ export const DEFAULT_FOOTER = {
display: Display.Flex,
flexDirection: FlexDirection.Row,
width: BlockSize.Full,
gap: 4,
padding: 4,
className: 'snap-ui-renderer__footer',
backgroundColor: BackgroundColor.backgroundDefault,
Expand All @@ -39,7 +40,7 @@ const getDefaultButtons = (
// If onCancel is omitted by the caller we assume that it is safe to not display the default footer.
if (children.length === 1 && onCancel) {
return {
element: 'SnapFooterButton',
element: 'SnapUIFooterButton',
key: 'default-button',
props: {
onCancel,
Expand Down Expand Up @@ -67,7 +68,7 @@ export const footer: UIComponentFactory<FooterElement> = ({
element: children,
} as UIComponentParams<ButtonElement>);
return {
element: 'SnapFooterButton',
element: 'SnapUIFooterButton',
key: `snap-footer-button-${buttonMapped.props?.name ?? index}`,
props: {
...buttonMapped.props,
Expand Down
16 changes: 0 additions & 16 deletions ui/components/app/snaps/snap-ui-renderer/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,5 @@

&__footer {
margin-top: auto;

&-centered {
margin-top: auto;

& button {
&:first-child {
margin-right: 0;
}
}
}

& button {
&:first-child {
margin-right: 16px;
}
}
}
}

0 comments on commit efc5fdd

Please sign in to comment.