diff --git a/fakemui/react/components/email/atoms/AttachmentIcon.tsx b/fakemui/react/components/email/atoms/AttachmentIcon.tsx new file mode 100644 index 000000000..361d44eec --- /dev/null +++ b/fakemui/react/components/email/atoms/AttachmentIcon.tsx @@ -0,0 +1,47 @@ +import React, { forwardRef } from 'react' +import { useAccessible } from '@metabuilder/fakemui/hooks' + +export interface AttachmentIconProps extends React.SVGAttributes { + filename?: string + mimeType?: string + testId?: string +} + +export const AttachmentIcon = forwardRef( + ({ filename, mimeType, testId: customTestId, ...props }, ref) => { + const accessible = useAccessible({ + feature: 'email', + component: 'attachment-icon', + identifier: customTestId || filename || 'attachment' + }) + + // Determine icon based on mime type + const getIconContent = () => { + if (mimeType?.startsWith('image/')) return '🖼️' + if (mimeType?.startsWith('video/')) return '🎬' + if (mimeType?.startsWith('audio/')) return '🎵' + if (mimeType === 'application/pdf') return '📄' + return '📎' + } + + return ( + + + {getIconContent()} + + + ) + } +) + +AttachmentIcon.displayName = 'AttachmentIcon' diff --git a/fakemui/react/components/email/atoms/MarkAsReadCheckbox.tsx b/fakemui/react/components/email/atoms/MarkAsReadCheckbox.tsx new file mode 100644 index 000000000..5bd6b2085 --- /dev/null +++ b/fakemui/react/components/email/atoms/MarkAsReadCheckbox.tsx @@ -0,0 +1,42 @@ +import React, { forwardRef, useState } from 'react' +import { useAccessible } from '@metabuilder/fakemui/hooks' + +export interface MarkAsReadCheckboxProps extends React.InputHTMLAttributes { + isRead?: boolean + onToggleRead?: (read: boolean) => void + testId?: string +} + +export const MarkAsReadCheckbox = forwardRef( + ({ isRead = false, onToggleRead, testId: customTestId, ...props }, ref) => { + const [read, setRead] = useState(isRead) + + const accessible = useAccessible({ + feature: 'email', + component: 'read-checkbox', + identifier: customTestId || 'read-status' + }) + + const handleChange = (e: React.ChangeEvent) => { + const newState = e.target.checked + setRead(newState) + onToggleRead?.(newState) + props.onChange?.(e) + } + + return ( + + ) + } +) + +MarkAsReadCheckbox.displayName = 'MarkAsReadCheckbox' diff --git a/fakemui/react/components/email/atoms/StarButton.tsx b/fakemui/react/components/email/atoms/StarButton.tsx new file mode 100644 index 000000000..60ade89dd --- /dev/null +++ b/fakemui/react/components/email/atoms/StarButton.tsx @@ -0,0 +1,43 @@ +import React, { forwardRef, useState } from 'react' +import { useAccessible } from '@metabuilder/fakemui/hooks' + +export interface StarButtonProps extends React.ButtonHTMLAttributes { + isStarred?: boolean + onToggleStar?: (starred: boolean) => void + testId?: string +} + +export const StarButton = forwardRef( + ({ isStarred = false, onToggleStar, testId: customTestId, ...props }, ref) => { + const [starred, setStarred] = useState(isStarred) + + const accessible = useAccessible({ + feature: 'email', + component: 'star-button', + identifier: customTestId || 'star' + }) + + const handleClick = (e: React.MouseEvent) => { + const newState = !starred + setStarred(newState) + onToggleStar?.(newState) + props.onClick?.(e) + } + + return ( + + ) + } +) + +StarButton.displayName = 'StarButton' diff --git a/fakemui/react/components/email/atoms/index.ts b/fakemui/react/components/email/atoms/index.ts new file mode 100644 index 000000000..500865bf3 --- /dev/null +++ b/fakemui/react/components/email/atoms/index.ts @@ -0,0 +1,3 @@ +export { AttachmentIcon, type AttachmentIconProps } from './AttachmentIcon' +export { StarButton, type StarButtonProps } from './StarButton' +export { MarkAsReadCheckbox, type MarkAsReadCheckboxProps } from './MarkAsReadCheckbox'