Skip to content

Commit b14dec0

Browse files
committed
fix: token grid in chain page design
1 parent 679c456 commit b14dec0

File tree

4 files changed

+93
-3
lines changed

4 files changed

+93
-3
lines changed

src/components/CCIP/Cards/TokenCard.css

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,57 @@
5151
height: 124px;
5252
}
5353
}
54+
55+
/* Square variant styles */
56+
.token-card__square-container {
57+
display: flex;
58+
flex-direction: column;
59+
align-items: center;
60+
justify-content: center;
61+
width: 100%;
62+
background: var(--white);
63+
border: 1px solid var(--gray-200);
64+
border-radius: var(--space-1x);
65+
text-align: center;
66+
}
67+
68+
.token-card__square-container:hover {
69+
background-color: var(--gray-50);
70+
}
71+
72+
.token-card__square-logo {
73+
display: flex;
74+
align-items: center;
75+
justify-content: center;
76+
margin-bottom: var(--space-4x);
77+
}
78+
79+
.token-card__square-logo object,
80+
.token-card__square-logo object img {
81+
width: var(--space-16x);
82+
height: var(--space-16x);
83+
border-radius: 50%;
84+
}
85+
86+
.token-card__square-content {
87+
display: flex;
88+
flex-direction: column;
89+
align-items: center;
90+
}
91+
92+
.token-card__square-content h3 {
93+
font-size: var(--space-4x);
94+
font-weight: var(--font-weight-medium);
95+
line-height: var(--space-6x);
96+
color: var(--gray-950);
97+
margin-bottom: var(--space-1x);
98+
text-align: center;
99+
}
100+
101+
.token-card__square-content p {
102+
margin-bottom: 0;
103+
font-size: var(--space-3x);
104+
line-height: var(--space-5x);
105+
color: var(--gray-500);
106+
text-align: center;
107+
}

src/components/CCIP/Cards/TokenCard.tsx

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ interface TokenCardProps {
99
link?: string
1010
onClick?: () => void
1111
totalNetworks?: number
12+
variant?: "default" | "square"
1213
}
1314

14-
const TokenCard = memo(function TokenCard({ id, logo, link, onClick, totalNetworks }: TokenCardProps) {
15+
const TokenCard = memo(function TokenCard({ id, logo, link, onClick, totalNetworks, variant = "default" }: TokenCardProps) {
1516
const logoElement = (
1617
<object data={logo} type="image/png" aria-label={`${id} token logo`}>
1718
<img src={fallbackTokenIconUrl} alt={`${id} token logo`} loading="lazy" />
@@ -21,6 +22,36 @@ const TokenCard = memo(function TokenCard({ id, logo, link, onClick, totalNetwor
2122
const subtitle =
2223
totalNetworks !== undefined ? `${totalNetworks} ${totalNetworks === 1 ? "network" : "networks"}` : undefined
2324

25+
if (variant === "square") {
26+
const content = (
27+
<>
28+
<div className="token-card__square-logo">{logoElement}</div>
29+
<div className="token-card__square-content">
30+
<h3>{id}</h3>
31+
{subtitle && <p>{subtitle}</p>}
32+
</div>
33+
</>
34+
)
35+
36+
if (link) {
37+
return (
38+
<a href={link} aria-label={`View ${id} token details`}>
39+
<div className="token-card__square-container">{content}</div>
40+
</a>
41+
)
42+
}
43+
44+
if (onClick) {
45+
return (
46+
<button type="button" className="token-card__square-container" onClick={onClick} aria-label={`View ${id} token details`}>
47+
{content}
48+
</button>
49+
)
50+
}
51+
52+
return <div className="token-card__square-container">{content}</div>
53+
}
54+
2455
return (
2556
<Card
2657
logo={logoElement}

src/components/CCIP/Chain/Chain.astro

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,12 @@ const chainStructuredData = generateChainStructuredData(
187187
display: grid;
188188
--doc-padding: var(--space-10x);
189189
padding: var(--doc-padding) var(--space-8x);
190-
grid-template-columns: 1fr 1fr;
191-
gap: var(--space-24x);
190+
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
191+
gap: var(--space-8x);
192+
}
193+
194+
.layout > div {
195+
min-width: 0;
192196
}
193197

194198
.networks__grid {

src/components/CCIP/Chain/ChainTokenGrid.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ function ChainTokenGrid({ tokens, network, environment }: ChainTokenGridProps) {
3636
id={token.id}
3737
logo={token.logo}
3838
key={token.id}
39+
variant="square"
3940
onClick={() => {
4041
const selectedNetwork = Object.keys(data)
4142
.map((key) => {

0 commit comments

Comments
 (0)