feat(fakemui): add email navigation components

This commit is contained in:
2026-01-23 19:33:29 +00:00
parent 8d52f641b2
commit 468a8bdf7a
3 changed files with 112 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
import React, { forwardRef } from 'react'
import { Tabs, Tab, TabsProps } from '../..'
import { useAccessible } from '@metabuilder/fakemui/hooks'
export interface EmailAccount {
id: string
accountName: string
emailAddress: string
unreadCount?: number
}
export interface AccountTabsProps extends Omit<TabsProps, 'onChange'> {
accounts: EmailAccount[]
selectedAccountId?: string
onSelectAccount?: (accountId: string) => void
testId?: string
}
export const AccountTabs = forwardRef<HTMLDivElement, AccountTabsProps>(
({ accounts, selectedAccountId, onSelectAccount, testId: customTestId, ...props }, ref) => {
const accessible = useAccessible({
feature: 'email',
component: 'account-tabs',
identifier: customTestId || 'accounts'
})
return (
<Tabs
ref={ref}
value={selectedAccountId || (accounts[0]?.id ?? '')}
onChange={(_, value) => onSelectAccount?.(value as string)}
{...accessible}
{...props}
>
{accounts.map((account) => (
<Tab
key={account.id}
label={
<span className="account-tab">
<span className="account-name">{account.accountName}</span>
{account.unreadCount ? (
<span className="unread-badge">{account.unreadCount}</span>
) : null}
</span>
}
value={account.id}
/>
))}
</Tabs>
)
}
)
AccountTabs.displayName = 'AccountTabs'

View File

@@ -0,0 +1,56 @@
import React, { forwardRef } from 'react'
import { Box, BoxProps, Button } from '../..'
import { useAccessible } from '@metabuilder/fakemui/hooks'
export interface FolderNavigationItem {
id: string
label: string
icon?: string
unreadCount?: number
isActive?: boolean
}
export interface FolderNavigationProps extends BoxProps {
items: FolderNavigationItem[]
onNavigate?: (itemId: string) => void
testId?: string
}
export const FolderNavigation = forwardRef<HTMLDivElement, FolderNavigationProps>(
({ items, onNavigate, testId: customTestId, ...props }, ref) => {
const accessible = useAccessible({
feature: 'email',
component: 'folder-nav',
identifier: customTestId || 'folders'
})
return (
<Box
ref={ref}
className="folder-navigation"
{...accessible}
{...props}
>
<nav className="folder-nav-list">
{items.map((item) => (
<Button
key={item.id}
variant={item.isActive ? 'primary' : 'ghost'}
fullWidth
className="folder-nav-item"
onClick={() => onNavigate?.(item.id)}
>
{item.icon && <span className="folder-icon">{item.icon}</span>}
<span className="folder-label">{item.label}</span>
{item.unreadCount ? (
<span className="unread-count">{item.unreadCount}</span>
) : null}
</Button>
))}
</nav>
</Box>
)
}
)
FolderNavigation.displayName = 'FolderNavigation'

View File

@@ -0,0 +1,2 @@
export { AccountTabs, type AccountTabsProps, type EmailAccount } from './AccountTabs'
export { FolderNavigation, type FolderNavigationProps, type FolderNavigationItem } from './FolderNavigation'