Skip to content

Commit 4643795

Browse files
committed
feat(ui): add UserButton controller
1 parent 2bff351 commit 4643795

6 files changed

Lines changed: 585 additions & 12 deletions

File tree

packages/swingset/src/stories/user-button.mdx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ one.
2121
It is a composition of lower-layer Mosaic components — `Popover` for the floating surface, `Card` for
2222
the surface itself, `Item` for every row, `Avatar` for the workspace marks, and `Menu` for the
2323
per-account actions — so it inherits their behavior, focus management, and ARIA wiring rather than
24-
restyling any of it. This first pass is presentational: the parts render from the props on
25-
`UserButtonRoot` (mock data in the examples). A `useUserButtonController()` that reads live Clerk
26-
resources is a drop-in follow-up.
24+
restyling any of it. `UserButtonView` is presentational: the parts render from the props on
25+
`UserButtonRoot` (mock data in the examples). The connected `UserButton` wraps it with
26+
`useUserButtonController()`, which reads live Clerk resources and needs no props.
2727

2828
## Example
2929

@@ -40,12 +40,13 @@ to go here, so they only close the popover.
4040

4141
## Usage
4242

43-
The all-in-one `UserButton` renders the trigger and popup from a single prop-driven call:
43+
The all-in-one, presentational `UserButtonView` renders the trigger and popup from a single
44+
prop-driven call (the connected, Clerk-backed `UserButton` wraps it and needs no props):
4445

4546
```tsx
46-
import { UserButton } from '@clerk/ui/mosaic/user-button/user-button.view';
47+
import { UserButtonView } from '@clerk/ui/mosaic/user-button/user-button.view';
4748

48-
<UserButton
49+
<UserButtonView
4950
activeSession={{ sessionId: 'sess_colin', name: 'Colin', email: 'colin@clerk.dev' }}
5051
activeOrganizationId='org_clerk_app'
5152
hasOrganizations

packages/swingset/src/stories/user-button.stories.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/** @jsxImportSource @emotion/react */
22
import {
3-
UserButton,
43
type UserButtonInvitation,
54
type UserButtonMembership,
65
type UserButtonProps,
76
type UserButtonSession,
87
type UserButtonSuggestion,
8+
UserButtonView,
99
} from '@clerk/ui/mosaic/user-button/user-button.view';
1010
import { useState } from 'react';
1111

@@ -201,7 +201,7 @@ export function Combined(_args: Record<string, unknown>) {
201201
const prototype = usePrototype();
202202

203203
return (
204-
<UserButton
204+
<UserButtonView
205205
{...prototype}
206206
mode='combined'
207207
/>
@@ -213,7 +213,7 @@ export function Organizations(_args: Record<string, unknown>) {
213213

214214
// Fed the same data as the others, including the additional account it deliberately never shows.
215215
return (
216-
<UserButton
216+
<UserButtonView
217217
{...prototype}
218218
mode='orgs'
219219
/>
@@ -225,7 +225,7 @@ export function User(_args: Record<string, unknown>) {
225225

226226
// Fed the same data too: an active organization and its workspaces, none of which this mode shows.
227227
return (
228-
<UserButton
228+
<UserButtonView
229229
{...prototype}
230230
mode='user'
231231
/>

0 commit comments

Comments
 (0)