From 6f8fd9fb55f0eeda830120a416237c768e7423ed Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Fri, 14 Mar 2025 15:49:29 -0400 Subject: [PATCH 1/2] fix(clerk-js): Update plan feed rendering within PlanCard --- .../ui/components/PricingTable/PlanCard.tsx | 88 ++++++++++--------- 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx b/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx index bc5aa512e21..ba903bc7406 100644 --- a/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx +++ b/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx @@ -147,13 +147,19 @@ export const PlanCardHeader = React.forwardRef ({ transition: isMotionSafe ? `grid-template-rows ${t.transitionDuration.$slower} ${t.transitionTiming.$slowBezier}` : 'none', }); + const getPlanFee = React.useMemo(() => { + if (annualMonthlyAmount <= 0) { + return plan.amountFormatted; + } + return planPeriod === 'annual' ? plan.annualMonthlyAmountFormatted : plan.amountFormatted; + }, [annualMonthlyAmount, planPeriod, plan.amountFormatted, plan.annualMonthlyAmountFormatted]); return ( {plan.currencySymbol} - {planPeriod === 'month' ? plan.amountFormatted : plan.annualMonthlyAmountFormatted} + {getPlanFee} - ({ - width: '100%', - display: 'grid', - gridTemplateRows: planPeriod === 'annual' ? '1fr' : '0fr', - }), - planCardFeePeriodNoticeAnimation, - ]} - // @ts-ignore - Needed until React 19 support - inert={planPeriod !== 'annual' ? 'true' : undefined} - > + {annualMonthlyAmount > 0 ? ( - ({ + elementDescriptor={descriptors.planCardFeePeriodNotice} + sx={[ + _ => ({ width: '100%', - display: 'flex', - alignItems: 'center', - columnGap: t.space.$1, - })} + display: 'grid', + gridTemplateRows: planPeriod === 'annual' ? '1fr' : '0fr', + }), + planCardFeePeriodNoticeAnimation, + ]} + // @ts-ignore - Needed until React 19 support + inert={planPeriod !== 'annual' ? 'true' : undefined} + > + - {' '} - - + ({ + width: '100%', + display: 'flex', + alignItems: 'center', + columnGap: t.space.$1, + })} + > + {' '} + + + - + ) : null} ) : ( )} - {plan.hasBaseFee ? ( + {plan.hasBaseFee && annualMonthlyAmount > 0 ? ( ({ From 6b62b600ca17acf9a8d2f4c2b766485a71d2a93f Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Fri, 14 Mar 2025 15:50:24 -0400 Subject: [PATCH 2/2] add changeset --- .changeset/soft-houses-camp.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/soft-houses-camp.md diff --git a/.changeset/soft-houses-camp.md b/.changeset/soft-houses-camp.md new file mode 100644 index 00000000000..c8805c1af2b --- /dev/null +++ b/.changeset/soft-houses-camp.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Update plan feed rendering within `` to only render `annualMonthlyAmount` when it's greater than 0.