Skip to content

Commit 0f5145e

Browse files
fix(clerk-js,types): Correctly pass Checkout appearance prop through PricingTable (#5888)
Co-authored-by: panteliselef <panteliselef@outlook.com>
1 parent afdfd18 commit 0f5145e

File tree

7 files changed

+49
-6
lines changed

7 files changed

+49
-6
lines changed

.changeset/famous-fans-create.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
'@clerk/types': minor
4+
---
5+
6+
Fix issue where we were not correctly passing the checkoutProps through within the PricingTable component. Removes internal checkoutProps prefix from PricingTableBaseProps.

packages/clerk-js/bundlewatch.config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
{ "path": "./dist/clerk.browser.js", "maxSize": "68.3KB" },
55
{ "path": "./dist/clerk.legacy.browser.js", "maxSize": "110KB" },
66
{ "path": "./dist/clerk.headless*.js", "maxSize": "52KB" },
7-
{ "path": "./dist/ui-common*.js", "maxSize": "104KB" },
7+
{ "path": "./dist/ui-common*.js", "maxSize": "104.1KB" },
88
{ "path": "./dist/vendors*.js", "maxSize": "39.5KB" },
99
{ "path": "./dist/coinbase*.js", "maxSize": "38KB" },
1010
{ "path": "./dist/createorganization*.js", "maxSize": "5KB" },

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,13 @@ const PricingTableRoot = (props: PricingTableProps) => {
5050
return clerk.redirectToSignIn();
5151
}
5252

53-
handleSelectPlan({ mode, plan, planPeriod, event });
53+
handleSelectPlan({
54+
mode,
55+
plan,
56+
planPeriod,
57+
event,
58+
appearance: props.checkoutProps?.appearance,
59+
});
5460
return;
5561
};
5662

packages/clerk-js/src/ui/contexts/components/Plans.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { useClerk, useOrganization, useUser } from '@clerk/shared/react';
22
import type {
3+
Appearance,
34
CommercePlanResource,
45
CommerceSubscriberType,
56
CommerceSubscriptionPlanPeriod,
@@ -135,6 +136,7 @@ type HandleSelectPlanProps = {
135136
onSubscriptionChange?: () => void;
136137
mode?: 'modal' | 'mounted';
137138
event?: React.MouseEvent<HTMLElement>;
139+
appearance?: Appearance;
138140
};
139141

140142
export const usePlansContext = () => {
@@ -254,7 +256,7 @@ export const usePlansContext = () => {
254256

255257
// handle the selection of a plan, either by opening the subscription details or checkout
256258
const handleSelectPlan = useCallback(
257-
({ plan, planPeriod, onSubscriptionChange, mode = 'mounted', event }: HandleSelectPlanProps) => {
259+
({ plan, planPeriod, onSubscriptionChange, mode = 'mounted', event, appearance }: HandleSelectPlanProps) => {
258260
const subscription = activeOrUpcomingSubscription(plan);
259261

260262
const portalRoot = getClosestProfileScrollBox(mode, event);
@@ -267,6 +269,7 @@ export const usePlansContext = () => {
267269
ctx.revalidate();
268270
onSubscriptionChange?.();
269271
},
272+
appearance,
270273
portalRoot,
271274
});
272275
} else {
@@ -284,6 +287,7 @@ export const usePlansContext = () => {
284287
ctx.revalidate();
285288
onSubscriptionChange?.();
286289
},
290+
appearance,
287291
portalRoot,
288292
});
289293
}

packages/clerk-js/src/ui/lazyModules/MountedCheckoutDrawer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function MountedCheckoutDrawer({
2828
key={user?.id}
2929
globalAppearance={appearance}
3030
appearanceKey={'checkout' as any}
31-
componentAppearance={{}}
31+
componentAppearance={checkoutDrawer.props.appearance || {}}
3232
flowName={'checkout'}
3333
open={checkoutDrawer.open}
3434
onOpenChange={onOpenChange}
@@ -43,6 +43,7 @@ export function MountedCheckoutDrawer({
4343
subscriberType={checkoutDrawer.props.subscriberType}
4444
onSubscriptionComplete={checkoutDrawer.props.onSubscriptionComplete}
4545
portalRoot={checkoutDrawer.props.portalRoot}
46+
appearance={checkoutDrawer.props.appearance}
4647
/>
4748
)}
4849
</LazyDrawerRenderer>

packages/clerk-js/src/ui/lazyModules/MountedPlanDetailDrawer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export function MountedPlanDetailDrawer({
2828
key={user?.id}
2929
globalAppearance={appearance}
3030
appearanceKey={'planDetails' as any}
31-
componentAppearance={{}}
31+
componentAppearance={planDetailsDrawer.props.appearance || {}}
3232
flowName={'planDetails'}
3333
open={planDetailsDrawer.open}
3434
onOpenChange={onOpenChange}
@@ -40,6 +40,7 @@ export function MountedPlanDetailDrawer({
4040
{...planDetailsDrawer.props}
4141
subscriberType={planDetailsDrawer.props.subscriberType || 'user'}
4242
onSubscriptionCancel={planDetailsDrawer.props.onSubscriptionCancel || (() => {})}
43+
appearance={planDetailsDrawer.props.appearance}
4344
/>
4445
</LazyDrawerRenderer>
4546
);

packages/types/src/clerk.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1568,15 +1568,40 @@ export type WaitlistProps = {
15681568
export type WaitlistModalProps = WaitlistProps;
15691569

15701570
type PricingTableDefaultProps = {
1571+
/**
1572+
* The position of the CTA button.
1573+
* @default 'bottom'
1574+
*/
15711575
ctaPosition?: 'top' | 'bottom';
1576+
/**
1577+
* Whether to collapse features on the pricing table.
1578+
* @default false
1579+
*/
15721580
collapseFeatures?: boolean;
1581+
/**
1582+
* Full URL or path to navigate to after checkout is complete and the user clicks the "Continue" button.
1583+
* @default undefined
1584+
*/
15731585
newSubscriptionRedirectUrl?: string;
15741586
};
15751587

15761588
type PricingTableBaseProps = {
1589+
/**
1590+
* Whether to show pricing table for organizations.
1591+
* @default false
1592+
*/
15771593
forOrganizations?: boolean;
1594+
/**
1595+
* Customisation options to fully match the Clerk components to your own brand.
1596+
* These options serve as overrides and will be merged with the global `appearance`
1597+
* prop of ClerkProvider (if one is provided)
1598+
*/
15781599
appearance?: PricingTableTheme;
1579-
__internal_CheckoutProps?: Pick<__internal_CheckoutProps, 'appearance'>;
1600+
/*
1601+
* Specify options for the underlying <Checkout /> component.
1602+
* e.g. <PricingTable checkoutProps={{appearance: {variables: {colorText: 'blue'}}}} />
1603+
*/
1604+
checkoutProps?: Pick<__internal_CheckoutProps, 'appearance'>;
15801605
};
15811606

15821607
type PortalRoot = HTMLElement | null | undefined;

0 commit comments

Comments
 (0)