Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .changeset/user-profile-panel-shell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
1 change: 1 addition & 0 deletions packages/swingset/src/components/DocsViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ViewSource } from './ViewSource';
const docModules: Record<string, Record<string, React.ComponentType>> = {
user: {
'user-button': dynamic(() => import('../stories/user-button.mdx')),
'user-profile-profile-panel': dynamic(() => import('../stories/user-profile-profile-panel.mdx')),
'user-profile-account-section': dynamic(() => import('../stories/user-profile-account-section.mdx')),
'user-profile-connected-accounts-section': dynamic(
() => import('../stories/user-profile-connected-accounts-section.mdx'),
Expand Down
9 changes: 9 additions & 0 deletions packages/swingset/src/lib/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@ import {
Default as UserProfileDeleteSectionDefault,
meta as userProfileDeleteSectionMeta,
} from '../stories/user-profile-delete-section.stories';
import {
Default as UserProfileProfilePanelDefault,
meta as userProfileProfilePanelMeta,
} from '../stories/user-profile-profile-panel.stories';
import {
Default as UserProfileWeb3WalletsSectionDefault,
meta as userProfileWeb3WalletsSectionMeta,
Expand Down Expand Up @@ -224,6 +228,10 @@ const userProfileAccountSectionModule: StoryModule = {
meta: userProfileAccountSectionMeta,
Default: UserProfileAccountSectionDefault,
};
const userProfileProfilePanelModule: StoryModule = {
meta: userProfileProfilePanelMeta,
Default: UserProfileProfilePanelDefault,
};
const userProfileConnectedAccountsSectionModule: StoryModule = {
meta: userProfileConnectedAccountsSectionMeta,
Default: UserProfileConnectedAccountsSectionDefault,
Expand All @@ -240,6 +248,7 @@ const userProfileDeleteSectionModule: StoryModule = {
export const registry: StoryModule[] = [
// User
userButtonModule,
userProfileProfilePanelModule,
userProfileAccountSectionModule,
userProfileConnectedAccountsSectionModule,
userProfileWeb3WalletsSectionModule,
Expand Down
71 changes: 71 additions & 0 deletions packages/swingset/src/stories/user-profile-profile-panel.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import * as UserProfileProfilePanelStories from './user-profile-profile-panel.stories';

# UserProfileProfilePanel

The Profile panel from UserProfile, composed without the surrounding navigation shell. The
presentational view uses `Section` for its account details, connected accounts, Web3 wallets, and danger zone
while preserving the existing resource props and callback seams.

## Example

<Story
name='Default'
storyModule={UserProfileProfilePanelStories}
composition={[
{ name: 'Section', href: '/components/section', layer: 'Components' },
{ name: 'Avatar', href: '/components/avatar', layer: 'Components' },
]}
/>

## Usage

```tsx
import { UserProfileProfilePanelView } from '@clerk/ui/mosaic/user-profile/user-profile-profile-panel.view';

<UserProfileProfilePanelView
imageUrl={user.imageUrl}
name={user.fullName ?? ''}
username={user.username ?? ''}
emails={user.emailAddresses.map(email => ({
id: email.id,
value: email.emailAddress,
isDefault: email.id === user.primaryEmailAddressId,
isVerified: email.verification.status === 'verified',
}))}
phones={user.phoneNumbers.map(phone => ({
id: phone.id,
value: phone.phoneNumber,
isDefault: phone.id === user.primaryPhoneNumberId,
isVerified: phone.verification.status === 'verified',
}))}
connectedAccounts={user.externalAccounts.map(account => ({
id: account.id,
provider: account.provider,
identifier: account.emailAddress,
connected: true,
}))}
web3Wallets={supportedWeb3Wallets.map(provider => {
const wallet = user.web3Wallets.find(wallet => wallet.provider === provider.id);

return {
id: provider.id,
provider: provider.name,
iconUrl: provider.iconUrl,
address: wallet?.web3Wallet,
connected: Boolean(wallet),
isPrimary: wallet?.id === user.primaryWeb3WalletId,
isVerified: wallet ? wallet.verification.status === 'verified' : undefined,
};
})}
onVerifyEmail={verifyEmail}
onSetPrimaryEmail={setPrimaryEmail}
onRemoveEmail={removeEmail}
onVerifyPhone={verifyPhone}
onSetPrimaryPhone={setPrimaryPhone}
onRemovePhone={removePhone}
onRemoveConnectedAccount={removeConnectedAccount}
onConnectWeb3Wallet={connectWeb3Wallet}
onSetPrimaryWeb3Wallet={setPrimaryWeb3Wallet}
onRemoveWeb3Wallet={removeWeb3Wallet}
/>
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { UserProfileProfilePanelView } from '@clerk/ui/mosaic/user-profile/user-profile-profile-panel.view';

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

const providerIconUrl = (provider: string) => `https://img.clerk.com/static/${provider}.svg`;
const profileImageUrl = 'https://avatars.githubusercontent.com/u/51144033?v=4';

export { default as __source } from './user-profile-profile-panel.stories?raw';

export const meta: StoryMeta = {
group: 'User',
title: 'UserProfileProfilePanel',
source: 'packages/ui/src/mosaic/user-profile/user-profile-profile-panel.view.tsx',
};

export function Default(_args: Record<string, unknown>) {
return (
<UserProfileProfilePanelView
emails={[
{ id: 'email_1', value: 'item1@clerk.dev', isDefault: true, isVerified: true },
{ id: 'email_2', value: 'item2@clerk.dev', isVerified: true },
]}
connectedAccounts={[
{
id: 'google',
provider: 'Google',
identifier: 'test@google.com',
iconUrl: providerIconUrl('google'),
connected: true,
},
{ id: 'apple', provider: 'Apple', iconUrl: providerIconUrl('apple'), connected: false },
]}
web3Wallets={[
{
id: 'metamask',
address: '0x71C7656EC7ab88b098defB751B7401B5f6d8976F',
provider: 'MetaMask',
iconUrl: providerIconUrl('metamask'),
isPrimary: true,
isVerified: true,
},
{
id: 'coinbase-wallet',
provider: 'Coinbase Wallet',
iconUrl: providerIconUrl('coinbase_wallet'),
connected: false,
},
]}
imageUrl={profileImageUrl}
name='Preston Booth'
phones={[{ id: 'phone_1', value: '+1 801-888-8181', isDefault: true, isVerified: true }]}
username='prestonxyz'
onAddEmail={() => undefined}
onAddPhone={() => undefined}
onConnectAccount={() => undefined}
onDeleteAccount={() => undefined}
onEditProfilePicture={() => undefined}
onRemoveConnectedAccount={() => undefined}
onRemoveEmail={() => undefined}
onRemovePhone={() => undefined}
onConnectWeb3Wallet={() => undefined}
onRemoveWeb3Wallet={() => undefined}
onSetPrimaryWeb3Wallet={() => undefined}
onSetPrimaryEmail={() => undefined}
onSetPrimaryPhone={() => undefined}
onVerifyEmail={() => undefined}
onVerifyPhone={() => undefined}
onNameChange={() => undefined}
onUsernameChange={() => undefined}
/>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import * as Stories from './user-profile-web3-wallets-section.stories';

# UserProfileWeb3WalletsSection

Web3 wallet identities, verification state, primary status, and wallet actions.
Supported Web3 wallet providers with per-provider connection actions, connected identities, verification state,
primary status, and wallet actions.

<Story
name='Default'
Expand Down
Loading
Loading