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

fix: updated toasts component and copy #27656

Merged
merged 3 commits into from
Oct 10, 2024
Merged
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
8 changes: 3 additions & 5 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import { NonEmptyArray } from '@metamask/utils';
import { InternalAccount, isEvmAccountType } from '@metamask/keyring-api';
import { NetworkConfiguration } from '@metamask/network-controller';
import {
AlignItems,
BlockSize,
Display,
FlexDirection,
} from '../../../../helpers/constants/design-system';
import { getURLHost } from '../../../../helpers/utils/util';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import {
getConnectedSitesList,
Expand Down Expand Up @@ -175,8 +175,6 @@ export const ReviewPermissions = () => {
setShowAccountToast(true);
};

const hostName = getURLHost(securedOrigin);

return (
<Page
data-testid="connections-page"
Expand Down Expand Up @@ -222,11 +220,12 @@ export const ReviewPermissions = () => {
flexDirection={FlexDirection.Column}
width={BlockSize.Full}
gap={2}
alignItems={AlignItems.center}
>
{showAccountToast ? (
<ToastContainer>
<Toast
text={t('accountPermissionToast', [hostName])}
text={t('accountPermissionToast')}
onClose={() => setShowAccountToast(false)}
startAdornment={
<AvatarFavicon
Expand All @@ -241,7 +240,7 @@ export const ReviewPermissions = () => {
{showNetworkToast ? (
<ToastContainer>
<Toast
text={t('networkPermissionToast', [hostName])}
text={t('networkPermissionToast')}
onClose={() => setShowNetworkToast(false)}
startAdornment={
<AvatarFavicon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`Toast should render Toast component 1`] = `
<div>
<div
class="mm-box mm-banner-base mm-box--padding-3 mm-box--display-flex mm-box--gap-2 mm-box--background-color-background-default"
class="mm-box mm-banner-base toasts-container__banner-base undefined mm-box--padding-3 mm-box--display-flex mm-box--gap-2 mm-box--background-color-background-default"
data-theme="light"
>
<div
Expand Down
12 changes: 8 additions & 4 deletions ui/components/multichain/toast/index.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
.toasts-container {
position: sticky;
bottom: 10px;
margin-inline-start: 10px;
margin-inline-end: 10px;
bottom: 16px;
margin-inline-start: 16px;
margin-inline-end: 16px;
z-index: 200;
display: flex;
gap: 10px;
width: 90%;
flex-direction: column;
max-width: 600px;

&__banner-base {
border-radius: 8px;
box-shadow: var(--shadow-size-md);
}
}

.toast-text {
Expand Down
3 changes: 3 additions & 0 deletions ui/components/multichain/toast/toast.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const Toast = ({
autoHideTime,
onAutoHideToast,
dataTestId,
className,
}: {
startAdornment: React.ReactNode | React.ReactNode[];
text: string;
Expand All @@ -35,6 +36,7 @@ export const Toast = ({
autoHideTime?: number;
onAutoHideToast?: () => void;
dataTestId?: string;
className?: string;
}) => {
const { theme } = document.documentElement.dataset;
const [shouldDisplay, setShouldDisplay] = useState(true);
Expand Down Expand Up @@ -66,6 +68,7 @@ export const Toast = ({
onClose={onClose}
borderRadius={borderRadius}
data-testid={dataTestId ? `${dataTestId}-banner-base` : undefined}
className={`toasts-container__banner-base ${className}`}
>
<Box display={Display.Flex} gap={4} data-testid={dataTestId}>
{startAdornment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exports[`SurveyToast should match snapshot 1`] = `
<div>
<div
class="mm-box mm-banner-base mm-box--padding-3 mm-box--display-flex mm-box--gap-2 mm-box--background-color-background-default"
class="mm-box mm-banner-base toasts-container__banner-base undefined mm-box--padding-3 mm-box--display-flex mm-box--gap-2 mm-box--background-color-background-default"
data-testid="survey-toast-banner-base"
data-theme="light"
>
Expand Down