Skip to content

Commit f39fd25

Browse files
polish direct payment screen ui
1 parent 8b24014 commit f39fd25

File tree

3 files changed

+222
-113
lines changed

3 files changed

+222
-113
lines changed

packages/thirdweb/src/react/web/ui/Bridge/DirectPayment.tsx

Lines changed: 165 additions & 112 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { FiatValue } from "../ConnectWallet/screens/Buy/swap/FiatValue.js";
1313
import type { PayEmbedConnectOptions } from "../PayEmbed.js";
1414
import { ChainName } from "../components/ChainName.js";
1515
import { Spacer } from "../components/Spacer.js";
16-
import { Container, Line, ModalHeader } from "../components/basic.js";
16+
import { Container, Line } from "../components/basic.js";
1717
import { Button } from "../components/buttons.js";
1818
import { Text } from "../components/text.js";
1919
import { ChainIcon } from "./TokenAndChain.js";
@@ -29,7 +29,8 @@ export interface DirectPaymentProps {
2929
feePayer?: "sender" | "receiver";
3030
metadata: {
3131
name: string;
32-
image: string;
32+
description?: string;
33+
image?: string;
3334
};
3435
};
3536

@@ -72,48 +73,65 @@ export function DirectPayment({
7273
const sellerAddress =
7374
ensName.data || shortenAddress(paymentInfo.sellerAddress);
7475

75-
return (
76-
<Container flex="column" p="lg">
77-
{/* Header with product name */}
78-
<ModalHeader title={paymentInfo.metadata.name} />
79-
80-
<Spacer y="lg" />
76+
const buyNow = (
77+
<Container flex="row" gap="3xs">
78+
<Text size="md" color="primaryButtonText">
79+
Buy Now ·
80+
</Text>
81+
<FiatValue
82+
tokenAmount={paymentInfo.amount}
83+
token={paymentInfo.token}
84+
chain={chain}
85+
client={client}
86+
color="primaryButtonText"
87+
size="md"
88+
/>
89+
</Container>
90+
);
8191

92+
return (
93+
<Container flex="column">
8294
{/* Product image */}
83-
<div
84-
style={{
85-
width: "100%",
86-
borderRadius: radius.lg,
87-
overflow: "hidden",
88-
aspectRatio: "4/3",
89-
backgroundColor: theme.colors.secondaryIconColor,
90-
backgroundImage: `url(${paymentInfo.metadata.image})`,
91-
backgroundSize: "cover",
92-
backgroundPosition: "center",
93-
border: `1px solid ${theme.colors.borderColor}`,
94-
}}
95-
/>
95+
{paymentInfo.metadata.image && (
96+
<div
97+
style={{
98+
width: "100%",
99+
borderRadius: `${radius.md} ${radius.md} 0 0`,
100+
overflow: "hidden",
101+
aspectRatio: "16/9",
102+
backgroundColor: theme.colors.secondaryIconColor,
103+
backgroundImage: `url(${paymentInfo.metadata.image})`,
104+
backgroundSize: "cover",
105+
backgroundPosition: "center",
106+
}}
107+
/>
108+
)}
109+
<Container flex="column" px="lg">
110+
<Spacer y="lg" />
96111

97-
<Spacer y="lg" />
98-
99-
{/* Price section */}
100-
<Container
101-
flex="row"
102-
style={{
103-
justifyContent: "space-between",
104-
}}
105-
>
106-
<Text size="md" color="secondaryText">
107-
Price
112+
{/* Header with product name */}
113+
<Text size="lg" color="primaryText" weight={700}>
114+
{paymentInfo.metadata.name}
108115
</Text>
116+
117+
<Spacer y="xs" />
118+
119+
{/* Description */}
120+
{paymentInfo.metadata.description && (
121+
<Text size="sm" color="secondaryText">
122+
{paymentInfo.metadata.description}
123+
</Text>
124+
)}
125+
126+
<Spacer y="lg" />
127+
128+
{/* Price section */}
109129
<Container
110-
flex="column"
111-
color="secondaryText"
130+
flex="row"
131+
center="y"
112132
gap="3xs"
113133
style={{
114-
alignItems: "flex-end",
115-
minWidth: 0,
116-
overflow: "hidden",
134+
justifyContent: "space-between",
117135
}}
118136
>
119137
<FiatValue
@@ -122,100 +140,135 @@ export function DirectPayment({
122140
chain={chain}
123141
client={client}
124142
color="primaryText"
125-
size="md"
126-
weight={600}
143+
size="xl"
144+
weight={700}
127145
/>
146+
<Container flex="row" gap="3xs">
147+
<Text
148+
size="xs"
149+
color="secondaryText"
150+
style={{
151+
overflow: "hidden",
152+
textOverflow: "ellipsis",
153+
whiteSpace: "nowrap",
154+
}}
155+
>
156+
One-time payment
157+
</Text>
158+
</Container>
159+
</Container>
160+
161+
<Spacer y="md" />
162+
163+
<Line />
164+
165+
<Spacer y="md" />
166+
167+
{/* Seller section */}
168+
<Container
169+
flex="row"
170+
style={{
171+
justifyContent: "space-between",
172+
alignItems: "center",
173+
}}
174+
>
175+
<Text size="sm" color="secondaryText">
176+
Sold by
177+
</Text>
128178
<Text
129-
size="xs"
130-
color="secondaryText"
179+
size="sm"
180+
color="primaryText"
131181
style={{
132-
overflow: "hidden",
133-
textOverflow: "ellipsis",
134-
whiteSpace: "nowrap",
182+
fontFamily: "monospace",
135183
}}
136184
>
137-
{`${paymentInfo.amount} ${paymentInfo.token.symbol}`}
185+
{sellerAddress}
138186
</Text>
139187
</Container>
140-
</Container>
141-
142-
<Spacer y="md" />
143188

144-
<Line />
189+
<Spacer y="xs" />
145190

146-
<Spacer y="md" />
147-
148-
{/* Seller section */}
149-
<Container
150-
flex="row"
151-
style={{
152-
justifyContent: "space-between",
153-
alignItems: "center",
154-
}}
155-
>
156-
<Text size="sm" color="secondaryText">
157-
Sold by
158-
</Text>
159-
<Text
160-
size="sm"
161-
color="primaryText"
191+
<Container
192+
flex="row"
162193
style={{
163-
fontFamily: "monospace",
194+
justifyContent: "space-between",
195+
alignItems: "center",
164196
}}
165197
>
166-
{sellerAddress}
167-
</Text>
168-
</Container>
169-
170-
<Spacer y="sm" />
171-
172-
{/* Network section */}
173-
<Container
174-
flex="row"
175-
style={{
176-
justifyContent: "space-between",
177-
alignItems: "center",
178-
}}
179-
>
180-
<Text size="sm" color="secondaryText">
181-
Network
182-
</Text>
183-
<Container flex="row" gap="3xs" center="y">
184-
<ChainIcon chain={chain} size={"xs"} client={client} />
185-
<ChainName
186-
chain={chain}
187-
client={client}
198+
<Text size="sm" color="secondaryText">
199+
Price
200+
</Text>
201+
<Text
188202
size="sm"
189203
color="primaryText"
190-
short
191-
/>
204+
style={{
205+
fontFamily: "monospace",
206+
}}
207+
>
208+
{`${paymentInfo.amount} ${paymentInfo.token.symbol}`}
209+
</Text>
192210
</Container>
193-
</Container>
194211

195-
<Spacer y="xl" />
196-
197-
{/* Action button */}
198-
{activeAccount ? (
199-
<Button variant="accent" fullWidth onClick={handleContinue}>
200-
Buy Now
201-
</Button>
202-
) : (
203-
<ConnectButton
204-
client={client}
205-
theme={theme}
206-
connectButton={{
207-
label: "Buy Now",
208-
style: {
209-
width: "100%",
210-
},
212+
<Spacer y="xs" />
213+
214+
{/* Network section */}
215+
<Container
216+
flex="row"
217+
style={{
218+
justifyContent: "space-between",
219+
alignItems: "center",
211220
}}
212-
{...connectOptions}
213-
/>
214-
)}
221+
>
222+
<Text size="sm" color="secondaryText">
223+
Network
224+
</Text>
225+
<Container flex="row" gap="3xs" center="y">
226+
<ChainIcon chain={chain} size={"xs"} client={client} />
227+
<ChainName
228+
chain={chain}
229+
client={client}
230+
size="sm"
231+
color="primaryText"
232+
short
233+
style={{
234+
fontFamily: "monospace",
235+
}}
236+
/>
237+
</Container>
238+
</Container>
239+
240+
<Spacer y="md" />
241+
242+
<Line />
215243

216-
<Spacer y="lg" />
244+
<Spacer y="lg" />
217245

218-
<PoweredByThirdweb />
246+
{/* Action button */}
247+
<Container flex="column">
248+
{activeAccount ? (
249+
<Button variant="primary" fullWidth onClick={handleContinue}>
250+
{buyNow}
251+
</Button>
252+
) : (
253+
<ConnectButton
254+
client={client}
255+
theme={theme}
256+
connectButton={{
257+
label: buyNow,
258+
style: {
259+
width: "100%",
260+
},
261+
}}
262+
{...connectOptions}
263+
/>
264+
)}
265+
266+
<Spacer y="md" />
267+
268+
<PoweredByThirdweb />
269+
<Spacer y="md" />
270+
</Container>
271+
</Container>
219272
</Container>
220273
);
221274
}

packages/thirdweb/src/react/web/ui/components/ChainName.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,13 @@ export const ChainName: React.FC<{
1414
color?: "primaryText" | "secondaryText";
1515
client: ThirdwebClient;
1616
short?: boolean;
17+
style?: React.CSSProperties;
1718
}> = (props) => {
1819
const { name } = useChainName(props.chain);
1920

2021
if (name) {
2122
return (
22-
<Text size={props.size} color={props.color}>
23+
<Text size={props.size} color={props.color} style={props.style}>
2324
{props.short ? shorterChainName(name) : name}
2425
</Text>
2526
);

0 commit comments

Comments
 (0)