Skip to content

Commit ba22f92

Browse files
committed
feat(ui): add AccountButton controller
1 parent dfae67d commit ba22f92

7 files changed

Lines changed: 584 additions & 11 deletions

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ exposes **Add organization**, **Add account**, and **Sign out of all accounts**.
1010

1111
It is the styled Mosaic component composed from the headless `@clerk/headless` popover primitive plus
1212
slot recipes, and inherits the primitive's open/close behavior, focus management, and ARIA wiring. This
13-
first pass is presentational: the parts render from the props on `AccountButtonRoot` (mock data in the
14-
examples). A `useAccountButtonController()` that reads live Clerk resources is a drop-in follow-up.
13+
`AccountButtonView` is presentational: the parts render from the props on `AccountButtonRoot` (mock data
14+
in the examples). The connected `AccountButton` wraps it with `useAccountButtonController()`, which reads
15+
live Clerk resources and needs no props.
1516

1617
## Example
1718

@@ -22,12 +23,13 @@ examples). A `useAccountButtonController()` that reads live Clerk resources is a
2223

2324
## Usage
2425

25-
The all-in-one `AccountButton` renders the trigger and popup from a single prop-driven call:
26+
The all-in-one, presentational `AccountButtonView` renders the trigger and popup from a single
27+
prop-driven call (the connected, Clerk-backed `AccountButton` wraps it and needs no props):
2628

2729
```tsx
28-
import { AccountButton } from '@clerk/ui/mosaic/account/account-button.view';
30+
import { AccountButtonView } from '@clerk/ui/mosaic/account/account-button.view';
2931

30-
<AccountButton
32+
<AccountButtonView
3133
status='ready'
3234
activeAccount={{ sessionId: 'sess_1', userId: 'user_1', name: 'Preston Booth', email: 'preston@clerk.dev' }}
3335
activeOrganizationId='org_clerk_app'

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** @jsxImportSource @emotion/react */
2-
import { AccountButton, type AccountButtonProps } from '@clerk/ui/mosaic/account/account-button.view';
2+
import { type AccountButtonProps, AccountButtonView } from '@clerk/ui/mosaic/account/account-button.view';
33

44
import type { StoryMeta } from '@/lib/types';
55

@@ -35,7 +35,7 @@ const preston = { sessionId: 'sess_1', userId: 'user_1', name: 'Preston Booth',
3535

3636
export function Default(_args: Record<string, unknown>) {
3737
return (
38-
<AccountButton
38+
<AccountButtonView
3939
{...handlers}
4040
status='ready'
4141
activeAccount={preston}
@@ -63,7 +63,7 @@ export function Default(_args: Record<string, unknown>) {
6363

6464
export function Personal(_args: Record<string, unknown>) {
6565
return (
66-
<AccountButton
66+
<AccountButtonView
6767
{...handlers}
6868
status='ready'
6969
activeAccount={{
@@ -86,7 +86,7 @@ export function Personal(_args: Record<string, unknown>) {
8686

8787
export function MultipleAccounts(_args: Record<string, unknown>) {
8888
return (
89-
<AccountButton
89+
<AccountButtonView
9090
{...handlers}
9191
status='ready'
9292
activeAccount={preston}

0 commit comments

Comments
 (0)