defuss-shadcn / Application / Scaffolds / scaffold-messenger
Messenger
A WhatsApp-style messenger as a clickdummy - "Relay". Open a chat, type and press ↵: the message goes out, its ticks turn blue, the other side types and answers. Filter the list, play a voice note, start a call, open the contact info, switch to dark mode. Every control is a shipped component. Part of the Application Scaffolds.
On this page (2)
§Messenger
The whole messenger in one source. Chats are routes (#/chats/anna…) of defuss-dom-router; Settings › App language translates the chrome with defuss-i18n; the rail, the filter chips and the contact-info column are radio and checkbox state read by :has(); conversations are the Session component; sending, read receipts, typing and replies are a few lines of script.
§How it works
A page, not a component: it composes the library and keeps its own glue small.
- Layout - a rail, the chat list, the conversation and an optional contact-info column in one grid; below 48rem of width you see the list or the chat, with a back link.
- Resizable list - the chat list sits in a Resizer with
data-variant="divider": drag its edge, or Tab to it and press the left or right arrow key; a double-click restores the default width, and the width you chose is remembered. - Routing - defuss-dom-router in hash mode:
#/is the list,#/chats/:ida chat (the:idparameter names its thread); the commit shows that thread, marks its row read and current, fills the info column and, below 48rem, swaps the list for the chat. Back and forward work, chats are linkable. Inside the docs preview the same routes match the frame's hash. See Client-side Routing. - Translation - defuss-i18n: Settings › App language switches the rail, the list, the panels, the info column and every label that names a contact (attribute variants:
data-i18n-aria-label-de) between English and German. Messages, toasts and replies stay as they were written. See Translation. - CSS state - the rail tabs, the filter chips (All / Unread / Favourites / Groups), the contact-info column, the voice-note player and the composer's mic / send swap (
:placeholder-shown) are form state read by:has(). - Conversations - the Session component scrolls each transcript and follows new messages; rows are Bubbles with tails and reactions, Markers for the day separators, a Message attachment for the file; delivery ticks use the Message status.
- Composer - the Textarea group grows with the text; the emoji panel is a Popover, the attach menu a Dropdown.
- Calls and info - a Dialog that rings and then times the call; the info column has Switches and Toast feedback.
- Script - sending (one tick, then two, then two blue ones, "typing...", a reply), the unread badges, the search, emoji insertion, the call timer and the dark-mode switch.
- Full screen - app-messenger.html is generated from this page's example at build time.
Comments, ideas or improvements? Edit this page's source on GitHub