Skip to content

Commit 466ed13

Browse files
chore(clerk-js): Use nested AppearanceProvider for Checkout component (#5443)
1 parent 5403e25 commit 466ed13

File tree

3 files changed

+39
-26
lines changed

3 files changed

+39
-26
lines changed

.changeset/rare-rules-fly.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Wrap nested `<Checkout />` component in its own AppearanceProvider to recieve its own appearance object.

packages/clerk-js/src/ui/components/PricingTable/PricingTable.tsx

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useState } from 'react';
44

55
import { PROFILE_CARD_SCROLLBOX_ID } from '../../constants';
66
import { __experimental_CheckoutContext, usePricingTableContext } from '../../contexts';
7+
import { AppearanceProvider } from '../../customizables';
78
import { useFetch } from '../../hooks';
89
import { __experimental_Checkout } from '../Checkout';
910
import { PlanDetailDrawer } from './PlanDetailDrawer';
@@ -54,33 +55,38 @@ export const __experimental_PricingTable = (props: __experimental_PricingTablePr
5455
/>
5556
)}
5657

57-
<__experimental_CheckoutContext.Provider
58-
value={{
59-
componentName: 'Checkout',
60-
mode,
61-
isOpen: showCheckout,
62-
setIsOpen: setShowCheckout,
63-
}}
58+
<AppearanceProvider
59+
appearanceKey='checkout'
60+
appearance={props.checkoutProps?.appearance}
6461
>
65-
{/*TODO: Used by InvisibleRootBox, can we simplify? */}
66-
<div>
67-
<__experimental_Checkout
68-
planPeriod={planPeriod}
69-
planId={selectedPlan?.id}
70-
/>
71-
</div>
72-
</__experimental_CheckoutContext.Provider>
73-
<PlanDetailDrawer
74-
isOpen={showPlanDetail}
75-
setIsOpen={setShowPlanDetail}
76-
plan={selectedPlan}
77-
planPeriod={planPeriod}
78-
setPlanPeriod={setPlanPeriod}
79-
strategy={mode === 'mounted' ? 'fixed' : 'absolute'}
80-
portalProps={{
81-
id: mode === 'modal' ? PROFILE_CARD_SCROLLBOX_ID : undefined,
82-
}}
83-
/>
62+
<__experimental_CheckoutContext.Provider
63+
value={{
64+
componentName: 'Checkout',
65+
mode,
66+
isOpen: showCheckout,
67+
setIsOpen: setShowCheckout,
68+
}}
69+
>
70+
{/*TODO: Used by InvisibleRootBox, can we simplify? */}
71+
<div>
72+
<__experimental_Checkout
73+
planPeriod={planPeriod}
74+
planId={selectedPlan?.id}
75+
/>
76+
</div>
77+
</__experimental_CheckoutContext.Provider>
78+
<PlanDetailDrawer
79+
isOpen={showPlanDetail}
80+
setIsOpen={setShowPlanDetail}
81+
plan={selectedPlan}
82+
planPeriod={planPeriod}
83+
setPlanPeriod={setPlanPeriod}
84+
strategy={mode === 'mounted' ? 'fixed' : 'absolute'}
85+
portalProps={{
86+
id: mode === 'modal' ? PROFILE_CARD_SCROLLBOX_ID : undefined,
87+
}}
88+
/>
89+
</AppearanceProvider>
8490
</>
8591
);
8692
};

packages/types/src/clerk.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,6 +1490,7 @@ type __experimental_PricingTableMatrixProps = {
14901490

14911491
type __experimental_PricingTableBaseProps = {
14921492
appearance?: PricingTableTheme;
1493+
checkoutProps?: Pick<__experimental_CheckoutProps, 'appearance'>;
14931494
};
14941495

14951496
export type __experimental_PricingTableProps = __experimental_PricingTableBaseProps &

0 commit comments

Comments
 (0)