Skip to content

Commit 97749d5

Browse files
authored
chore(clerk-js,types): Display info tooltip for past due amounts in checkout (#6097)
1 parent 607d333 commit 97749d5

File tree

6 files changed

+44
-5
lines changed

6 files changed

+44
-5
lines changed

.changeset/tiny-cameras-battle.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': patch
3+
---
4+
5+
Display info tooltip for past due amounts at checkout.

.changeset/violet-views-sip.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@clerk/localizations': patch
3+
'@clerk/types': patch
4+
---
5+
6+
Introduce `commerce.checkout.pastDueNotice` localization key.

packages/clerk-js/src/ui/components/Checkout/CheckoutForm.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@ import { Drawer } from '@/ui/elements/Drawer';
1414
import { LineItems } from '@/ui/elements/LineItems';
1515
import { SegmentedControl } from '@/ui/elements/SegmentedControl';
1616
import { Select, SelectButton, SelectOptionList } from '@/ui/elements/Select';
17+
import { Tooltip } from '@/ui/elements/Tooltip';
1718

1819
import { DevOnly } from '../../common/DevOnly';
1920
import { useCheckoutContext, usePaymentSources } from '../../contexts';
2021
import { Box, Button, Col, descriptors, Flex, Form, localizationKeys, Text } from '../../customizables';
21-
import { ChevronUpDown } from '../../icons';
22+
import { ChevronUpDown, InformationCircle } from '../../icons';
2223
import { handleError } from '../../utils';
2324
import * as AddPaymentSource from '../PaymentSources/AddPaymentSource';
2425
import { PaymentSourceRow } from '../PaymentSources/PaymentSourceRow';
@@ -79,7 +80,15 @@ export const CheckoutForm = withCardStateProvider(() => {
7980
)}
8081
{showPastDue && (
8182
<LineItems.Group variant='tertiary'>
82-
<LineItems.Title title={localizationKeys('commerce.pastDue')} />
83+
<Tooltip.Root>
84+
<Tooltip.Trigger>
85+
<LineItems.Title
86+
title={localizationKeys('commerce.pastDue')}
87+
icon={InformationCircle}
88+
/>
89+
</Tooltip.Trigger>
90+
<Tooltip.Content text={localizationKeys('commerce.checkout.pastDueNotice')} />
91+
</Tooltip.Root>
8392
<LineItems.Description text={`${totals.pastDue?.currencySymbol}${totals.pastDue?.amountFormatted}`} />
8493
</LineItems.Group>
8594
)}

packages/clerk-js/src/ui/elements/LineItems.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,10 @@ function Group({ children, borderTop = false, variant = 'primary' }: GroupProps)
8383
interface TitleProps {
8484
title: string | LocalizationKey;
8585
description?: string | LocalizationKey;
86+
icon?: React.ComponentType;
8687
}
8788

88-
function Title({ title, description }: TitleProps) {
89+
const Title = React.forwardRef<HTMLTableCellElement, TitleProps>(({ title, description, icon }, ref) => {
8990
const context = React.useContext(GroupContext);
9091
if (!context) {
9192
throw new Error('LineItems.Title must be used within LineItems.Group');
@@ -94,6 +95,7 @@ function Title({ title, description }: TitleProps) {
9495
const textVariant = variant === 'primary' ? 'subtitle' : 'caption';
9596
return (
9697
<Dt
98+
ref={ref}
9799
elementDescriptor={descriptors.lineItemsTitle}
98100
elementId={descriptors.lineItemsTitle.setId(variant)}
99101
sx={t => ({
@@ -102,7 +104,22 @@ function Title({ title, description }: TitleProps) {
102104
...common.textVariants(t)[textVariant],
103105
})}
104106
>
105-
<Span localizationKey={title} />
107+
<Span
108+
sx={t => ({
109+
display: 'inline-flex',
110+
alignItems: 'center',
111+
gap: t.space.$1,
112+
})}
113+
>
114+
{icon ? (
115+
<Icon
116+
size='md'
117+
icon={icon}
118+
aria-hidden
119+
/>
120+
) : null}
121+
<Span localizationKey={title} />
122+
</Span>
106123
{description ? (
107124
<Span
108125
localizationKey={description}
@@ -115,7 +132,7 @@ function Title({ title, description }: TitleProps) {
115132
) : null}
116133
</Dt>
117134
);
118-
}
135+
});
119136

120137
/* -------------------------------------------------------------------------------------------------
121138
* LineItems.Description

packages/localizations/src/en-US.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ export const enUS: LocalizationResource = {
3838
description__subscriptionSuccessful: 'Your new subscription is all set.',
3939
downgradeNotice:
4040
'You will keep your current subscription and its features until the end of the billing cycle, then you will be switched to this subscription.',
41+
pastDueNotice: 'Your previous subscription was past due, with no payment.',
4142
emailForm: {
4243
subtitle: 'Before you can complete your purchase you must add an email address where receipts will be sent.',
4344
title: 'Add an email address',

packages/types/src/localization.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ type _LocalizationResource = {
178178
subtitle: LocalizationValue;
179179
};
180180
downgradeNotice: LocalizationValue;
181+
pastDueNotice: LocalizationValue;
181182
perMonth: LocalizationValue;
182183
};
183184
};

0 commit comments

Comments
 (0)