Skip to content

Commit 67f4765

Browse files
committed
feat: add WalletSocialLinks component
1 parent bc86184 commit 67f4765

File tree

2 files changed

+126
-109
lines changed

2 files changed

+126
-109
lines changed

src/components/FindWallet/WalletTable/WalletMoreInfo.tsx

Lines changed: 4 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,11 @@
11
import { useRouter } from "next/router"
22
import { useTranslation } from "next-i18next"
3-
import { FaDiscord, FaGlobe, FaTwitter } from "react-icons/fa"
4-
import {
5-
Box,
6-
Flex,
7-
Heading,
8-
Icon,
9-
SimpleGrid,
10-
Stack,
11-
Text,
12-
} from "@chakra-ui/react"
3+
import { Box, Flex, SimpleGrid } from "@chakra-ui/react"
134

14-
import { DropdownOption, Lang, WalletFilter } from "@/lib/types"
15-
16-
import InlineLink, { LinkProps } from "@/components/Link"
17-
18-
import { getLocaleFormattedDate } from "@/lib/utils/time"
5+
import { DropdownOption, WalletFilter } from "@/lib/types"
196

207
import { WalletMoreInfoCategory } from "./WalletMoreInfoCategory"
8+
import { WalletSocialLinks } from "./WalletSocialLinks"
219

2210
type WalletMoreInfoProps = {
2311
wallet: Record<string, any>
@@ -27,21 +15,6 @@ type WalletMoreInfoProps = {
2715
hasAllLabels: boolean
2816
}
2917

30-
const SocialLink = (props: LinkProps) => (
31-
<InlineLink
32-
display="flex"
33-
height={8}
34-
alignItems="center"
35-
verticalAlign="middle"
36-
transform="scale(1)"
37-
transition="transform 0.1s"
38-
_hover={{
39-
transform: "scale(1.15)",
40-
}}
41-
{...props}
42-
/>
43-
)
44-
4518
export const WalletMoreInfo = ({
4619
wallet,
4720
filters,
@@ -81,12 +54,6 @@ export const WalletMoreInfo = ({
8154
},
8255
]
8356

84-
// Format last updated date with current locale
85-
const walletLastUpdated = getLocaleFormattedDate(
86-
locale as Lang,
87-
wallet.last_updated
88-
)
89-
9057
return (
9158
<Box mt={4} w="full">
9259
<SimpleGrid
@@ -124,79 +91,7 @@ export const WalletMoreInfo = ({
12491
</Flex>
12592

12693
{/* Links section */}
127-
<Stack
128-
as={Text}
129-
fontSize="sm"
130-
justifyContent="space-between"
131-
wrap="wrap"
132-
alignItems="flex-start"
133-
mt={6}
134-
mb={8}
135-
spacing={4}
136-
>
137-
{/* Social icons */}
138-
<Heading
139-
as="h4"
140-
lineHeight={1.4}
141-
fontSize="md"
142-
fontWeight="bold"
143-
ms={{ lg: 2 }}
144-
my={-3.5}
145-
>
146-
{t("page-find-wallet-social-links")}
147-
</Heading>
148-
149-
<Flex ms={{ lg: 2 }} gap="0.8rem">
150-
<SocialLink
151-
to={wallet.url}
152-
hideArrow
153-
customEventOptions={{
154-
eventCategory: "WalletExternalLinkList",
155-
eventAction: `Go to wallet`,
156-
eventName: `Website: ${wallet.name} ${idx}`,
157-
eventValue: JSON.stringify(filters),
158-
}}
159-
>
160-
<Icon as={FaGlobe} fontSize="2xl" />
161-
</SocialLink>
162-
163-
{wallet.discord && (
164-
<SocialLink
165-
to={wallet.discord}
166-
hideArrow
167-
customEventOptions={{
168-
eventCategory: "WalletExternalLinkList",
169-
eventAction: `Go to wallet`,
170-
eventName: `Discord: ${wallet.name} ${idx}`,
171-
eventValue: JSON.stringify(filters),
172-
}}
173-
>
174-
<Icon as={FaDiscord} color="#7289da" fontSize="2xl" />
175-
</SocialLink>
176-
)}
177-
178-
{wallet.twitter && (
179-
<SocialLink
180-
to={wallet.twitter}
181-
hideArrow
182-
customEventOptions={{
183-
eventCategory: "WalletExternalLinkList",
184-
eventAction: `Go to wallet`,
185-
eventName: `Twitter: ${wallet.name} ${idx}`,
186-
eventValue: JSON.stringify(filters),
187-
}}
188-
>
189-
<Icon as={FaTwitter} color="#1da1f2" fontSize="2xl" />
190-
</SocialLink>
191-
)}
192-
</Flex>
193-
194-
<Text as="i">
195-
{`${wallet.name} ${t(
196-
"page-find-wallet-info-updated-on"
197-
)} ${walletLastUpdated}`}
198-
</Text>
199-
</Stack>
94+
<WalletSocialLinks wallet={wallet} idx={idx} filters={filters} />
20095
</Box>
20196
</SimpleGrid>
20297
</Box>
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
import { useRouter } from "next/router"
2+
import { useTranslation } from "next-i18next"
3+
import { FaDiscord, FaGlobe, FaTwitter } from "react-icons/fa"
4+
import { Flex, Heading, Icon, Stack, Text } from "@chakra-ui/react"
5+
6+
import { Lang, WalletFilter } from "@/lib/types"
7+
8+
import InlineLink, { LinkProps } from "@/components/Link"
9+
10+
import { getLocaleFormattedDate } from "@/lib/utils/time"
11+
12+
type WalletSocialLinksProps = {
13+
wallet: Record<string, any>
14+
idx: number
15+
filters: WalletFilter
16+
}
17+
18+
const SocialLink = (props: LinkProps) => (
19+
<InlineLink
20+
display="flex"
21+
height={8}
22+
alignItems="center"
23+
verticalAlign="middle"
24+
transform="scale(1)"
25+
transition="transform 0.1s"
26+
_hover={{
27+
transform: "scale(1.15)",
28+
}}
29+
{...props}
30+
/>
31+
)
32+
33+
export const WalletSocialLinks = ({
34+
wallet,
35+
idx,
36+
filters,
37+
}: WalletSocialLinksProps) => {
38+
const { t } = useTranslation("page-wallets-find-wallet")
39+
const { locale } = useRouter()
40+
41+
// Format last updated date with current locale
42+
const walletLastUpdated = getLocaleFormattedDate(
43+
locale as Lang,
44+
wallet.last_updated
45+
)
46+
47+
return (
48+
<Stack
49+
as={Text}
50+
fontSize="sm"
51+
justifyContent="space-between"
52+
wrap="wrap"
53+
alignItems="flex-start"
54+
mt={6}
55+
mb={8}
56+
spacing={4}
57+
>
58+
{/* Social icons */}
59+
<Heading
60+
as="h4"
61+
lineHeight={1.4}
62+
fontSize="md"
63+
fontWeight="bold"
64+
ms={{ lg: 2 }}
65+
my={-3.5}
66+
>
67+
{t("page-find-wallet-social-links")}
68+
</Heading>
69+
70+
<Flex ms={{ lg: 2 }} gap="0.8rem">
71+
<SocialLink
72+
to={wallet.url}
73+
hideArrow
74+
customEventOptions={{
75+
eventCategory: "WalletExternalLinkList",
76+
eventAction: `Go to wallet`,
77+
eventName: `Website: ${wallet.name} ${idx}`,
78+
eventValue: JSON.stringify(filters),
79+
}}
80+
>
81+
<Icon as={FaGlobe} fontSize="2xl" />
82+
</SocialLink>
83+
84+
{wallet.discord && (
85+
<SocialLink
86+
to={wallet.discord}
87+
hideArrow
88+
customEventOptions={{
89+
eventCategory: "WalletExternalLinkList",
90+
eventAction: `Go to wallet`,
91+
eventName: `Discord: ${wallet.name} ${idx}`,
92+
eventValue: JSON.stringify(filters),
93+
}}
94+
>
95+
<Icon as={FaDiscord} color="#7289da" fontSize="2xl" />
96+
</SocialLink>
97+
)}
98+
99+
{wallet.twitter && (
100+
<SocialLink
101+
to={wallet.twitter}
102+
hideArrow
103+
customEventOptions={{
104+
eventCategory: "WalletExternalLinkList",
105+
eventAction: `Go to wallet`,
106+
eventName: `Twitter: ${wallet.name} ${idx}`,
107+
eventValue: JSON.stringify(filters),
108+
}}
109+
>
110+
<Icon as={FaTwitter} color="#1da1f2" fontSize="2xl" />
111+
</SocialLink>
112+
)}
113+
</Flex>
114+
115+
<Text as="i">
116+
{`${wallet.name} ${t(
117+
"page-find-wallet-info-updated-on"
118+
)} ${walletLastUpdated}`}
119+
</Text>
120+
</Stack>
121+
)
122+
}

0 commit comments

Comments
 (0)