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

feat: Add updates to Snaps custom UI #26639

Merged
merged 6 commits into from
Sep 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: 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} />
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved
<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',
FrederikBolding marked this conversation as resolved.
Show resolved Hide resolved
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