mirror of
https://github.com/johndoe6345789/metabuilder.git
synced 2026-04-24 13:54:57 +00:00
feat(fakemui): add email navigation components
This commit is contained in:
54
fakemui/react/components/email/navigation/AccountTabs.tsx
Normal file
54
fakemui/react/components/email/navigation/AccountTabs.tsx
Normal 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'
|
||||
@@ -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'
|
||||
2
fakemui/react/components/email/navigation/index.ts
Normal file
2
fakemui/react/components/email/navigation/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export { AccountTabs, type AccountTabsProps, type EmailAccount } from './AccountTabs'
|
||||
export { FolderNavigation, type FolderNavigationProps, type FolderNavigationItem } from './FolderNavigation'
|
||||
Reference in New Issue
Block a user