Skip to content

Commit 889d297

Browse files
committed
Custom titles
1 parent 1047ecf commit 889d297

8 files changed

Lines changed: 21 additions & 28 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import { WidgetConfiguration } from './widget';
44
* Swap Widget Configuration represents the configuration options for the Swap Widget.
55
*/
66
export type SwapWidgetConfiguration = {
7-
showTitle?: boolean;
8-
showSubTitle?: boolean;
7+
customTitle?: string;
8+
customSubTitle?: string;
99
} & WidgetConfiguration;

packages/checkout/widgets-lib/src/widgets/immutable-commerce/CommerceWidget.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,8 @@ export default function CommerceWidget(props: CommerceWidgetInputs) {
315315
{view.type === CommerceFlowType.SWAP && (
316316
<SwapWidget
317317
config={widgetsConfig}
318-
swapConfig={{
319-
showTitle: true,
320-
showSubTitle: true,
321-
...view.data.config,
322-
}}
318+
swapConfig={view.data.config}
323319
{...(view.data.params || {})}
324-
{...(view.data.config || {})}
325320
showBackButton={showBackButton}
326321
/>
327322
)}

packages/checkout/widgets-lib/src/widgets/sale/components/FundingRouteExecute/FundingRouteExecute.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export function FundingRouteExecute({
319319
<BridgeWidget {...bridgeParams!} config={config} checkout={checkout!} />
320320
)}
321321
{view === FundingRouteExecuteViews.EXECUTE_SWAP && (
322-
<SwapWidget {...swapParams!} config={config} swapConfig={{ showTitle: true, showSubTitle: true }} />
322+
<SwapWidget {...swapParams!} config={config} swapConfig={{}} />
323323
)}
324324
{view === FundingRouteExecuteViews.EXECUTE_ON_RAMP && (
325325
<OnRampWidget config={config} {...onRampParams} />

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
TokenFilterTypes, IMTBLWidgetEvents, SwapWidgetParams,
1111
SwapDirection,
1212
WalletProviderName,
13+
SwapWidgetConfiguration,
1314
} from '@imtbl/checkout-sdk';
1415
import { useTranslation } from 'react-i18next';
1516
import { SwapCoins } from './views/SwapCoins';
@@ -59,7 +60,7 @@ import { GeoblockLoader } from './GeoblockLoader';
5960

6061
export type SwapWidgetInputs = SwapWidgetParams & {
6162
config: StrongCheckoutWidgetsConfig;
62-
swapConfig: { showTitle: boolean; showSubTitle: boolean };
63+
swapConfig: SwapWidgetConfiguration;
6364
};
6465

6566
export default function SwapWidget({
@@ -70,7 +71,7 @@ export default function SwapWidget({
7071
autoProceed,
7172
direction,
7273
showBackButton,
73-
swapConfig: { showTitle, showSubTitle },
74+
swapConfig: { customTitle, customSubTitle },
7475
walletProviderName,
7576
}: SwapWidgetInputs) {
7677
const { t } = useTranslation();
@@ -259,8 +260,8 @@ export default function SwapWidget({
259260
fromTokenAddress={viewState.view.data?.fromTokenAddress ?? fromTokenAddress}
260261
toTokenAddress={viewState.view.data?.toTokenAddress ?? toTokenAddress}
261262
showBackButton={showBackButton}
262-
showTitle={showTitle}
263-
showSubTitle={showSubTitle}
263+
title={customTitle ?? t('views.SWAP.header.title')}
264+
subTitle={customSubTitle ?? t('views.SWAP.content.title')}
264265
/>
265266
)}
266267
{viewState.view.type === SwapWidgetViews.IN_PROGRESS && (

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ export class Swap extends Base<WidgetType.SWAP> {
107107
showBackButton={this.parameters.showBackButton}
108108
walletProviderName={this.parameters.walletProviderName}
109109
swapConfig={{
110-
showTitle: this.properties.config?.showTitle ?? true,
111-
showSubTitle: this.properties.config?.showSubTitle ?? true,
110+
customTitle: this.properties.config?.customTitle,
111+
customSubTitle: this.properties.config?.customSubTitle,
112112
}}
113113
/>
114114
</Suspense>

packages/checkout/widgets-lib/src/widgets/swap/components/SwapForm.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export interface SwapFromProps {
7878
data?: SwapFormData;
7979
theme: WidgetTheme;
8080
cancelAutoProceed: () => void;
81-
showSubTitle: boolean;
81+
subTitle: string;
8282
}
8383

8484
class PriceImpactError extends Error {
@@ -89,7 +89,7 @@ class PriceImpactError extends Error {
8989
}
9090

9191
export function SwapForm({
92-
data, theme, cancelAutoProceed, showSubTitle,
92+
data, theme, cancelAutoProceed, subTitle,
9393
}: SwapFromProps) {
9494
const { t } = useTranslation();
9595
const {
@@ -109,7 +109,6 @@ export function SwapForm({
109109
? NATIVE
110110
: `${symbol.toLowerCase()}-${address!.toLowerCase()}`), []);
111111

112-
// const { cryptoFiatState, cryptoFiatDispatch } = useContext(CryptoFiatContext);
113112
const { conversions: usdConversions } = useCryptoUSDConversion(checkout?.config.environment);
114113
const { viewDispatch } = useContext(ViewContext);
115114

@@ -942,13 +941,13 @@ export function SwapForm({
942941
marginBottom: 'base.spacing.x2',
943942
}}
944943
>
945-
{showSubTitle ? (
944+
{subTitle !== '' ? (
946945
<Heading
947946
size="small"
948947
weight="regular"
949948
sx={{ paddingBottom: 'base.spacing.x4' }}
950949
>
951-
{t('views.SWAP.content.title')}
950+
{subTitle}
952951
</Heading>
953952
) : null}
954953
<Box

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ export interface SwapCoinsProps {
3232
fromTokenAddress?: string;
3333
toTokenAddress?: string;
3434
showBackButton?: boolean;
35-
showTitle: boolean;
36-
showSubTitle: boolean;
35+
title: string;
36+
subTitle: string;
3737
}
3838

3939
export function SwapCoins({
@@ -44,8 +44,8 @@ export function SwapCoins({
4444
fromTokenAddress,
4545
toTokenAddress,
4646
showBackButton,
47-
showTitle,
48-
showSubTitle,
47+
title,
48+
subTitle,
4949
}: SwapCoinsProps) {
5050
const { t } = useTranslation();
5151
const { viewDispatch } = useContext(ViewContext);
@@ -92,7 +92,7 @@ export function SwapCoins({
9292
<SimpleLayout
9393
header={!autoProceed ? (
9494
<HeaderNavigation
95-
title={showTitle ? t('views.SWAP.header.title') : undefined}
95+
title={title}
9696
onCloseButtonClick={() => sendSwapWidgetCloseEvent(eventTarget)}
9797
showBack={showBackButton}
9898
onBackButtonClick={() => {
@@ -123,7 +123,7 @@ export function SwapCoins({
123123
toTokenAddress,
124124
}}
125125
theme={theme}
126-
showSubTitle={showSubTitle}
126+
subTitle={subTitle}
127127
/>
128128
<NotEnoughImx
129129
environment={checkout?.config.environment ?? Environment.PRODUCTION}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ function CheckoutUI() {
288288
theme,
289289
language,
290290
SWAP: {
291-
// showTitle: false,
292-
// showSubTitle: false,
293291
},
294292
// TRANSFER: {
295293
// // showTitle: false,

0 commit comments

Comments
 (0)