Skip to content

Commit 6901a41

Browse files
committed
feat(react): adds tab icons to connect ui transactions page (#3844)
![Screenshot 2024-07-27 at 2.07.20 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/G5kV6fAq4H1wu10SVop6/006213aa-0e02-4b06-a3ec-335bcbb91069.png) ![Screenshot 2024-07-27 at 2.07.25 PM.png](https://graphite-user-uploaded-assets-prod.s3.amazonaws.com/G5kV6fAq4H1wu10SVop6/acc841ae-cd8d-4e02-942c-4872aa2b4c2c.png) ### TL;DR Improved the TransactionsScreen UI in the thirdweb package by adding new icons for better visualization and adjusted some layout styles for uniformity. ### What changed? - Added CoinsIcon and FundsIcon for better tab representation in TransactionsScreen.tsx. - Updated Tabs component to support labels with React nodes. - Implemented padding and minHeight adjustments in BuyTxHistory and WalletTransactionHistory components. - Conditionally rendered transaction history buttons only when transactions are available. ### How to test? 1. Navigate to the TransactionsScreen in the thirdweb package. 2. Verify that the tabs now display icons alongside text labels. 3. Check the layout adjustments in the transaction history components for proper spacing and padding. ### Why make this change? To enhance the user experience by improving the visual representation of tabs and ensuring consistency in the layout of transaction history components. ---
1 parent d775333 commit 6901a41

File tree

4 files changed

+64
-31
lines changed

4 files changed

+64
-31
lines changed

packages/thirdweb/src/react/web/ui/ConnectWallet/TransactionsScreen.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import { Spacer } from "../components/Spacer.js";
1313
import Tabs from "../components/Tabs.js";
1414
import { Container, Line, ModalHeader } from "../components/basic.js";
1515
import { ButtonLink } from "../components/buttons.js";
16+
import { CoinsIcon } from "./icons/CoinsIcon.js";
17+
import { FundsIcon } from "./icons/FundsIcon.js";
1618
import type { ConnectLocale } from "./locale/types.js";
1719
import { PayTxHistoryList } from "./screens/Buy/pay-transactions/BuyTxHistory.js";
1820
import { TxDetailsScreen } from "./screens/Buy/pay-transactions/TxDetailsScreen.js";
@@ -82,7 +84,24 @@ export function TransactionsScreen(props: {
8284
>
8385
<Spacer y="md" />
8486
<Tabs
85-
options={["Transactions", "Purchases"]}
87+
options={[
88+
{
89+
label: (
90+
<span className="flex gap-2">
91+
<CoinsIcon size={iconSize.sm} /> Transactions
92+
</span>
93+
),
94+
value: "Transactions",
95+
},
96+
{
97+
label: (
98+
<span className="flex gap-2">
99+
<FundsIcon size={iconSize.sm} /> Purchases
100+
</span>
101+
),
102+
value: "Purchases",
103+
},
104+
]}
86105
selected={activeTab}
87106
onSelect={setActiveTab}
88107
>

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/Buy/pay-transactions/BuyTxHistory.tsx

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ export function PayTxHistoryList(props: {
128128
width: "100%",
129129
minHeight: "250px",
130130
maxHeight: "370px",
131+
paddingBottom: spacing.lg,
131132
}}
132133
>
133134
<Container flex="column" gap="xs" expand>
@@ -158,24 +159,26 @@ export function PayTxHistoryList(props: {
158159
</Container>
159160
)}
160161

161-
<Container animate="fadein" flex="column" gap="xs">
162-
{txInfosToShow.map((txInfo) => {
163-
return (
164-
<BuyTxHistoryButton
165-
key={
166-
txInfo.type === "swap"
167-
? txInfo.status.source?.transactionHash
168-
: txInfo.status.intentId
169-
}
170-
txInfo={txInfo}
171-
client={props.client}
172-
onClick={() => {
173-
props.onSelectTx(txInfo);
174-
}}
175-
/>
176-
);
177-
})}
178-
</Container>
162+
{txInfosToShow.length > 0 && (
163+
<Container animate="fadein" flex="column" gap="xs">
164+
{txInfosToShow.map((txInfo) => {
165+
return (
166+
<BuyTxHistoryButton
167+
key={
168+
txInfo.type === "swap"
169+
? txInfo.status.source?.transactionHash
170+
: txInfo.status.intentId
171+
}
172+
txInfo={txInfo}
173+
client={props.client}
174+
onClick={() => {
175+
props.onSelectTx(txInfo);
176+
}}
177+
/>
178+
);
179+
})}
180+
</Container>
181+
)}
179182

180183
{isLoading && txInfosToShow.length > 0 && (
181184
<>
@@ -186,8 +189,8 @@ export function PayTxHistoryList(props: {
186189
)}
187190
</Container>
188191

189-
<Container py="lg">
190-
{pagination && !hidePagination && (
192+
{pagination && !hidePagination && (
193+
<Container py="md">
191194
<div
192195
style={{
193196
display: "grid",
@@ -234,8 +237,8 @@ export function PayTxHistoryList(props: {
234237
<ArrowRightIcon width={iconSize.sm} height={iconSize.sm} />
235238
</Button>
236239
</div>
237-
)}
238-
</Container>
240+
</Container>
241+
)}
239242
</Container>
240243
);
241244
}

packages/thirdweb/src/react/web/ui/ConnectWallet/screens/WalletTransactionHistory.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export function WalletTransactionHistory(props: {
4646
fullHeight
4747
style={{
4848
minHeight: "250px",
49-
maxHeight: "350px",
49+
maxHeight: "370px",
5050
paddingBottom: spacing.lg,
5151
}}
5252
>
@@ -59,13 +59,19 @@ export function WalletTransactionHistory(props: {
5959
color="secondaryText"
6060
style={{
6161
flex: "1",
62+
minHeight: "250px",
6263
}}
6364
>
6465
<CrossCircledIcon width={iconSize.xl} height={iconSize.xl} />
6566
<Text>No Transactions</Text>
6667
</Container>
6768
) : (
68-
<Container animate="fadein" flex="column" gap="xs">
69+
<Container
70+
animate="fadein"
71+
flex="column"
72+
gap="xs"
73+
style={{ minHeight: "250px" }}
74+
>
6975
{transactions.map((tx) => {
7076
return (
7177
<TransactionButton

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type React from "react";
12
import { useCustomTheme } from "../../../core/design-system/CustomThemeProvider.js";
23
import { radius, spacing } from "../../../core/design-system/index.js";
34
import { Text } from "../components/text.js";
@@ -13,7 +14,7 @@ export default function Tabs({
1314
}: {
1415
selected: string;
1516
onSelect: (selected: string) => void;
16-
options: string[];
17+
options: { label: React.ReactNode; value: string }[];
1718
children: React.ReactNode;
1819
}) {
1920
const theme = useCustomTheme();
@@ -30,8 +31,8 @@ export default function Tabs({
3031
<Button
3132
variant="accent"
3233
type="button"
33-
key={option}
34-
onClick={() => onSelect(option)}
34+
key={option.value}
35+
onClick={() => onSelect(option.value)}
3536
style={{
3637
flex: 1,
3738
paddingBlock: spacing.sm,
@@ -41,15 +42,19 @@ export default function Tabs({
4142
position: "relative",
4243
borderRadius: radius.md,
4344
backgroundColor:
44-
option === selected ? theme.colors.modalBg : "transparent",
45+
option.value === selected
46+
? theme.colors.modalBg
47+
: "transparent",
4548
}}
4649
>
4750
<Text
48-
color={option === selected ? "primaryText" : "secondaryText"}
51+
color={
52+
option.value === selected ? "primaryText" : "secondaryText"
53+
}
4954
style={{ textAlign: "center" }}
5055
size="sm"
5156
>
52-
{option}
57+
{option.label}
5358
</Text>
5459
</Button>
5560
))}

0 commit comments

Comments
 (0)