From 30fdd434c61b8777167fe7e24c85a21e992d43ec Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Thu, 13 Mar 2025 15:59:57 -0400 Subject: [PATCH 1/3] fix(clerk-js): Conditionally render avatar --- .../ui/components/PricingTable/PlanCard.tsx | 94 +++++++++++-------- .../ui/customizables/elementDescriptors.ts | 2 +- packages/types/src/appearance.ts | 2 +- 3 files changed, 57 insertions(+), 41 deletions(-) diff --git a/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx b/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx index 8cfae45beea..8b2b03e6b98 100644 --- a/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx +++ b/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx @@ -33,12 +33,24 @@ interface PlanCardProps { export function PlanCard(props: PlanCardProps) { const { plan, period, setPeriod, onSelect, props: pricingTableProps, isCompact = false } = props; + const { + id, + slug, + name, + description, + avatarUrl, + features, + isActiveForPayer, + hasBaseFee, + currencySymbol, + amountFormatted, + annualMonthlyAmountFormatted, + } = plan; const { ctaPosition = 'top', collapseFeatures = false } = pricingTableProps; const [showAllFeatures, setShowAllFeatures] = React.useState(false); - const totalFeatures = plan.features.length; + const totalFeatures = features.length; const hasFeatures = totalFeatures > 0; const canToggleFeatures = isCompact && totalFeatures > 3; - const isActivePlan = plan.isActiveForPayer; const prefersReducedMotion = usePrefersReducedMotion(); const { animations: appearanceAnimations } = useAppearance().parsedLayout; const planCardFeePeriodNoticeAnimation: ThemableCssProp = t => ({ @@ -54,9 +66,9 @@ export function PlanCard(props: PlanCardProps) { return ( ({ display: 'flex', flexDirection: 'column', @@ -79,44 +91,48 @@ export function PlanCard(props: PlanCardProps) { padding: isCompact ? t.space.$3 : t.space.$4, })} > - - 40} - title={plan.name} - initials={plan.name[0]} - rounded={false} - imageUrl={plan.avatarUrl} - /> - {isActivePlan ? ( - - ) : null} - + {avatarUrl || isActiveForPayer ? ( + ({ + display: 'flex', + alignItems: 'start', + gap: t.space.$3, + marginBlockEnd: t.space.$3, + })} + > + {avatarUrl ? ( + 40} + title={name} + initials={name[0]} + rounded={false} + imageUrl={avatarUrl} + /> + ) : null} + {isActiveForPayer ? ( + + ) : null} + + ) : null} ({ - marginTop: t.space.$3, - })} > - {plan.name} + {name} - {!isCompact && plan.description ? ( + {!isCompact && description ? ( - {plan.description} + {description} ) : null} - {plan.hasBaseFee ? ( + {hasBaseFee ? ( <> - {plan.currencySymbol} - {period === 'month' ? plan.amountFormatted : plan.annualMonthlyAmountFormatted} + {currencySymbol} + {period === 'month' ? amountFormatted : annualMonthlyAmountFormatted} )} - {plan.hasBaseFee ? ( + {hasBaseFee ? ( ({ @@ -246,7 +262,7 @@ export function PlanCard(props: PlanCardProps) { rowGap: isCompact ? t.space.$2 : t.space.$3, })} > - {plan.features.slice(0, showAllFeatures ? totalFeatures : 3).map(feature => ( + {features.slice(0, showAllFeatures ? totalFeatures : 3).map(feature => ( Date: Thu, 13 Mar 2025 16:05:06 -0400 Subject: [PATCH 2/3] Create purple-lamps-beg.md --- .changeset/purple-lamps-beg.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/purple-lamps-beg.md diff --git a/.changeset/purple-lamps-beg.md b/.changeset/purple-lamps-beg.md new file mode 100644 index 00000000000..d75fc2af5ce --- /dev/null +++ b/.changeset/purple-lamps-beg.md @@ -0,0 +1,6 @@ +--- +'@clerk/clerk-js': patch +'@clerk/types': patch +--- + +Conditionally render the avatar and badge components within PlanCard. From 13d2959c4f1b18197e0cd75c3a8c8551c97ae8e3 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Thu, 13 Mar 2025 16:06:19 -0400 Subject: [PATCH 3/3] Update PlanCard.tsx --- packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx b/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx index 8b2b03e6b98..730f1083eba 100644 --- a/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx +++ b/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx @@ -97,6 +97,7 @@ export function PlanCard(props: PlanCardProps) { sx={t => ({ display: 'flex', alignItems: 'start', + justifyContent: 'space-between', gap: t.space.$3, marginBlockEnd: t.space.$3, })}