-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Custom Pages for
<UserProfile />
and <OrganizationProfile />
comp…
…onents (#1822) * feat(clerk-js,clerk-react,types): Introduce Custom Pages in UserProfile * fix(clerk-js): Fix top-level `localizationKeys` evaluation * fix(clerk-react): Fix issue with useCustomPages when making changes on the custom pages in dev * chore(clerk-js): Update bundlewatch.config.json * fix(clerk-react): Fix issue when changing the custom pages length dynamically * feat(clerk-react,clerk-js): Add support for custom pages in OrganizationProfile * fix(clerk-react,clerk-js): Resolve comments for custom pages * test(clerk-js): Add tests for OrganizationProfile custom pages * fix(clerk-js): Add navbar menu for mobile on custom pages * fix(clerk-react): Omit `customPages` property from React package components * refactor(clerk-js): Refactor the UserProfileRoutes and OrganizationProfileRoutes to be more readable * refactor(clerk-react,types): Apply minor refactors suggested by PR comments * refactor(clerk-react,types): Resolve PR comments * chore(clerk-js): Lint OrganizationProfileRoutes * fix(clerk-js): Fix custom icons props * fix(nextjs): Fix typings issue
- Loading branch information
Showing
29 changed files
with
1,812 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
'@clerk/clerk-js': minor | ||
'@clerk/clerk-react': minor | ||
'@clerk/types': minor | ||
--- | ||
|
||
Introduce customization in `UserProfile` and `OrganizationProfile` | ||
|
||
The `<UserProfile />` component now allows the addition of custom pages and external links to the navigation sidebar. Custom pages can be created using the `<UserProfile.Page>` component, and external links can be added using the `<UserProfile.Link>` component. The default routes, such as `Account` and `Security`, can be reordered. | ||
|
||
Example React API usage: | ||
|
||
```tsx | ||
<UserProfile> | ||
<UserProfile.Page label="Custom Page" url="custom" labelIcon={<CustomIcon />}> | ||
<MyCustomPageContent /> | ||
</UserProfile.Page> | ||
<UserProfile.Link label="External" url="/home" labelIcon={<Icon />} /> | ||
<UserProfile.Page label="account" /> | ||
<UserProfile.Page label="security" /> | ||
</UserProfile> | ||
``` | ||
Custom pages and links should be provided as children using the `<UserButton.UserProfilePage>` and `<UserButton.UserProfileLink>` components when using the `UserButton` component. | ||
|
||
The `<OrganizationProfile />` component now supports the addition of custom pages and external links to the navigation sidebar. Custom pages can be created using the `<OrganizationProfile.Page>` component, and external links can be added using the `<OrganizationProfile.Link>` component. The default routes, such as `Members` and `Settings`, can be reordered. | ||
|
||
Example React API usage: | ||
|
||
```tsx | ||
<OrganizationProfile> | ||
<OrganizationProfile.Page label="Custom Page" url="custom" labelIcon={<CustomIcon />}> | ||
<MyCustomPageContent /> | ||
</OrganizationProfile.Page> | ||
<OrganizationProfile.Link label="External" url="/home" labelIcon={<Icon />} /> | ||
<OrganizationProfile.Page label="members" /> | ||
<OrganizationProfile.Page label="settings" /> | ||
</OrganizationProfile> | ||
``` | ||
Custom pages and links should be provided as children using the `<OrganizationSwitcher.OrganizationProfilePage>` and `<OrganizationSwitcher.OrganizationProfileLink>` components when using the `OrganizationSwitcher` component. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/clerk-js/src/ui/common/CustomPageContentContainer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { Col, descriptors } from '../customizables'; | ||
import { CardAlert, NavbarMenuButtonRow, useCardState, withCardStateProvider } from '../elements'; | ||
import type { CustomPageContent } from '../utils'; | ||
import { ExternalElementMounter } from '../utils'; | ||
|
||
export const CustomPageContentContainer = withCardStateProvider( | ||
({ mount, unmount }: Omit<CustomPageContent, 'url'>) => { | ||
const card = useCardState(); | ||
return ( | ||
<Col | ||
elementDescriptor={descriptors.page} | ||
gap={8} | ||
> | ||
<CardAlert>{card.error}</CardAlert> | ||
<NavbarMenuButtonRow /> | ||
<Col | ||
elementDescriptor={descriptors.profilePage} | ||
gap={8} | ||
> | ||
<ExternalElementMounter | ||
mount={mount} | ||
unmount={unmount} | ||
/> | ||
</Col> | ||
</Col> | ||
); | ||
}, | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.