Skip to content

Commit f6b8daa

Browse files
feat(checkout-widgets): Allow hide header on Swap widget (#2724)
Co-authored-by: priyaleedman <[email protected]>
1 parent 1a2d0e1 commit f6b8daa

File tree

5 files changed

+13
-4
lines changed

5 files changed

+13
-4
lines changed

packages/checkout/sdk/src/widgets/definitions/configurations/swap.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ import { WidgetConfiguration } from './widget';
66
export type SwapWidgetConfiguration = {
77
customTitle?: string;
88
customSubTitle?: string;
9+
showHeader?: boolean;
910
} & WidgetConfiguration;

packages/checkout/widgets-lib/src/widgets/swap/SwapWidget.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export default function SwapWidget({
7171
autoProceed,
7272
direction,
7373
showBackButton,
74-
swapConfig: { customTitle, customSubTitle },
74+
swapConfig: { customTitle, customSubTitle, showHeader },
7575
walletProviderName,
7676
}: SwapWidgetInputs) {
7777
const { t } = useTranslation();
@@ -260,6 +260,7 @@ export default function SwapWidget({
260260
fromTokenAddress={viewState.view.data?.fromTokenAddress ?? fromTokenAddress}
261261
toTokenAddress={viewState.view.data?.toTokenAddress ?? toTokenAddress}
262262
showBackButton={showBackButton}
263+
showHeader={showHeader ?? true}
263264
title={customTitle ?? t('views.SWAP.header.title')}
264265
subTitle={customSubTitle ?? t('views.SWAP.content.title')}
265266
/>

packages/checkout/widgets-lib/src/widgets/swap/SwapWidgetRoot.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ export class Swap extends Base<WidgetType.SWAP> {
110110
swapConfig={{
111111
customTitle: this.properties.config?.customTitle,
112112
customSubTitle: this.properties.config?.customSubTitle,
113+
showHeader: this.properties.config?.showHeader,
113114
}}
114115
/>
115116
</Suspense>

packages/checkout/widgets-lib/src/widgets/swap/views/SwapCoins.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface SwapCoinsProps {
3232
fromTokenAddress?: string;
3333
toTokenAddress?: string;
3434
showBackButton?: boolean;
35+
showHeader?: boolean;
3536
title: string;
3637
subTitle: string;
3738
}
@@ -44,6 +45,7 @@ export function SwapCoins({
4445
fromTokenAddress,
4546
toTokenAddress,
4647
showBackButton,
48+
showHeader,
4749
title,
4850
subTitle,
4951
}: SwapCoinsProps) {
@@ -90,7 +92,7 @@ export function SwapCoins({
9092

9193
return (
9294
<SimpleLayout
93-
header={!autoProceed ? (
95+
header={!autoProceed && showHeader ? (
9496
<HeaderNavigation
9597
title={title}
9698
onCloseButtonClick={() => sendSwapWidgetCloseEvent(eventTarget)}
@@ -103,7 +105,7 @@ export function SwapCoins({
103105
);
104106
}}
105107
/>
106-
) : ''}
108+
) : undefined}
107109
footer={<QuickswapFooter environment={checkout?.config.environment} theme={theme} />}
108110
>
109111
<Box

packages/checkout/widgets-sample-app/src/components/ui/checkout/checkout.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,14 @@ function CheckoutUI() {
288288
config: {
289289
theme,
290290
language,
291+
/*
292+
SWAP: {
293+
showHeader: true,
294+
},
295+
*/
291296
CONNECT: {
292297

293298
},
294-
// SWAP: {},
295299
TRANSFER: {
296300
customTitle: "Dromedary Transfer",
297301
},

0 commit comments

Comments
 (0)