Skip to content

feat(clerk-js): Add checkout success animation #5940

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 31 additions & 13 deletions packages/clerk-js/src/ui/components/Checkout/CheckoutComplete.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ export const CheckoutComplete = ({
animationTimingFunction: transitionTiming.bezier,
animationFillMode: 'forwards',
opacity: 0,
overflow: 'hidden',
backgroundColor: t.colors.$colorBackground,
'@keyframes scaleIn': {
'0%': {
filter: 'blur(10px)',
Expand Down Expand Up @@ -77,6 +79,20 @@ export const CheckoutComplete = ({
/>
);
})}
<Box
sx={t => ({
position: 'absolute',
inset: '0',
borderRadius: '50%',
backgroundColor: t.colors.$success500,
mixBlendMode: 'color',
filter: 'blur(20px)',
opacity: 0,
transform: 'translateX(-50%)',
zIndex: 1,
pointerEvents: 'none',
})}
/>
<Box
elementDescriptor={descriptors.checkoutSuccessBadge}
sx={t => ({
Expand All @@ -89,6 +105,7 @@ export const CheckoutComplete = ({
borderRadius: t.radii.$circle,
backgroundImage: `linear-gradient(180deg, rgba(255, 255, 255, 0.30) 0%, rgba(0, 0, 0, 0.12) 50%, rgba(0, 0, 0, 0.30) 95.31%)`,
boxShadow: '0px 4px 12px 0px rgba(0, 0, 0, 0.35), 0px 1px 0px 0px rgba(255, 255, 255, 0.05) inset',
color: t.colors.$success500,
':before': {
content: '""',
position: 'absolute',
Expand Down Expand Up @@ -155,16 +172,17 @@ export const CheckoutComplete = ({
as='h2'
textVariant='h2'
localizationKey={
checkout.totals.totalDueNow.amount > 0
checkout?.totals.totalDueNow.amount > 0
? localizationKeys('commerce.checkout.title__paymentSuccessful')
: localizationKeys('commerce.checkout.title__subscriptionSuccessful')
}
sx={{
sx={t => ({
opacity: 0,
animationName: 'slideUp',
animationDuration: `${transitionDurationValues.slowest}ms`,
animationTimingFunction: transitionTiming.bezier,
animationFillMode: 'forwards',
color: t.colors.$colorText,
'@keyframes slideUp': {
'0%': {
transform: 'translateY(30px)',
Expand All @@ -179,7 +197,7 @@ export const CheckoutComplete = ({
opacity: 1,
animation: 'none',
}),
}}
})}
/>
<Text
elementDescriptor={descriptors.checkoutSuccessDescription}
Expand Down Expand Up @@ -209,7 +227,7 @@ export const CheckoutComplete = ({
}),
})}
localizationKey={
checkout.totals.totalDueNow.amount > 0
checkout?.totals.totalDueNow.amount > 0
? localizationKeys('commerce.checkout.description__paymentSuccessful')
: localizationKeys('commerce.checkout.description__subscriptionSuccessful')
}
Expand Down Expand Up @@ -242,27 +260,27 @@ export const CheckoutComplete = ({
<LineItems.Group variant='secondary'>
<LineItems.Title title={localizationKeys('commerce.checkout.lineItems.title__totalPaid')} />
<LineItems.Description
text={`${checkout.totals.totalDueNow.currencySymbol}${checkout.totals.totalDueNow.amountFormatted}`}
text={`${checkout?.totals.totalDueNow.currencySymbol}${checkout?.totals.totalDueNow.amountFormatted}`}
/>
</LineItems.Group>
<LineItems.Group variant='secondary'>
<LineItems.Title
title={
checkout.totals.totalDueNow.amount > 0
checkout?.totals.totalDueNow.amount > 0
? localizationKeys('commerce.checkout.lineItems.title__paymentMethod')
: localizationKeys('commerce.checkout.lineItems.title__subscriptionBegins')
}
/>
<LineItems.Description
text={
checkout.totals.totalDueNow.amount > 0
? checkout.paymentSource
? checkout.paymentSource.paymentMethod !== 'card'
? `${capitalize(checkout.paymentSource.paymentMethod)}`
: `${capitalize(checkout.paymentSource.cardType)} ⋯ ${checkout.paymentSource.last4}`
checkout?.totals.totalDueNow.amount > 0
? checkout?.paymentSource
? checkout?.paymentSource.paymentMethod !== 'card'
? `${capitalize(checkout?.paymentSource.paymentMethod)}`
: `${capitalize(checkout?.paymentSource.cardType)} ⋯ ${checkout?.paymentSource.last4}`
: '–'
: checkout.planPeriodStart
? formatDate(new Date(checkout.planPeriodStart))
: checkout?.planPeriodStart
? formatDate(new Date(checkout?.planPeriodStart))
: '–'
}
/>
Expand Down