Skip to content

Commit feebe85

Browse files
authored
chore(astro): Small QoL improvement for internal UI component IDs (#5848)
1 parent 895a1a3 commit feebe85

4 files changed

Lines changed: 20 additions & 14 deletions

File tree

.changeset/eager-bananas-write.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/astro/src/astro-components/interactive/InternalUIComponentRenderer.astro

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,13 @@
11
---
2+
import { generateSafeId } from '@clerk/astro/internal';
3+
import type { InternalUIComponentId } from '../../types';
4+
25
interface Props {
36
[key: string]: unknown;
47
id?: string;
5-
component:
6-
| 'sign-in'
7-
| 'sign-up'
8-
| 'organization-list'
9-
| 'organization-profile'
10-
| 'organization-switcher'
11-
| 'user-button'
12-
| 'user-profile'
13-
| 'google-one-tap'
14-
| 'waitlist'
15-
| 'pricing-table';
8+
component: InternalUIComponentId
169
}
1710
18-
import { generateSafeId } from '@clerk/astro/internal';
19-
2011
const { component, id, ...props } = Astro.props;
2112
2213
const safeId = id || generateSafeId();

packages/astro/src/internal/mount-clerk-astro-js-components.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { $clerk } from '../stores/internal';
2+
import type { InternalUIComponentId } from '../types';
23

34
/**
45
* Loop through any Astro component that has requested to mount a UI component and mount it with its respective props.
@@ -15,7 +16,7 @@ const mountAllClerkAstroJSComponents = () => {
1516
'google-one-tap': 'openGoogleOneTap',
1617
waitlist: 'mountWaitlist',
1718
'pricing-table': 'mountPricingTable',
18-
} as const;
19+
} as const satisfies Record<InternalUIComponentId, string>;
1920

2021
Object.entries(mountFns).forEach(([category, mountFn]) => {
2122
const elementsOfCategory = document.querySelectorAll(`[data-clerk-id^="clerk-${category}"]`);

packages/astro/src/types.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,15 @@ export type ButtonProps<Tag> = {
8383
as: Tag;
8484
asChild?: boolean;
8585
};
86+
87+
export type InternalUIComponentId =
88+
| 'sign-in'
89+
| 'sign-up'
90+
| 'organization-list'
91+
| 'organization-profile'
92+
| 'organization-switcher'
93+
| 'user-button'
94+
| 'user-profile'
95+
| 'google-one-tap'
96+
| 'waitlist'
97+
| 'pricing-table';

0 commit comments

Comments
 (0)