A conversation's name, topic, members, call button, notification settings and tabs.
design-crit
Post work in progress. Be kind, be specific.
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { ChannelHeader, ChannelTab, NotifyLevel } from "./ui/uicontext/components/kit/ChannelHeader.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"import { ben, dana, mira } from "./chat.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 52rem)", overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg },})const Message = UiSchema.TaggedEnum({ ChoseTab: { tab: ChannelTab }, ChoseNotify: { level: NotifyLevel }, ToggledMute: { muted: Schema.Boolean }, JoinedCall: {},})// Switch tabs, set what notifies you from the ⋯ menu, and join the call going onexport const DesignCritHeader = Html.component({ name: "DesignCritHeader", model: Schema.Struct({ tab: ChannelTab, notify: NotifyLevel, muted: Schema.Boolean, joined: Schema.Boolean }), message: Message,}).make({ init: () => ({ tab: "messages" as const, notify: "all" as const, muted: false, joined: false }), update: { ChoseTab: ($, { tab }) => $.evolve({ tab }), ChoseNotify: ($, { level }) => $.evolve({ notify: level }), ToggledMute: ($, { muted }) => $.evolve({ muted }), JoinedCall: ($) => $.evolve({ joined: true }), }, view: (h, model) => h.div.attrs(sx(styles.frame)).children(ChannelHeader(h, { props: { name: "design-crit", kind: "public", topic: "Post work in progress. Be kind, be specific.", members: { total: 14, faces: [mira, dana, ben] }, call: { people: model.joined ? 3 : 2, joined: model.joined }, notify: model.notify, muted: model.muted, tab: model.tab, files: 12, pins: 2, }, onEmit: { RequestedTab: ({ tab }) => Message.ChoseTab({ tab }), RequestedNotify: ({ level }) => Message.ChoseNotify({ level }), RequestedMute: ({ muted }) => Message.ToggledMute({ muted }), RequestedCall: () => Message.JoinedCall(), RequestedMembers: () => undefined, RequestedCopyLink: () => undefined, }, })),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/channel-headerUsage
import { ChannelHeader, ChannelTab, NotifyLevel } from "./ui/uicontext/components/kit/ChannelHeader.ts"const Message = UiSchema.TaggedEnum({ ChoseTab: { tab: ChannelTab }, ChoseNotify: { level: NotifyLevel }, ToggledMute: { muted: Schema.Boolean }, StartedCall: {},})export const Header = (h: Html.H<typeof Message.Type>, tab: ChannelTab, notify: NotifyLevel, muted: boolean) => ChannelHeader(h, { props: { name: "general", kind: "public", topic: "Company-wide news.", members: { total: 58, faces: [] }, call: null, notify, muted, tab }, onEmit: { RequestedTab: ({ tab }) => Message.ChoseTab({ tab }), RequestedNotify: ({ level }) => Message.ChoseNotify({ level }), RequestedMute: ({ muted }) => Message.ToggledMute({ muted }), RequestedCall: () => Message.StartedCall(), RequestedMembers: () => undefined, RequestedCopyLink: () => undefined, }, })Examples
Direct message
import type { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { ChannelHeader } from "./ui/uicontext/components/kit/ChannelHeader.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { color, radius } from "./ui/uicontext/components/tokens.stylex.ts"import { ben, maya } from "./chat.ts"const styles = stylex.create({ frame: { inlineSize: "min(100%, 26rem)", overflow: "hidden", borderWidth: 1, borderStyle: "solid", borderColor: color.line, borderRadius: radius.lg },})// A DM on a phone: their face, presence and status, a Back link, and Call; the topic and faces give wayexport const DirectMessageHeader = <M>(h: Html.H<M>) => h.div.attrs(sx(styles.frame)).children(ChannelHeader(h, { props: { name: "Ben Okafor", kind: "dm", id: "ben", presence: "active", status: "📍", members: { total: 2, faces: [ben, maya] }, call: null, notify: "all", muted: false, tab: "messages", back: "#dms", }, onEmit: { RequestedTab: () => undefined, RequestedNotify: () => undefined, RequestedMute: () => undefined, RequestedCall: () => undefined, RequestedMembers: () => undefined, RequestedCopyLink: () => undefined, }, }))API reference
Props
| Name | Type | Description |
|---|---|---|
namerequired | string | The channel's name without "#", or the person's name |
kindrequired | ConversationKind | — |
id | string | The conversation's id: a DM's face is drawn from it |
topic | string | — |
presence | Presence | A DM's person: whether they're here, and their status |
status | string | — |
membersrequired | { total, faces } | — |
callrequired | { people, joined } | null | A call in this conversation: who's in it, and whether the reader is |
notifyrequired | NotifyLevel | — |
mutedrequired | boolean | — |
tabrequired | ChannelTab | — |
files | number | — |
pins | number | — |
back | string | A printed route: on a phone, the Back link that leads to the list |
agentId | string | — |
Events
| Event | Payload | Description |
|---|---|---|
RequestedTab | { tab: ChannelTab } | — |
RequestedCall | {} | Start a call here, or join the one going on |
RequestedMembers | {} | — |
RequestedNotify | { level: NotifyLevel } | — |
RequestedMute | { muted: boolean } | — |
RequestedCopyLink | {} | Copy the conversation's link |
Agent actions
| Action | Description |
|---|---|
ClickedTab | Show the conversation's messages, files or pins |
ClickedCall | Start a call in this conversation, or join the one going on |
PickedNotifyLevel | Set notifications: group "notify", value all, mentions or nothing |
Accessibility
- The name is a heading; the members, call and options are named buttons, and the call button says when a call is going on.
- Messages, Files and Pins are tabs; notifications are a radio group in the options menu, and Mute a checkbox item.