Repository navigation
feat(clerk-js,types): Standalone UserButton and OrganizationSwitcher #4042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
panteliselef
merged 47 commits into
main
from
elef/sdk-1754-add-open-and-onopenchange-to-userbutton-and-switcher
Oct 16, 2024
Merged
Changes from 34 commits
Commits
Show all changes
47 commits
Select commit
Hold shift + click to select a range
3b240b7
feat(clerk-js): Experimental controlled UserButton
panteliselef 14f15ee
chore(clerk-js): Add changeset
panteliselef 92bbb91
feat(clerk-js): Experimental controlled OrganizationSwitcher
panteliselef 0eb2bda
feat(clerk-js): Standalone OrganizationSwitcher
panteliselef 74582c6
drop unwanted changes
panteliselef d187ba2
Revert "drop unwanted changes"
panteliselef 7cd9c0b
support hideTrigger in userButton
panteliselef 75e0933
remove experimental open
panteliselef d6f58e3
update naming and write jsdoc
panteliselef 2f69080
minor cleanup
panteliselef 22691cb
add unit tests
panteliselef 08a1b3e
update changeset
panteliselef 3c38cd1
Merge branch 'main' into elef/sdk-1754-add-open-and-onopenchange-to-u…
panteliselef 57e39d9
wip
panteliselef 640d7f4
poc state
panteliselef 4988ea4
ready for snapshot
panteliselef e1348db
Merge branch 'refs/heads/main' into elef/sdk-1754-add-open-and-onopen…
panteliselef 0c42492
skip tests
panteliselef f3edf18
update bundlewatch.config.json
panteliselef f99c981
wip prefetch on provider
panteliselef 45509a0
OrganizationSwitcher implement asProvider and asStandalone
panteliselef 9283c25
UserButton implement asProvider and asStandalone
panteliselef 0dbed6c
Merge branch 'refs/heads/main' into elef/sdk-1754-add-open-and-onopen…
panteliselef b4903a7
bump bundlewatch for clerk-js
panteliselef 0c86be3
update e2e tests
panteliselef a5b0e9a
Merge branch 'refs/heads/main' into elef/sdk-1754-add-open-and-onopen…
panteliselef 0ac1301
update unit tests
panteliselef 1455348
add jsdoc to `__experimental_prefetchOrganizationSwitcher` and saniti…
panteliselef 24bb37c
Merge branch 'refs/heads/main' into elef/sdk-1754-add-open-and-onopen…
panteliselef b8f2f7e
update bundlewatch.config.json
panteliselef 7483218
Merge branch 'refs/heads/main' into elef/sdk-1754-add-open-and-onopen…
panteliselef 131e99c
cleanup
panteliselef 727ffed
bring back pages
panteliselef 2f940fd
revert necessary changes
panteliselef 2516815
Apply suggestions from code review
panteliselef 237af16
update changeset
panteliselef 957661c
add changeset for react
panteliselef 6152be0
Merge branch 'refs/heads/main' into elef/sdk-1754-add-open-and-onopen…
panteliselef 7b7f8d5
fix formatting
panteliselef 3ef3bb5
Apply suggestions from code review
panteliselef a84b075
address review comments
panteliselef 1d67a45
update bundlewatch.config.json
panteliselef 04bb42b
Merge branch 'main' into elef/sdk-1754-add-open-and-onopenchange-to-u…
panteliselef 7fee588
Merge branch 'main' into elef/sdk-1754-add-open-and-onopenchange-to-u…
panteliselef 68fec36
Merge branch 'refs/heads/main' into elef/sdk-1754-add-open-and-onopen…
panteliselef d4b8a12
when popover with asStandalone avoid entry animations
panteliselef 65fe1c8
Merge branch 'main' into elef/sdk-1754-add-open-and-onopenchange-to-u…
panteliselef File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,7 @@ | ||
| --- | ||
| '@clerk/clerk-js': minor | ||
| '@clerk/types': minor | ||
| --- | ||
|
|
||
| Add experimental support for a standalone mode for UserButton and OrganizationSwitcher. | ||
| When `__experimental_standalone: true` the component will not render its trigger and instead it will render only the contents of the popover in place. |
100 changes: 100 additions & 0 deletions
100
integration/templates/react-vite/src/custom-user-button-trigger/index.tsx
This file contains hidden or 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,100 @@ | ||
| import { UserButton } from '@clerk/clerk-react'; | ||
| import { PropsWithChildren, useContext, useState } from 'react'; | ||
| import { PageContext, PageContextProvider } from '../PageContext.tsx'; | ||
|
|
||
| function Page1() { | ||
| const { counter, setCounter } = useContext(PageContext); | ||
|
|
||
| return ( | ||
| <> | ||
| <h1 data-page={1}>Page 1</h1> | ||
| <p data-page={1}>Counter: {counter}</p> | ||
| <button | ||
| data-page={1} | ||
| onClick={() => setCounter(a => a + 1)} | ||
| > | ||
| Update | ||
| </button> | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| function ToggleChildren(props: PropsWithChildren) { | ||
| const [isMounted, setMounted] = useState(false); | ||
|
|
||
| return ( | ||
| <> | ||
| <button | ||
| data-toggle-btn | ||
| onClick={() => setMounted(v => !v)} | ||
| > | ||
| Toggle | ||
| </button> | ||
| {isMounted ? props.children : null} | ||
| </> | ||
| ); | ||
| } | ||
|
|
||
| export default function Page() { | ||
| return ( | ||
| <PageContextProvider> | ||
| <UserButton __experimental_asProvider> | ||
| <UserButton.UserProfilePage | ||
| label={'Page 1'} | ||
| labelIcon={<p data-label-icon={'page-1'}>🙃</p>} | ||
| url='page-1' | ||
| > | ||
| <Page1 /> | ||
| </UserButton.UserProfilePage> | ||
| <UserButton.UserProfilePage label={'security'} /> | ||
| <UserButton.UserProfilePage | ||
| label={'Page 2'} | ||
| labelIcon={<p data-label-icon={'page-2'}>🙃</p>} | ||
| url='page-2' | ||
| > | ||
| <h1>Page 2</h1> | ||
| </UserButton.UserProfilePage> | ||
| <p data-leaked-child>This is leaking</p> | ||
| <UserButton.UserProfileLink | ||
| url={'https://clerk.com'} | ||
| label={'Visit Clerk'} | ||
| labelIcon={<p data-label-icon={'page-3'}>🌐</p>} | ||
| /> | ||
| <UserButton.MenuItems> | ||
| <UserButton.Action | ||
| label={'page-1'} | ||
| labelIcon={<span>🙃</span>} | ||
| open={'page-1'} | ||
| /> | ||
| <UserButton.Action label={'manageAccount'} /> | ||
| <UserButton.Action label={'signOut'} /> | ||
| <UserButton.Link | ||
| href={'http://clerk.com'} | ||
| label={'Visit Clerk'} | ||
| labelIcon={<span>🌐</span>} | ||
| /> | ||
|
|
||
| <UserButton.Link | ||
| href={'/user'} | ||
| label={'Visit User page'} | ||
| labelIcon={<span>🌐</span>} | ||
| /> | ||
|
|
||
| <UserButton.Action | ||
| label={'Custom Alert'} | ||
| labelIcon={<span>🔔</span>} | ||
| onClick={() => alert('custom-alert')} | ||
| /> | ||
| </UserButton.MenuItems> | ||
| <UserButton.UserProfileLink | ||
| url={'/user'} | ||
| label={'Visit User page'} | ||
| labelIcon={<p data-label-icon={'page-4'}>🌐</p>} | ||
| /> | ||
| <ToggleChildren> | ||
| <UserButton.__experimental_Outlet __experimental_asStandalone /> | ||
| </ToggleChildren> | ||
| </UserButton> | ||
| </PageContextProvider> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.