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. diff --git a/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx b/packages/clerk-js/src/ui/components/PricingTable/PlanCard.tsx index 8cfae45beea..730f1083eba 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,49 @@ 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', + justifyContent: 'space-between', + 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 +263,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 => (