Skip to content

Commit 7a9777a

Browse files
authored
Post-launch fixes for TokenWidget (#872)
* fix footer vertical alignement * sync footer line height * fix action button font inconsistency * fix sell tab init balance load * feat: changeset
1 parent 79c7548 commit 7a9777a

File tree

4 files changed

+53
-23
lines changed

4 files changed

+53
-23
lines changed

.changeset/early-comics-roll.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@relayprotocol/relay-kit-ui': patch
3+
---
4+
5+
Post-launch fixes for `TokenWidget`

packages/ui/src/components/widgets/SwapButton.tsx

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,9 @@ const SwapButton: FC<SwapButtonProps> = ({
9898
css={{
9999
justifyContent: 'center',
100100
width: tokenWidgetMode ? '100%' : undefined,
101-
textTransform:
102-
tokenWidgetMode && (context === 'Buy' || context === 'Sell')
103-
? 'uppercase'
104-
: 'none',
105-
fontFamily: tokenWidgetMode ? 'heading' : undefined,
106-
fontWeight: tokenWidgetMode ? 700 : undefined,
107-
fontStyle: tokenWidgetMode
108-
? 'var(--relay-fonts-button-cta-font-style, italic)'
109-
: undefined
101+
...(!tokenWidgetMode && {
102+
textTransform: 'none'
103+
})
110104
}}
111105
color={showHighPriceImpactWarning ? 'error' : 'primary'}
112106
aria-label={context}
@@ -130,15 +124,9 @@ const SwapButton: FC<SwapButtonProps> = ({
130124
css={{
131125
justifyContent: 'center',
132126
width: tokenWidgetMode ? '100%' : undefined,
133-
textTransform:
134-
tokenWidgetMode && (context === 'Buy' || context === 'Sell')
135-
? 'uppercase'
136-
: 'none',
137-
fontFamily: tokenWidgetMode ? 'heading' : undefined,
138-
fontWeight: tokenWidgetMode ? 700 : undefined,
139-
fontStyle: tokenWidgetMode
140-
? 'var(--relay-fonts-button-cta-font-style, italic)'
141-
: undefined
127+
...(!tokenWidgetMode && {
128+
textTransform: 'none'
129+
})
142130
}}
143131
aria-label="Connect wallet"
144132
onClick={() => {

packages/ui/src/components/widgets/TokenWidget/TransactionDetailsFooter.tsx

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,21 @@ const TransactionDetailsFooter: FC<TransactionDetailsFooterProps> = ({
4949
{timeEstimate && timeEstimate.time !== 0 ? (
5050
<>
5151
<Flex align="center" css={{ gap: '2' }}>
52-
<Box css={{ color: clockColor, width: 14, height: 14 }}>
52+
<Box
53+
css={{
54+
color: clockColor,
55+
width: 14,
56+
height: 14,
57+
display: 'flex',
58+
alignItems: 'center',
59+
justifyContent: 'center'
60+
}}
61+
>
5362
<FontAwesomeIcon icon={faClock} />
5463
</Box>
55-
<Text style="subtitle3">{timeLabel}</Text>
64+
<Text style="subtitle3" css={{ lineHeight: 'normal' }}>
65+
{timeLabel}
66+
</Text>
5667
</Flex>
5768
{showDivider ? (
5869
<Flex
@@ -67,10 +78,21 @@ const TransactionDetailsFooter: FC<TransactionDetailsFooterProps> = ({
6778
) : null}
6879
{hasNetworkCost ? (
6980
<Flex align="center" css={{ gap: '2' }}>
70-
<Box css={{ color: 'gray9', width: 14, height: 14 }}>
81+
<Box
82+
css={{
83+
color: 'gray9',
84+
width: 14,
85+
height: 14,
86+
display: 'flex',
87+
alignItems: 'center',
88+
justifyContent: 'center'
89+
}}
90+
>
7191
<FontAwesomeIcon icon={faGasPump} />
7292
</Box>
73-
<Text style="subtitle3">{networkCostLabel}</Text>
93+
<Text style="subtitle3" css={{ lineHeight: 'normal' }}>
94+
{networkCostLabel}
95+
</Text>
7496
</Flex>
7597
) : null}
7698
</Flex>

packages/ui/src/components/widgets/TokenWidget/widget/index.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Flex, Button, Text } from '../../../primitives/index.js'
1+
import { Flex, Text } from '../../../primitives/index.js'
22
import { TabsRoot, TabsList, TabsTrigger } from '../../../primitives/Tabs.js'
33
import {
44
useCallback,
@@ -603,6 +603,21 @@ const TokenWidget: FC<TokenWidgetProps> = ({
603603
// Get public client for the fromChain to estimate gas
604604
const publicClient = usePublicClient({ chainId: fromChain?.id })
605605

606+
// Seed fromToken on sell tab if empty but we have a token available
607+
useEffect(() => {
608+
if (activeTab !== 'sell') return
609+
if (fromToken) return
610+
611+
const candidateFromToken =
612+
tabTokenStateRef.current.sell?.fromToken ??
613+
tabTokenStateRef.current.buy?.toToken ??
614+
toToken
615+
616+
if (candidateFromToken) {
617+
handleSetFromToken(candidateFromToken)
618+
}
619+
}, [activeTab, fromToken, toToken, handleSetFromToken])
620+
606621
useWalletGuards({
607622
multiWalletSupportEnabled,
608623
allowUnsupportedOrigin,

0 commit comments

Comments
 (0)