From 3b917d6eb38fd3134432a2de579fa13024783aac Mon Sep 17 00:00:00 2001 From: wobsoriano Date: Mon, 19 Aug 2024 14:38:24 -0700 Subject: [PATCH 1/5] feat(astro): Add custom pages and links --- packages/astro/src/astro-components/index.ts | 2 +- .../interactive/UserProfile.astro | 8 --- .../UserProfile/ProfileRenderer.astro | 60 +++++++++++++++++++ .../interactive/UserProfile/UserProfile.astro | 11 ++++ .../UserProfile/UserProfileLink.astro | 14 +++++ .../UserProfile/UserProfilePage.astro | 23 +++++++ .../interactive/UserProfile/index.ts | 8 +++ 7 files changed, 117 insertions(+), 9 deletions(-) delete mode 100644 packages/astro/src/astro-components/interactive/UserProfile.astro create mode 100644 packages/astro/src/astro-components/interactive/UserProfile/ProfileRenderer.astro create mode 100644 packages/astro/src/astro-components/interactive/UserProfile/UserProfile.astro create mode 100644 packages/astro/src/astro-components/interactive/UserProfile/UserProfileLink.astro create mode 100644 packages/astro/src/astro-components/interactive/UserProfile/UserProfilePage.astro create mode 100644 packages/astro/src/astro-components/interactive/UserProfile/index.ts diff --git a/packages/astro/src/astro-components/index.ts b/packages/astro/src/astro-components/index.ts index e78da856ec3..dd6725c1642 100644 --- a/packages/astro/src/astro-components/index.ts +++ b/packages/astro/src/astro-components/index.ts @@ -19,7 +19,7 @@ export { default as SignOutButton } from './unstyled/SignOutButton.astro'; export { default as SignIn } from './interactive/SignIn.astro'; export { default as SignUp } from './interactive/SignUp.astro'; export { UserButton } from './interactive/UserButton'; -export { default as UserProfile } from './interactive/UserProfile.astro'; +export { UserProfile } from './interactive/UserProfile'; export { default as OrganizationProfile } from './interactive/OrganizationProfile.astro'; export { default as OrganizationSwitcher } from './interactive/OrganizationSwitcher.astro'; export { default as OrganizationList } from './interactive/OrganizationList.astro'; diff --git a/packages/astro/src/astro-components/interactive/UserProfile.astro b/packages/astro/src/astro-components/interactive/UserProfile.astro deleted file mode 100644 index 1cf962e5d2a..00000000000 --- a/packages/astro/src/astro-components/interactive/UserProfile.astro +++ /dev/null @@ -1,8 +0,0 @@ ---- -import type { UserProfileProps } from "@clerk/types"; -type Props = UserProfileProps - -import InternalUIComponentRenderer from './InternalUIComponentRenderer.astro' ---- - - diff --git a/packages/astro/src/astro-components/interactive/UserProfile/ProfileRenderer.astro b/packages/astro/src/astro-components/interactive/UserProfile/ProfileRenderer.astro new file mode 100644 index 00000000000..647d3433d36 --- /dev/null +++ b/packages/astro/src/astro-components/interactive/UserProfile/ProfileRenderer.astro @@ -0,0 +1,60 @@ +--- +interface Props { + url: string + label: string + type: 'page' | 'link' +} + +const { url, label, type } = Astro.props + +let labelIcon = ''; +let content = '' + +if (Astro.slots.has('label-icon')) { + labelIcon = await Astro.slots.render('label-icon'); +} + +if (Astro.slots.has('default') && type === 'page') { + content = await Astro.slots.render('default'); +} +--- + + diff --git a/packages/astro/src/astro-components/interactive/UserProfile/UserProfile.astro b/packages/astro/src/astro-components/interactive/UserProfile/UserProfile.astro new file mode 100644 index 00000000000..92f8b1554ea --- /dev/null +++ b/packages/astro/src/astro-components/interactive/UserProfile/UserProfile.astro @@ -0,0 +1,11 @@ +--- +import type { UserProfileProps, Without } from "@clerk/types"; + +type Props = Without + +import InternalUIComponentRenderer from '../InternalUIComponentRenderer.astro' +--- + + + + diff --git a/packages/astro/src/astro-components/interactive/UserProfile/UserProfileLink.astro b/packages/astro/src/astro-components/interactive/UserProfile/UserProfileLink.astro new file mode 100644 index 00000000000..211dfa40026 --- /dev/null +++ b/packages/astro/src/astro-components/interactive/UserProfile/UserProfileLink.astro @@ -0,0 +1,14 @@ +--- +import ProfileRenderer from './ProfileRenderer.astro' + +interface Props { + url: string + label: string +} + +const { url, label } = Astro.props +--- + + + + diff --git a/packages/astro/src/astro-components/interactive/UserProfile/UserProfilePage.astro b/packages/astro/src/astro-components/interactive/UserProfile/UserProfilePage.astro new file mode 100644 index 00000000000..01c933bde70 --- /dev/null +++ b/packages/astro/src/astro-components/interactive/UserProfile/UserProfilePage.astro @@ -0,0 +1,23 @@ +--- +import ProfileRenderer from './ProfileRenderer.astro' + +type ReorderItemsLabels = 'account' | 'security' + +type Props