Skip to content

Commit

Permalink
feat: Add updates to Snaps custom UI (#26639)
Browse files Browse the repository at this point in the history
## **Description**
This PR adds changes to update Snaps Custom UI. Affected areas are:
Snaps Home, Snap Custom Dialog, Snap components.

[![Open in GitHub
Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/MetaMask/metamask-extension/pull/26639?quickstart=1)

## **Related issues**
Fixes: #26436

## **Manual testing steps**
1. Go to test Snaps.
2. Install Snaps with custom UI and Snap home.
3. Check the new UI styling applied.

## **Screenshots/Recordings**
### **Before**
![Screenshot 2024-08-26 at 17 40
00](https://github.com/user-attachments/assets/dda8ab1f-f915-4b1b-9f34-b0657377aecd)
![Screenshot 2024-08-26 at 17 40
28](https://github.com/user-attachments/assets/39d246b6-b7f6-4630-950e-81153b01055e)
![Screenshot 2024-08-26 at 17 40
51](https://github.com/user-attachments/assets/f9730150-5f47-4c25-b516-f0245857dadc)
![Screenshot 2024-08-26 at 17 41
27](https://github.com/user-attachments/assets/3565fd8c-3563-4e72-9fa7-6e8d4a809601)

### **After**
![Screenshot 2024-09-05 at 14 01
12](https://github.com/user-attachments/assets/6bfea475-89fb-4cc9-bd9a-4060b51b1004)
![Screenshot 2024-09-05 at 14 01
26](https://github.com/user-attachments/assets/feb061e5-9f57-4926-9413-5e60e7753d04)
![Screenshot 2024-09-05 at 14 01
45](https://github.com/user-attachments/assets/30945e92-8a6b-452a-ba8f-2fcbbd843131)
![Screenshot 2024-09-05 at 14 02
34](https://github.com/user-attachments/assets/50a2710f-4410-4964-b67e-a1fb651707e6)
![Screenshot 2024-09-05 at 14 03
04](https://github.com/user-attachments/assets/7ab79ac4-9900-4e78-9947-c0ee2561097e)
![Screenshot 2024-09-05 at 14 04
44](https://github.com/user-attachments/assets/beb57d5e-64a1-4675-af1c-2b20b3286498)
![Screenshot 2024-09-05 at 14 06
34](https://github.com/user-attachments/assets/0ea50de1-9aca-428e-8575-40ff73a507f9)
![Screenshot 2024-09-05 at 14 20
50](https://github.com/user-attachments/assets/6bb8039c-7713-48e0-a219-2bc4b0017ff5)
![Screenshot 2024-09-05 at 16 42
16](https://github.com/user-attachments/assets/48a5f43a-fad1-4db8-84fd-b6ae3c038de3)
![Screenshot 2024-09-05 at 16 42
42](https://github.com/user-attachments/assets/e588f207-4952-4bc7-bd91-d26900158bb9)
![Screenshot 2024-09-09 at 18 25
45](https://github.com/user-attachments/assets/283339e3-3a01-4a9c-bb28-906d54cb2374)

## **Pre-merge author checklist**
- [ ] I've followed [MetaMask Contributor
Docs](https://github.com/MetaMask/contributor-docs) and [MetaMask
Extension Coding
Standards](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/CODING_GUIDELINES.md).
- [ ] I've completed the PR template to the best of my ability
- [ ] I’ve included tests if applicable
- [ ] I’ve documented my code using [JSDoc](https://jsdoc.app/) format
if applicable
- [ ] I’ve applied the right labels on the PR (see [labeling
guidelines](https://github.com/MetaMask/metamask-extension/blob/develop/.github/guidelines/LABELING_GUIDELINES.md)).
Not required for external contributors.

## **Pre-merge reviewer checklist**
- [ ] I've manually tested the PR (e.g. pull and build branch, run the
app, test code being changed).
- [ ] I confirm that this PR addresses all acceptance criteria described
in the ticket it closes and includes the necessary testing evidence such
as recordings and or screenshots.
  • Loading branch information
david0xd authored Sep 10, 2024
1 parent 92c8a06 commit bbbe511
Show file tree
Hide file tree
Showing 30 changed files with 139 additions and 290 deletions.
8 changes: 2 additions & 6 deletions ui/components/app/connected-sites-list/connected-snaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { useDispatch, useSelector } from 'react-redux';
import { Box, IconName, IconSize, Text } from '../../component-library';
import { useI18nContext } from '../../../hooks/useI18nContext';
import { MenuItem } from '../../ui/menu';
import SnapAvatar from '../snaps/snap-avatar';
import {
AlignItems,
BlockSize,
Expand All @@ -18,6 +17,7 @@ import ConnectedAccountsListOptions from '../connected-accounts-list/connected-a
import { getOriginOfCurrentTab } from '../../../selectors';
import { disconnectOriginFromSnap } from '../../../store/actions';
import { getSnapRoute } from '../../../helpers/utils/util';
import { SnapIcon } from '../snaps/snap-icon';

export default function ConnectedSnaps({ connectedSubjects }) {
const [showOptions, setShowOptions] = useState();
Expand Down Expand Up @@ -74,11 +74,7 @@ export default function ConnectedSnaps({ connectedSubjects }) {
display={Display.Flex}
alignItems={AlignItems.center}
>
<SnapAvatar
snapId={subject.origin}
badgeSize={IconSize.Xs}
avatarSize={IconSize.Md}
/>
<SnapIcon snapId={subject.origin} avatarSize={IconSize.Md} />
<Text
variant={TextVariant.bodyLgMedium}
className="connected-accounts-list__account-name"
Expand Down
2 changes: 1 addition & 1 deletion ui/components/app/snaps/copyable/copyable.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const Copyable = ({
backgroundColor={
isVisible && sensitive
? BackgroundColor.errorMuted
: BackgroundColor.backgroundAlternative
: BackgroundColor.primaryMuted
}
borderRadius={BorderRadius.LG}
padding={2}
Expand Down
39 changes: 32 additions & 7 deletions ui/components/app/snaps/copyable/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,42 @@
transition: background-color background 0.2s;

& .show-more__button {
background: linear-gradient(90deg, transparent 0%, var(--color-background-alternative) 33%);
background: linear-gradient(90deg, transparent 0%, var(--color-background-primary-muted) 33%);
}

&:hover {
background-color: var(--color-background-alternative-hover);
background-color: var(--color-primary-muted);
color: var(--color-primary-default) !important;

& .show-more__button {
background: linear-gradient(90deg, transparent 0%, var(--color-background-alternative-hover) 33%);
background: linear-gradient(90deg, transparent 0%, var(--color-background-primary-muted) 33%);
}

p,
.copyable__icon {
color: var(--color-primary-default);
}

.copyable__tooltip {
.mm-icon {
color: var(--color-primary-default);
}
}
}

&.clicked {
background-color: var(--color-background-alternative-pressed);
background-color: var(--color-primary-muted);
opacity: 0.75;

& .show-more__button {
background: linear-gradient(90deg, transparent 0%, var(--color-background-alternative-pressed) 33%);
background: linear-gradient(90deg, transparent 0%, var(--color-background-primary-muted) 33%);
}

&:hover {
background-color: var(--color-background-alternative-pressed);
background-color: var(--color-primary-muted);

& .show-more__button {
background: linear-gradient(90deg, transparent 0%, var(--color-background-alternative-pressed) 33%);
background: linear-gradient(90deg, transparent 0%, var(--color-background-primary-muted) 33%);
}
}
}
Expand All @@ -45,9 +58,21 @@
& .show-more__button {
background: linear-gradient(90deg, transparent 0%, var(--color-error-muted-hover) 33%);
}

p,
.copyable__icon {
color: var(--color-error-default);
}

.copyable__tooltip {
.mm-icon {
color: var(--color-error-default);
}
}
}

&.clicked {
opacity: 0.75;
background-color: var(--color-error-muted-pressed);

& .show-more__button {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import React, { useState } from 'react';
import PropTypes from 'prop-types';
import classnames from 'classnames';
import { stripSnapPrefix } from '@metamask/snaps-utils';
import { useSelector } from 'react-redux';
import {
BackgroundColor,
TextColor,
FlexDirection,
TextVariant,
AlignItems,
Display,
Expand All @@ -25,9 +23,9 @@ import {
ButtonIconSize,
ButtonIcon,
} from '../../../component-library';
import SnapAvatar from '../snap-avatar';
import { SnapMetadataModal } from '../snap-metadata-modal';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import { SnapIcon } from '../snap-icon';

const SnapAuthorshipHeader = ({
snapId,
Expand All @@ -40,11 +38,6 @@ const SnapAuthorshipHeader = ({
}) => {
const t = useI18nContext();
const [isModalOpen, setIsModalOpen] = useState(false);
// We're using optional chaining with snapId, because with the current implementation
// of snap update in the snap controller, we do not have reference to snapId when an
// update request is rejected because the reference comes from the request itself and not subject metadata
// like it is done with snap install
const packageName = snapId && stripSnapPrefix(snapId);

const { name: snapName } = useSelector((state) =>
getSnapMetadata(state, snapId),
Expand All @@ -57,13 +50,15 @@ const SnapAuthorshipHeader = ({
return (
<Box
className={classnames('snaps-authorship-header', className)}
backgroundColor={BackgroundColor.backgroundAlternative}
backgroundColor={BackgroundColor.backgroundDefault}
width={BlockSize.Full}
alignItems={AlignItems.center}
display={Display.Flex}
padding={4}
style={{
boxShadow,
minHeight: '64px',
zIndex: 1,
}}
>
{snapId && (
Expand All @@ -87,7 +82,8 @@ const SnapAuthorshipHeader = ({
marginLeft={4}
marginRight={4}
display={Display.Flex}
flexDirection={FlexDirection.Column}
justifyContent={JustifyContent.center}
alignItems={AlignItems.center}
style={{ overflow: 'hidden' }}
width={BlockSize.Full}
>
Expand All @@ -96,11 +92,7 @@ const SnapAuthorshipHeader = ({
justifyContent={JustifyContent.center}
alignItems={AlignItems.center}
>
<SnapAvatar
snapId={snapId}
avatarSize={IconSize.Sm}
badgeSize={IconSize.Xs}
/>
<SnapIcon snapId={snapId} avatarSize={IconSize.Sm} />
<Text
color={TextColor.textDefault}
variant={TextVariant.bodyMdMedium}
Expand All @@ -110,20 +102,6 @@ const SnapAuthorshipHeader = ({
{snapName}
</Text>
</Box>
<Box
display={Display.Flex}
justifyContent={JustifyContent.center}
alignItems={AlignItems.center}
paddingTop={1}
>
<Text
ellipsis
variant={TextVariant.bodySm}
color={TextColor.textAlternative}
>
{packageName}
</Text>
</Box>
</Box>
{showInfo && (
<Box marginLeft="auto">
Expand Down
1 change: 0 additions & 1 deletion ui/components/app/snaps/snap-avatar/index.js

This file was deleted.

67 changes: 0 additions & 67 deletions ui/components/app/snaps/snap-avatar/snap-avatar.js

This file was deleted.

21 changes: 0 additions & 21 deletions ui/components/app/snaps/snap-avatar/snap-avatar.stories.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {
} from '../../../component-library';
import Tooltip from '../../../ui/tooltip/tooltip';
import { useI18nContext } from '../../../../hooks/useI18nContext';
import SnapAvatar from '../snap-avatar/snap-avatar';
import { getSnapMetadata } from '../../../../selectors';
import { SnapIcon } from '../snap-icon';

export default function SnapConnectCell({ origin, snapId }) {
const t = useI18nContext();
Expand All @@ -33,7 +33,7 @@ export default function SnapConnectCell({ origin, snapId }) {
paddingTop={2}
paddingBottom={2}
>
<SnapAvatar snapId={snapId} />
<SnapIcon snapId={snapId} />
<Box width="full" paddingLeft={4} paddingRight={4}>
<Text>
{t('connectSnap', [
Expand Down
11 changes: 10 additions & 1 deletion ui/components/app/snaps/snap-home-page/snap-home-renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
import { SnapDelineator } from '../snap-delineator';
import { DelineatorType } from '../../../../helpers/constants/snaps';
import {
BackgroundColor,
BlockSize,
TextVariant,
} from '../../../../helpers/constants/design-system';
Expand Down Expand Up @@ -64,7 +65,14 @@ export const SnapHomeRenderer = ({ snapId }) => {
}, [unapprovedTemplatedConfirmations, unapprovedConfirmations, history]);

return (
<Box height={BlockSize.Full}>
<Box
height={BlockSize.Full}
width={BlockSize.Full}
backgroundColor={BackgroundColor.backgroundAlternative}
style={{
overflowY: 'auto',
}}
>
{error && (
<Box height={BlockSize.Full} padding={4}>
<SnapDelineator snapName={snapName} type={DelineatorType.Error}>
Expand All @@ -82,6 +90,7 @@ export const SnapHomeRenderer = ({ snapId }) => {
isLoading={loading}
useDelineator={false}
useFooter
contentBackgroundColor={BackgroundColor.backgroundAlternative}
/>
)}
</Box>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {

import { Box, Text } from '../../../component-library';
import { getSnapMetadata } from '../../../../selectors';
import SnapAvatar from '../snap-avatar';
import { SnapIcon } from '../snap-icon';

const SnapLegacyAuthorshipHeader = ({
snapId,
Expand All @@ -45,7 +45,7 @@ const SnapLegacyAuthorshipHeader = ({
marginRight={marginRight}
>
<Box>
<SnapAvatar snapId={snapId} />
<SnapIcon snapId={snapId} />
</Box>
<Box
marginLeft={4}
Expand Down
4 changes: 2 additions & 2 deletions ui/components/app/snaps/snap-list-item/snap-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
IconSize,
Icon,
} from '../../../component-library';
import SnapAvatar from '../snap-avatar';
import { SnapIcon } from '../snap-icon';

const SnapListItem = ({
name,
Expand Down Expand Up @@ -45,7 +45,7 @@ const SnapListItem = ({
width={BlockSize.Full}
>
<Box>
<SnapAvatar snapId={snapId} />
<SnapIcon snapId={snapId} />
</Box>
<Box
paddingLeft={4}
Expand Down
Loading

0 comments on commit bbbe511

Please sign in to comment.