Skip to content

Commit 4856a95

Browse files
authored
Merge pull request #425 from WalletConnect/feat/redirect-to-domain-on-click-in-topic-header
redirect to domain on click
2 parents 393c689 + 4f20a53 commit 4856a95

File tree

6 files changed

+59
-43
lines changed

6 files changed

+59
-43
lines changed

src/components/general/Icon/ArrowRightTopIcon.tsx

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,13 @@ import React from 'react'
22

33
const ArrowRightTopIcon: React.FC<React.SVGProps<SVGSVGElement>> = props => {
44
return (
5-
<svg
6-
xmlns="http://www.w3.org/2000/svg"
7-
width="16"
8-
height="17"
9-
viewBox="0 0 16 17"
10-
fill="none"
11-
{...props}
12-
>
13-
<g clipPath="url(#clip0_4498_48131)">
14-
<path
15-
d="M11.3012 5.19971L4.70117 11.7997"
16-
stroke="currentColor"
17-
strokeWidth="1.25"
18-
strokeLinecap="round"
19-
strokeLinejoin="round"
20-
/>
21-
<path
22-
d="M6 5.19922L11.2993 5.19932V10.5"
23-
stroke="currentColor"
24-
strokeWidth="1.25"
25-
strokeLinecap="round"
26-
strokeLinejoin="round"
27-
/>
28-
</g>
29-
<defs>
30-
<clipPath id="clip0_4498_48131">
31-
<rect width="16" height="16" fill="white" transform="translate(0 0.5)" />
32-
</clipPath>
33-
</defs>
5+
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
6+
<path
7+
fill-rule="evenodd"
8+
clip-rule="evenodd"
9+
d="M2.67029 2.14284C2.67029 1.74835 2.99009 1.42856 3.38457 1.42856H7.85648C8.25097 1.42856 8.57077 1.74835 8.57077 2.14284V6.61475C8.57077 7.00924 8.25097 7.32904 7.85648 7.32904C7.462 7.32904 7.1422 7.00924 7.1422 6.61475V3.86796L2.64795 8.36221C2.36901 8.64115 1.91674 8.64115 1.6378 8.36221C1.35885 8.08326 1.35885 7.631 1.6378 7.35205L6.13272 2.85713H3.38457C2.99009 2.85713 2.67029 2.53733 2.67029 2.14284Z"
10+
fill="currentColor"
11+
/>
3412
</svg>
3513
)
3614
}

src/components/notifications/AppExplorer/AppCard/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const AppCard: React.FC<AppCardProps> = ({
4040
const { activeSubscriptions } = useContext(W3iContext)
4141

4242
const host = new URL(url).host
43+
const projectURL = new URL(url)
4344

4445
useEffect(() => {
4546
// If the account changes, the subscribing flow has broken.
@@ -49,8 +50,6 @@ const AppCard: React.FC<AppCardProps> = ({
4950
const subscribed =
5051
userPubkey &&
5152
activeSubscriptions.some(element => {
52-
const projectURL = new URL(url)
53-
5453
return projectURL.hostname === element.metadata.appDomain
5554
})
5655
const logoURL = logo || '/fallback.svg'

src/components/notifications/AppNotifications/AppNotifications.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@
199199
color: var(--accent-color-1);
200200
display: none;
201201
align-items: center;
202+
gap: 0.125rem;
202203

203204
span {
204205
color: var(--accent-color-1);
@@ -214,7 +215,7 @@
214215
color: var(--fg-color-1);
215216
display: flex;
216217
align-items: center;
217-
gap: 2px;
218+
gap: 0.125rem;
218219

219220
&__external-link-icon {
220221
display: inline-block;

src/components/notifications/AppNotifications/AppNotificationsHeader/AppNotificationsHeader.scss

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,22 @@
7777
-webkit-box-orient: vertical;
7878
-webkit-line-clamp: 1;
7979
}
80-
&__description {
80+
&__link {
8181
color: var(--fg-color-2);
82-
82+
text-decoration: none;
83+
display: flex;
84+
align-items: center;
8385
overflow: hidden;
84-
display: -webkit-box;
85-
-webkit-box-orient: vertical;
86-
-webkit-line-clamp: 1;
86+
gap: 0.125rem;
87+
88+
svg {
89+
display: inline-block;
90+
}
91+
92+
&:hover {
93+
color: var(--fg-color-2);
94+
filter: brightness(0.9);
95+
}
8796
}
8897
}
8998
&__actions {

src/components/notifications/AppNotifications/AppNotificationsHeader/index.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { useContext, useState } from 'react'
1+
import { useContext } from 'react'
2+
3+
import { Link } from 'react-router-dom'
24

35
import BackButton from '@/components/general/BackButton'
46
import Button from '@/components/general/Button'
7+
import ArrowRightTopIcon from '@/components/general/Icon/ArrowRightTopIcon'
58
import Text from '@/components/general/Text'
69
import W3iContext from '@/contexts/W3iContext/context'
710
import { noop } from '@/utils/general'
811
import { useIsMobile } from '@/utils/hooks'
12+
import getDomainHref from '@/utils/url'
913

1014
import AppNotificationDropdown from '../AppNotificationDropdown'
1115

@@ -17,6 +21,7 @@ interface IAppNotificationsHeaderProps {
1721
name: string
1822
domain: string
1923
}
24+
2025
const AppNotificationsHeader: React.FC<IAppNotificationsHeaderProps> = ({
2126
domain,
2227
logo,
@@ -25,7 +30,7 @@ const AppNotificationsHeader: React.FC<IAppNotificationsHeaderProps> = ({
2530
}) => {
2631
const isMobile = useIsMobile()
2732
const { dappOrigin } = useContext(W3iContext)
28-
const [dropdownToShow, setDropdownToShow] = useState<string | undefined>()
33+
const href = getDomainHref(domain)
2934

3035
return (
3136
<div className="AppNotificationsHeader">
@@ -53,18 +58,26 @@ const AppNotificationsHeader: React.FC<IAppNotificationsHeaderProps> = ({
5358
/>
5459
<div className="AppNotificationsHeader__app__name_container">
5560
<h2 className="AppNotificationsHeader__app__name">{name}</h2>
56-
<Text variant="link-500" className="AppNotificationsHeader__app__description">
57-
{domain}
58-
</Text>
61+
<Link
62+
to={href}
63+
className="AppNotificationsHeader__app__link"
64+
target="_blank"
65+
rel="noopener noreferrer"
66+
>
67+
<Text variant="link-500">{domain}</Text>
68+
<div>
69+
<ArrowRightTopIcon />
70+
</div>
71+
</Link>
5972
</div>
6073
</div>
6174
<div className="AppNotificationsHeader__wrapper">
6275
<AppNotificationDropdown
63-
closeDropdown={() => setDropdownToShow(undefined)}
6476
h="2.5em"
6577
w="2.5em"
6678
notificationId={id}
6779
dropdownPlacement="bottomLeft"
80+
closeDropdown={noop}
6881
/>
6982
</div>
7083
</>

src/utils/url.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export const PROTOCOL = 'https://'
2+
3+
/**
4+
* Returns the full URL of the given domain
5+
* @param domain
6+
* @return Href value - string
7+
*/
8+
export default function getDomainHref(domain: string): string {
9+
if (!domain) {
10+
throw new Error('Domain is required')
11+
}
12+
13+
const url = new URL(PROTOCOL + domain)
14+
15+
return url.href
16+
}

0 commit comments

Comments
 (0)