From 3747bc61efed32fcb4214bdb7bbbda4d63db1260 Mon Sep 17 00:00:00 2001 From: Monte Lai Date: Wed, 30 Aug 2023 05:22:53 +0800 Subject: [PATCH] fix: overflow of link and warnings (#20375) * fix: overflow of link and warnings * fix: update snapshot * --wrapped in React.memo HOC --changed Website to a clickable link --slightly better overflow wrapping, but the best would be to wrap on dots and slashes * updated snapshot --------- Co-authored-by: Howard Braham --- .../snap-account-detail-page.test.tsx.snap | 99 ++++++++----------- .../snap-account-detail-page/detail.tsx | 7 +- .../snap-account-detail-page/header.tsx | 59 ++--------- .../snap-account-detail-page.tsx | 33 +++++-- .../snap-detail-tag.tsx | 49 +++++++++ 5 files changed, 132 insertions(+), 115 deletions(-) create mode 100644 ui/pages/keyring-snaps/snap-account-detail-page/snap-detail-tag.tsx diff --git a/ui/pages/keyring-snaps/snap-account-detail-page/__snapshots__/snap-account-detail-page.test.tsx.snap b/ui/pages/keyring-snaps/snap-account-detail-page/__snapshots__/snap-account-detail-page.test.tsx.snap index 13f172499..aef5def3d 100644 --- a/ui/pages/keyring-snaps/snap-account-detail-page/__snapshots__/snap-account-detail-page.test.tsx.snap +++ b/ui/pages/keyring-snaps/snap-account-detail-page/__snapshots__/snap-account-detail-page.test.tsx.snap @@ -61,47 +61,31 @@ exports[`SnapAccountDetails should take a snapshot 1`] = ` />
+ +

-

- - -

- By MetaMask -

-
+ By MetaMask

+ +

-

- - -

- Audited -

-
+ Audited

@@ -130,7 +114,7 @@ exports[`SnapAccountDetails should take a snapshot 1`] = ` class="mm-box mm-box--margin-bottom-4 mm-box--flex-direction-column" >

Tags

@@ -148,12 +132,12 @@ exports[`SnapAccountDetails should take a snapshot 1`] = ` class="mm-box mm-box--margin-bottom-4 mm-box--flex-direction-column" >

Developer

Metamask

@@ -162,46 +146,49 @@ exports[`SnapAccountDetails should take a snapshot 1`] = ` class="mm-box mm-box--margin-bottom-4 mm-box--flex-direction-column" >

Website

- https://www.consensys.net/ + + https://www.consensys.net/ +

Audit

-

- - auditUrl1 - -

-

+ - - auditUrl2 - -

+ auditUrl2 +

Version

@@ -215,7 +202,7 @@ exports[`SnapAccountDetails should take a snapshot 1`] = ` class="mm-box mm-box--margin-bottom-4 mm-box--flex-direction-column" >

Updated

diff --git a/ui/pages/keyring-snaps/snap-account-detail-page/detail.tsx b/ui/pages/keyring-snaps/snap-account-detail-page/detail.tsx index 7e47b59ad..1fccfa161 100644 --- a/ui/pages/keyring-snaps/snap-account-detail-page/detail.tsx +++ b/ui/pages/keyring-snaps/snap-account-detail-page/detail.tsx @@ -2,6 +2,7 @@ import React from 'react'; import { Box, Text } from '../../../components/component-library'; import { FlexDirection, + OverflowWrap, TextVariant, } from '../../../helpers/constants/design-system'; @@ -11,7 +12,11 @@ const Detail = ({ }: React.PropsWithChildren<{ title: string }>) => { return ( - + {title} {children} diff --git a/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx b/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx index 056c8d754..9a53cbd67 100644 --- a/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx +++ b/ui/pages/keyring-snaps/snap-account-detail-page/header.tsx @@ -13,7 +13,6 @@ import { } from '../../../components/component-library'; import { AlignItems, - BackgroundColor, BorderColor, Display, FlexDirection, @@ -22,8 +21,9 @@ import { TextVariant, } from '../../../helpers/constants/design-system'; import { useI18nContext } from '../../../hooks/useI18nContext'; -import { SnapCardProps } from '../new-snap-account-page/new-snap-account-page'; import { METAMASK_DEVELOPER } from '../constants'; +import { SnapCardProps } from '../new-snap-account-page/new-snap-account-page'; +import SnapDetailTag from './snap-detail-tag'; export const SnapDetailHeader = ({ updateAvailable, @@ -147,57 +147,14 @@ export const SnapDetailHeader = ({ {developer.toLowerCase() === METAMASK_DEVELOPER && ( - - {' '} - - {t('snapCreatedByMetaMask')} - - - } - labelProps={{ - color: TextColor.infoDefault, - }} - className="" - marginRight={1} - /> + + {t('snapCreatedByMetaMask')} + )} {auditUrls.length > 0 && ( - - {' '} - - {t('snapIsAudited')} - - - } - labelProps={{ - color: TextColor.infoDefault, - }} - /> + + {t('snapIsAudited')} + )} diff --git a/ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx b/ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx index e7f3e8f9f..91404eeaa 100644 --- a/ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx +++ b/ui/pages/keyring-snaps/snap-account-detail-page/snap-account-detail-page.tsx @@ -13,6 +13,7 @@ import { BlockSize, Display, FlexDirection, + OverflowWrap, TextColor, TextVariant, } from '../../../helpers/constants/design-system'; @@ -104,17 +105,35 @@ export default function SnapAccountDetailPage() { })} - {currentSnap.developer} + + {currentSnap.developer} + + + + - {currentSnap.website} {currentSnap.auditUrls.map((auditLink, index) => { return ( - - - + ); })} diff --git a/ui/pages/keyring-snaps/snap-account-detail-page/snap-detail-tag.tsx b/ui/pages/keyring-snaps/snap-account-detail-page/snap-detail-tag.tsx new file mode 100644 index 000000000..5ed3ef186 --- /dev/null +++ b/ui/pages/keyring-snaps/snap-account-detail-page/snap-detail-tag.tsx @@ -0,0 +1,49 @@ +import React, { ReactChildren } from 'react'; +import { + Box, + Icon, + IconName, + Text, +} from '../../../components/component-library'; +import { + AlignItems, + BackgroundColor, + BorderColor, + BorderRadius, + Display, + IconColor, + JustifyContent, + TextColor, + TextVariant, +} from '../../../helpers/constants/design-system'; + +const SnapDetailTag = ({ + icon, + children, +}: { + icon: IconName; + children: ReactChildren; +}) => { + return ( + + {' '} + + {children} + + + ); +}; + +export default React.memo(SnapDetailTag);