Communication
A messaging app in three panels: the chat list, the conversation and the contact details.
Frame · Sidebar. <AppShell direction="frame">: the navigation on a grey tint; the page white and full-bleed.
npx wideset add block-communication
Import the default export from @/blocks/wideset/communication. The files below are relative to your project's source directory.
Installed with this block
app-shellavatarblock-stylesbuttonchipdividerdropdown-menuicon-buttonlist-itemprogress-barradio-buttonsegmented-controlsidebarslidersplit-buttontabstagtext-inputtextareatoasttooltiputils
blocks/wideset/communication/index.tsx
'use client';
import '@/styles/wideset-blocks.css';
import { AppShell } from '@/components/ui/wideset/app-shell/AppShell';
import { Toast } from '@/components/ui/wideset/toast/Toast';
import { ToastProvider, useToast } from '@/components/ui/wideset/toast/Toast.context';
import { useState } from 'react';
import { ChatList } from './chat-list';
import { ContactPanel } from './contact-panel';
import { Conversation } from './conversation';
import { conversation } from './data';
import { CommunicationSidebar } from './sidebar';
/** The page: three panels split by lines, the contact panel closable. */
function Panels() {
const { showToast, dismissToast } = useToast();
const [details, setDetails] = useState(true);
const [note, setNote] = useState('');
const archive = () => {
const id = showToast({
status: 'info',
content: `${conversation.title} archived`,
action: (
<Toast.Action preset="ghost" onClick={() => dismissToast(id)}>
Undo
</Toast.Action>
),
});
};
return (
<main className="flex min-w-0 flex-1">
<ChatList />
<Conversation
onArchive={archive}
onShowDetails={details ? undefined : () => setDetails(true)}
/>
{details && (
<ContactPanel
onClose={() => setDetails(false)}
onArchive={archive}
note={note}
onNoteChange={setNote}
/>
)}
</main>
);
}
/** Communication (Frame direction): chats, the open conversation and the contact's details. */
export default function Communication() {
return (
<ToastProvider position="bottom-center">
<AppShell className="ws-block-utility" direction="frame">
<CommunicationSidebar />
<Panels />
</AppShell>
</ToastProvider>
);
}