diff --git a/ui/components/app/app-components.scss b/ui/components/app/app-components.scss index cdbe492029b8..cc9a08a53f1d 100644 --- a/ui/components/app/app-components.scss +++ b/ui/components/app/app-components.scss @@ -34,6 +34,7 @@ @import 'snaps/show-more/index'; @import 'snaps/insight-warnings/index'; @import 'snaps/snap-authorship-header/index'; +@import 'snaps/snap-authorship-pill/index'; @import 'snaps/snap-footer-button/index'; @import 'hold-to-reveal-button/index'; @import 'home-notification/index'; diff --git a/ui/components/app/confirm/info/info.stories.tsx b/ui/components/app/confirm/info/info.stories.tsx index d801555aaed0..d23726f39104 100644 --- a/ui/components/app/confirm/info/info.stories.tsx +++ b/ui/components/app/confirm/info/info.stories.tsx @@ -17,7 +17,7 @@ const mockRowConfigs: ConfirmInfoRowConfig[] = [ label: 'Origin', type: ConfirmInfoRowType.UrlType, rowProps: { - address: 'https://metamask.github.io', + url: 'https://metamask.github.io', }, }, { diff --git a/ui/components/app/confirm/info/row/url.tsx b/ui/components/app/confirm/info/row/url.tsx index c7b9b8d9730a..807fc7298042 100644 --- a/ui/components/app/confirm/info/row/url.tsx +++ b/ui/components/app/confirm/info/row/url.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useCallback, useState } from 'react'; import { Box, Icon, @@ -16,6 +16,9 @@ import { TextVariant, BackgroundColor, } from '../../../../../helpers/constants/design-system'; +import SnapAuthorshipPill from '../../../snaps/snap-authorship-pill'; +import { SnapMetadataModal } from '../../../snaps/snap-metadata-modal'; +import { isSnapId } from '../../../../../helpers/utils/snaps'; export type ConfirmInfoRowUrlProps = { url: string; @@ -23,6 +26,28 @@ export type ConfirmInfoRowUrlProps = { export const ConfirmInfoRowUrl = ({ url }: ConfirmInfoRowUrlProps) => { let urlObject; + const [isModalOpen, setIsModalOpen] = useState(false); + const handlePillClick = useCallback( + () => setIsModalOpen(true), + [setIsModalOpen], + ); + const handleModalClose = useCallback( + () => setIsModalOpen(false), + [setIsModalOpen], + ); + + if (isSnapId(url)) { + return ( + <> + + + + ); + } try { urlObject = new URL(url); diff --git a/ui/components/app/snaps/snap-authorship-pill/index.scss b/ui/components/app/snaps/snap-authorship-pill/index.scss new file mode 100644 index 000000000000..6cc4f186046d --- /dev/null +++ b/ui/components/app/snaps/snap-authorship-pill/index.scss @@ -0,0 +1,7 @@ +.snap-authorship-pill { + cursor: pointer; + + &:hover { + background-color: var(--color-background-alternative); + } +} diff --git a/ui/components/app/snaps/snap-authorship-pill/index.ts b/ui/components/app/snaps/snap-authorship-pill/index.ts new file mode 100644 index 000000000000..14a023241bd0 --- /dev/null +++ b/ui/components/app/snaps/snap-authorship-pill/index.ts @@ -0,0 +1 @@ +export { default } from './snap-authorship-pill'; diff --git a/ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.stories.tsx b/ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.stories.tsx new file mode 100644 index 000000000000..0ec787c42887 --- /dev/null +++ b/ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.stories.tsx @@ -0,0 +1,20 @@ +import React from 'react'; +import SnapAuthorshipPill from './snap-authorship-pill' + +export default { + title: 'Components/App/Snaps/SnapAuthorshipPill', + component: SnapAuthorshipPill, + argTypes: { + snapId: { + control: 'text', + }, + }, +}; + +export const DefaultStory = (args) => ; + +DefaultStory.storyName = 'Default'; + +DefaultStory.args = { + snapId: 'npm:@metamask/test-snap-bip44', +}; diff --git a/ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.tsx b/ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.tsx new file mode 100644 index 000000000000..fd8831f36e0f --- /dev/null +++ b/ui/components/app/snaps/snap-authorship-pill/snap-authorship-pill.tsx @@ -0,0 +1,55 @@ +import React from 'react'; +import { useSelector } from 'react-redux'; +import { Box, IconSize, Text } from '../../../component-library'; +import { SnapIcon } from '../snap-icon'; +import { getSnapMetadata } from '../../../../selectors'; +import { + AlignItems, + BorderRadius, + Display, + FlexDirection, + TextColor, + TextVariant, +} from '../../../../helpers/constants/design-system'; + +type SnapAuthorshipPillProps = { + snapId: string; + onClick: () => void; +}; + +const SnapAuthorshipPill: React.FC = ({ + snapId, + onClick, +}) => { + const { name: snapName } = useSelector((state) => + // @ts-expect-error ts is picking up the wrong type for the selector + getSnapMetadata(state, snapId), + ); + + return ( + + + + {snapName} + + + ); +}; + +export default SnapAuthorshipPill;