SidebarStatusEntry
A sidebar entry that carries a status (phone): expanded it is a 36pt row shaped like a nav item, ending in status text and one persistent action; collapsed it is a 36pt icon with a status dot. Pressing it grows a GrowMenu in place.
Status: experimental · Components: SidebarStatusEntry
Import
Section titled “Import”import { SidebarStatusEntry } from 'nacre'trailing shows the status (offline / HK line · Online / an error), action holds one persistent IconButton xs outside the button (never nested); with menu it grows a menu in place like the account row, and checkable toggles set keepOpen so the menu stays.
import { Text, View, signal } from 'nsh'import { IconButton, PresenceDot, SidebarStatusEntry, TEXT_SIZE } from 'nacre'
export function SidebarStatusEntryUsage() { const open = signal(false) const online = signal(false) const title = () => 'Phone' const status = () => (online() ? 'HK line · Online' : 'Offline') return ( <View class="w-[240px] p-2 rounded-xl border border-border"> <SidebarStatusEntry testID="sidebar-status" title={title()} label={`${title()} · ${status()}`} icon="headset" collapsed={false} trailing={() => <Text class={`truncate ${TEXT_SIZE.small} text-muted-foreground`}>{status()}</Text>} overlay={(inMenu) => <If when={online()}><PresenceDot ring kind="online" label={status()} testID={inMenu ? undefined : 'sidebar-status-dot'} /></If>} action={<IconButton testID="sidebar-status-action" size="xs" surface="chrome" icon="phone" label="Dial" onPress={() => {}} />} onPress={() => open.set(true)} menu={{ open: open(), onClose: () => open.set(false), testID: 'sidebar-status-menu', closeTestID: 'sidebar-status-close', items: [ { label: 'HK line', checked: online(), keepOpen: true, onSelect: () => online.set(!online()) }, { type: 'separator' }, { label: 'Dial…', shortcut: '⌃⌘N', disabled: !online(), onSelect: () => {} }, ], }} /> </View> )}Examples
Section titled “Examples”With the sidebar collapsed
Section titled “With the sidebar collapsed”Only the icon remains, with the overlay status dot at its bottom-right (like the avatar dot); the menu still opens 240 wide. leading replaces the icon with a timer (in a call), usually opening a popover via onPress instead of a menu.
import { Text, View, signal } from 'nsh'import { PresenceDot, SidebarStatusEntry, TEXT_SIZE } from 'nacre'
export function SidebarStatusEntryCollapsed() { const open = signal(false) const title = () => 'Phone' const status = () => 'Break' return ( <View class="flex-row gap-3 p-2 rounded-xl border border-border"> <SidebarStatusEntry testID="sidebar-status-collapsed" title={title()} label={`${title()} · ${status()}`} icon="headset" collapsed trailing={() => <Text class={`${TEXT_SIZE.small} text-muted-foreground`}>{status()}</Text>} overlay={() => <PresenceDot ring kind="break" label={status()} />} onPress={() => open.set(true)} menu={{ open: open(), onClose: () => open.set(false), items: [{ label: 'HK line', checked: true, keepOpen: true, onSelect: () => {} }] }} /> <SidebarStatusEntry title={title()} label="Phone · In call 02:31" icon="headset" collapsed leading={<Text class={`${TEXT_SIZE.caption} tabular-nums text-sidebar-foreground`}>02:31</Text>} onPress={() => {}} /> </View> )}Keyboard
Section titled “Keyboard”| Key | Action |
|---|---|
| ↑ / ↓ / Home / End | Up, Down, Home and End move between enabled items and the close row. End focuses the close row. |
| Tab | Focus the entry; the trailing action is the next stop |
| Space / Return | Open the menu (or run onPress) |
| Esc | Close the menu and return focus to the entry |
Accessibility
Section titled “Accessibility”- label is required, reads as a button and should include the current status; the open state reads as expanded.
- The trailing action is its own button with its own name, not nested in the entry.
- Give the status dot a label; the copy in the menu footer carries no testID.
Do / Don’t
Section titled “Do / Don’t”Do
- Match sidebar nav items and the account row: flat on the window material, no card
- Use warning-text trailing text for errors
- Set keepOpen on checkable toggles
Don’t
- Nest interactive controls in the row (use action)
- Paint solid status colors behind it
Property descriptions follow the Chinese source comments.
SidebarStatusEntry
Section titled “SidebarStatusEntry”| Prop | Type | Default | Description |
|---|---|---|---|
label * |
string |
— | |
icon * |
IconName |
— | |
expanded |
boolean |
— | |
tone |
'default' | 'inverse' | 'connected' | 'ringing' |
— | 接通时图标用成功色,振铃时同时淡染背景。inverse 适用于强调入口。 |
overlay |
JSX.Element | ((inMenu: boolean) => JSX.Element) |
— | |
viewRef |
(node: ViewRef) => void |
— | |
testID |
string |
— | |
title |
string |
— | 展开时行里的可见标题(「电话」) |
collapsed |
boolean |
— | 侧栏收成图标栏:只剩 36 见方的图标 + 状态点 |
trailing |
(inMenu: boolean) => JSX.Element |
— | 行尾状态(展开时显示、不可点):状态文字、计时。inMenu 为真时画在菜单底行,不要再挂 testID |
action |
JSX.Element |
— | 行尾常驻操作(IconButton xs):在按钮之外,不嵌套可点控件;只在展开时显示,菜单开着时被面板盖住 |
leading |
JSX.Element |
— | 收起时代替图标的内容(通话计时),居中放在 36 见方里 |
onPress |
() => void |
— | |
menu |
SidebarStatusEntryMenu |
— | 按下原地长出的菜单(GrowMenu,同 SidebarAccount):底行压在这一行上,同位同内容 |
* required