A composer with reply and note modes
A help desk, a shared inbox
The composer draws the modes itself, on its text's start edge; the note mode tints it a faint warm yellow and names the send "Add note"; a posted note is ChatMessage variant="note", a faint warm box under "Internal note".
Show the code46 lines
TSX
import { useState } from 'react';
import { ChatMessage } from '@/components/ui/goop/chat-message';
import {
Composer,
ComposerActions,
ComposerEditor,
type ComposerMode,
ComposerSubmit,
ComposerToolbar,
} from '@/components/ui/goop/composer';
const MODES: ComposerMode[] = [
{ value: 'reply', label: 'Reply', placeholder: 'Write to the customer…' },
{ value: 'note', label: 'Internal note', variant: 'note', placeholder: 'Only your team sees this…', submitLabel: 'Add note' },
];
export function ReplyBox({ onSend }: { onSend: (text: string, note: boolean) => void }) {
const [mode, setMode] = useState('reply');
const [draft, setDraft] = useState('');
return (
<Composer
variant="reply"
aria-label="Reply"
modes={MODES}
mode={mode}
onModeChange={setMode}
onSubmit={(event) => {
event.preventDefault();
if (draft.trim()) onSend(draft.trim(), mode === 'note');
setDraft('');
}}
>
<ComposerEditor aria-label="Message" value={draft} onChange={(event) => setDraft(event.target.value)} />
<ComposerToolbar>
<ComposerActions>
<ComposerSubmit aria-label="Send reply" disabled={!draft.trim()} />
</ComposerActions>
</ComposerToolbar>
</Composer>
);
}
// in the thread, a posted note:
<ChatMessage from="self" author="You" time="09:24" variant="note">
Replacement goes out on Friday.
</ChatMessage>;The whole inbox around it (the list, the thread, this reply box and the customer's panel) is docs/screen-inbox.md.