Skip to content

feat(astro): Add support for custom menu items - #3969

Merged
wobsoriano merged 24 commits into
mainfrom
rob/eco-130-custom-menu-items-in-astro
Aug 19, 2024
Merged

feat(astro): Add support for custom menu items#3969
wobsoriano merged 24 commits into
mainfrom
rob/eco-130-custom-menu-items-in-astro

Conversation

@wobsoriano

@wobsorianowobsoriano commented Aug 15, 2024

Copy link
Copy Markdown
Member

Description

This PR adds support for custom menu items in the <UserButton /> Astro component. It implements the same behavior with the React counterpart, with two exceptions:

  1. The onClick prop for custom actions is not implemented, since Astro components are executed on the server and is serialized. Instead, we're using a CustomEvent with a clickIdentifier prop to identify which menu item has been clicked. Maybe we can remove clickIdentifier and just use the label as identifier?
  2. The labelIcon prop is now a slot.

React components to follow.

Closes ECO-130

Usage:

<UserButton><UserButton.MenuItems><UserButton.Linklabel="Profile" href="/profile"><SomeIconslot="label-icon" /></UserButton.Link><UserButton.Actionlabel="Terms" open="terms"><TermsIconslot="label-icon" /></UserButton.Action><UserButton.Actionlabel="Open chat" clickIdentifier="open_chat"><ChatIconslot="label-icon" /></UserButton.Action></UserButton.MenuItems><UserButton.UserProfilePagelabel="Terms" url="terms"><TermsIconslot="label-icon" /><div><h1>Custom Terms Page</h1><p>This is the custom terms page</p></div></UserButton.UserProfilePage></UserButton><script>document.addEventListener('clerk:menu-item-click',(e)=>{if(e.detail==='open_chat'){/* do something */}},false,);</script>

Closes ECO-130

Checklist

  • npm test runs as expected.
  • npm run build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

@changeset-bot

changeset-botBot commented Aug 15, 2024

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 7542e82

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
NameType
@clerk/astroMinor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@wobsorianowobsoriano changed the title feat(astro): Add custom menu itemsfeat(astro): Add support for custom menu itemsAug 16, 2024
@wobsoriano
wobsoriano marked this pull request as ready for review August 16, 2024 05:09
Comment thread.changeset/eighty-timers-march.md Outdated
@wobsoriano
wobsoriano merged commit 77a02d3 into mainAug 19, 2024
@wobsoriano
wobsoriano deleted the rob/eco-130-custom-menu-items-in-astro branch August 19, 2024 14:47
brkalow pushed a commit that referenced this pull request Aug 22, 2024
Co-authored-by: Lennart <lekoarts@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@wobsoriano@LekoArts@clerk-cookie