From 61f08de096f3fbfe39d873d04d614eb2f5bf46dc Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 16 Apr 2025 19:03:18 -0400 Subject: [PATCH 1/5] refactor(clerk-js): Invoice page title --- .../ui/components/Invoices/InvoicePage.tsx | 67 ++++++++++++++++--- 1 file changed, 59 insertions(+), 8 deletions(-) diff --git a/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx b/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx index fcd9f09343e..43c764a6a1d 100644 --- a/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx +++ b/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx @@ -1,6 +1,8 @@ import { useInvoicesContext } from '../../contexts'; -import { Badge, Box, Dd, descriptors, Dl, Dt, Heading, Spinner, Text } from '../../customizables'; +import { Badge, Box, Button, Dd, descriptors, Dl, Dt, Heading, Icon, Span, Spinner, Text } from '../../customizables'; import { Header, LineItems } from '../../elements'; +import { useClipboard } from '../../hooks'; +import { Check, Copy } from '../../icons'; import { useRouter } from '../../router'; import { common } from '../../styledSystem'; import { colors } from '../../utils'; @@ -79,15 +81,34 @@ export const InvoicePage = () => { sx={{ display: 'flex', justifyContent: 'space-between', - alignItems: 'center', + alignItems: 'start', }} > - - {truncateWithEndVisible(invoice.id)} - + + + Invoice ID + + ({ + display: 'flex', + alignItems: 'center', + gap: t.space.$0x5, + color: t.colors.$colorTextSecondary, + })} + > + + + {truncateWithEndVisible(invoice.id)} + + + + { ); }; + +function CopyButton({ text, copyLabel = 'Copy' }: { text: string; copyLabel?: string }) { + const { onCopy, hasCopied } = useClipboard(text); + + return ( + + ); +} From de1cce44791bc1b5fc181b05e6b61b891dcfa721 Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 16 Apr 2025 19:17:09 -0400 Subject: [PATCH 2/5] descriptors --- .../ui/components/Invoices/InvoicePage.tsx | 28 +++++++++++++++---- .../ui/customizables/elementDescriptors.ts | 6 ++++ packages/types/src/appearance.ts | 6 ++++ 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx b/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx index 43c764a6a1d..281073b5b6f 100644 --- a/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx +++ b/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx @@ -78,13 +78,14 @@ export const InvoicePage = () => { })} > - + { Invoice ID ({ display: 'flex', alignItems: 'center', - gap: t.space.$0x5, + gap: t.space.$0x25, color: t.colors.$colorTextSecondary, })} > - + {truncateWithEndVisible(invoice.id)} @@ -130,6 +136,7 @@ export const InvoicePage = () => {
@@ -137,7 +144,12 @@ export const InvoicePage = () => {
- {new Date(invoice.paymentDueOn).toLocaleDateString()} + + {new Date(invoice.paymentDueOn).toLocaleDateString()} +
{ >
@@ -155,7 +168,12 @@ export const InvoicePage = () => {
- {new Date(invoice.paymentDueOn).toLocaleDateString()} + + {new Date(invoice.paymentDueOn).toLocaleDateString()} +
diff --git a/packages/clerk-js/src/ui/customizables/elementDescriptors.ts b/packages/clerk-js/src/ui/customizables/elementDescriptors.ts index f91058baef1..9d5679b94d0 100644 --- a/packages/clerk-js/src/ui/customizables/elementDescriptors.ts +++ b/packages/clerk-js/src/ui/customizables/elementDescriptors.ts @@ -343,12 +343,18 @@ export const APPEARANCE_KEYS = containsAllElementsConfigKeys([ 'invoiceRoot', 'invoiceCard', 'invoiceHeader', + 'invoiceHeaderContent', 'invoiceTitle', + 'invoiceTitleContainer', + 'invoiceId', + 'invoiceIdContainer', 'invoiceBadge', 'invoiceDetails', 'invoiceDetailsItem', 'invoiceDetailsItemTitle', + 'invoiceDetailsItemTitleText', 'invoiceDetailsItemValue', + 'invoiceDetailsItemValueText', 'invoiceContent', 'menuButton', diff --git a/packages/types/src/appearance.ts b/packages/types/src/appearance.ts index 03903d1ca4d..cb2dd4f6324 100644 --- a/packages/types/src/appearance.ts +++ b/packages/types/src/appearance.ts @@ -467,12 +467,18 @@ export type ElementsConfig = { invoiceRoot: WithOptions; invoiceCard: WithOptions; invoiceHeader: WithOptions; + invoiceHeaderContent: WithOptions; invoiceTitle: WithOptions; + invoiceTitleContainer: WithOptions; + invoiceId: WithOptions; + invoiceIdContainer: WithOptions; invoiceBadge: WithOptions; invoiceDetails: WithOptions; invoiceDetailsItem: WithOptions; invoiceDetailsItemTitle: WithOptions; + invoiceDetailsItemTitleText: WithOptions; invoiceDetailsItemValue: WithOptions; + invoiceDetailsItemValueText: WithOptions; invoiceContent: WithOptions; menuButton: WithOptions; From 3629296872694f21e9c7fbba1741649e0ee46e0c Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Wed, 16 Apr 2025 19:18:18 -0400 Subject: [PATCH 3/5] add changeset --- .changeset/forty-peaches-stay.md | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .changeset/forty-peaches-stay.md diff --git a/.changeset/forty-peaches-stay.md b/.changeset/forty-peaches-stay.md new file mode 100644 index 00000000000..de77f82d107 --- /dev/null +++ b/.changeset/forty-peaches-stay.md @@ -0,0 +1,6 @@ +--- +'@clerk/clerk-js': patch +'@clerk/types': patch +--- + +Refactor InvoicePage title and invoice ID UI. From ea1927ce788ea74fdfa5843b187a54acec644dbe Mon Sep 17 00:00:00 2001 From: Alex Carpenter Date: Thu, 17 Apr 2025 09:33:00 -0400 Subject: [PATCH 4/5] improve descriptors --- .../clerk-js/src/ui/components/Invoices/InvoicePage.tsx | 7 ++++--- .../clerk-js/src/ui/customizables/elementDescriptors.ts | 4 +++- packages/types/src/appearance.ts | 4 +++- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx b/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx index 281073b5b6f..dc2e965cb30 100644 --- a/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx +++ b/packages/clerk-js/src/ui/components/Invoices/InvoicePage.tsx @@ -78,14 +78,14 @@ export const InvoicePage = () => { })} > - + { text={invoice.id} /> {truncateWithEndVisible(invoice.id)} @@ -228,6 +228,7 @@ function CopyButton({ text, copyLabel = 'Copy' }: { text: string; copyLabel?: st return (