refactor(clues): browse and pack rows use the shared row/state components
The pack shelf and the browse results each carried their own row shell, their own empty state and their own error+retry line. They now share ListRow, EmptyState and ErrorBlock, and the local copies are gone. ListRow grew the two contracts those callers actually need: - titleLabel so the accessible name can be "Manage pack: X" while the visible title stays "X"; - primary so the roving-focus marker (data-list-primary + its tab stop) lands on the title button, which is what useListNavigation focuses; - a navigating row keeps name + subtitle inside that button, so the whole two-line caption is one click target and one accessible name. Removed from clues-tab.module.css: the .packRow/.packOpen/.packGlyph/ .packName/.packMeta/.packCount/.packReference family plus the two coarse- pointer orphans left behind. tests/clues-tab-css.spec.ts now asserts that contract against the shared patterns sheet, where the rules actually live.
This commit is contained in:
1 parent
9056ea2c7c
commit
0edd9e9e81
7 files changed
+194
-212
No files matched your search
@@ -71,7 +71,9 @@ import {
|
||||
} from './browser-shared.tsx'
|
||||
import { ResourceInlineMeta } from '../resource-summary.tsx'
|
||||
import { ResourceFilters, resourceFilterState } from '../resource-filters.tsx'
|
||||
import { ActionButton, IconButton, Checkbox, Menu, SearchField } from '../../ui/index.ts'
|
||||
import {
|
||||
ActionButton, Checkbox, EmptyState, ErrorBlock, IconButton, ListRow, Menu, SearchField,
|
||||
} from '../../ui/index.ts'
|
||||
import { useListNavigation } from '../../ui/use-list-navigation.ts'
|
||||
import { SourceReadiness } from '../sources/readiness.tsx'
|
||||
import { WorkbenchSection } from '../../ui/WorkbenchSection.tsx'
|
||||
@@ -1208,13 +1210,15 @@ export function ClueBrowser(props: ClueBrowserProps): ReactNode {
|
||||
</div>
|
||||
)}
|
||||
{state.kind === 'page' && state.result.items.length === 0 && (
|
||||
<div className={css.emptyState}>
|
||||
<IconSearchOutlineRegular className={css.emptyIcon} size={24} />
|
||||
<p>{state.view.kind === 'search' || filters?.active === true ? t('clueBrowserNoResults') : t('clueBrowserEmpty')}</p>
|
||||
{filters?.active === true && <ActionButton onClick={() => { changeFilter(filters.clearedScope) }}>{t('clueClearFilters')}</ActionButton>}
|
||||
{state.view.kind === 'search' && <ActionButton
|
||||
onClick={() => { setQuery(''); setView({ kind: 'list' }); queryInputRef.current?.focus() }}>{t('clueClearSearch')}</ActionButton>}
|
||||
</div>
|
||||
<EmptyState
|
||||
icon={<IconSearchOutlineRegular size={24} />}
|
||||
title={state.view.kind === 'search' || filters?.active === true ? t('clueBrowserNoResults') : t('clueBrowserEmpty')}
|
||||
actions={<>
|
||||
{filters?.active === true && <ActionButton size="sm" onClick={() => { changeFilter(filters.clearedScope) }}>{t('clueClearFilters')}</ActionButton>}
|
||||
{state.view.kind === 'search' && <ActionButton size="sm"
|
||||
onClick={() => { setQuery(''); setView({ kind: 'list' }); queryInputRef.current?.focus() }}>{t('clueClearSearch')}</ActionButton>}
|
||||
</>}
|
||||
/>
|
||||
)}
|
||||
{state.kind === 'resolved' && (
|
||||
<div className={css.resolveHead}>
|
||||
@@ -1241,52 +1245,51 @@ export function ClueBrowser(props: ClueBrowserProps): ReactNode {
|
||||
const pinned = rowPinned(candidate)
|
||||
const key = candidateKey(candidate)
|
||||
return (
|
||||
<li key={key} className={css.resultRow} data-pinned={pinned ? 'true' : 'false'} data-selected={selected.has(key)} data-pending={pendingAction?.key === key || undefined} aria-busy={pendingAction?.key === key || undefined}
|
||||
<li key={key} data-pinned={pinned ? 'true' : 'false'} data-pending={pendingAction?.key === key || undefined}
|
||||
onContextMenu={event => { openRowMenu(event, candidate) }}
|
||||
onKeyDown={event => { rowMenuKey(event, candidate) }}>
|
||||
{selectionMode && <label className={css.rowSelection}>
|
||||
<Checkbox
|
||||
checked={selected.has(key)}
|
||||
disabled={busy}
|
||||
aria-label={t('clueBrowserSelectRow', { title: candidate.title })}
|
||||
onChange={() => { selectionToggle(candidate) }}
|
||||
/>
|
||||
</label>}
|
||||
<span className={css.rowGlyph} aria-hidden="true">{resourceIcon(candidate, displays)}</span>
|
||||
<button
|
||||
type="button"
|
||||
className={css.rowTitle}
|
||||
data-list-primary tabIndex={navigation.itemTabIndex(index)}
|
||||
<ListRow
|
||||
selected={selected.has(key)}
|
||||
title={candidate.title}
|
||||
onClick={() => { previewCandidate(candidate) }}
|
||||
>
|
||||
<span className={css.rowName}>{candidate.title}</span>
|
||||
<span className={css.rowSubtitle}>
|
||||
titleLabel={candidate.title}
|
||||
titleAs="button"
|
||||
primary={navigation.itemTabIndex(index) === 0}
|
||||
onTitleClick={() => { previewCandidate(candidate) }}
|
||||
leading={<>
|
||||
{selectionMode && <label className={css.rowSelection}>
|
||||
<Checkbox
|
||||
checked={selected.has(key)}
|
||||
disabled={busy}
|
||||
aria-label={t('clueBrowserSelectRow', { title: candidate.title })}
|
||||
onChange={() => { selectionToggle(candidate) }}
|
||||
/>
|
||||
</label>}
|
||||
<span className={css.rowGlyph} aria-hidden="true">{resourceIcon(candidate, displays)}</span>
|
||||
</>}
|
||||
subtitle={<>
|
||||
<ResourceInlineMeta info={candidate.info} />
|
||||
{candidate.info?.state === undefined && candidate.info?.author === undefined && candidate.info?.branches === undefined && candidate.subtitle !== candidate.title ? candidate.subtitle : null}
|
||||
</span>
|
||||
</button>
|
||||
{pinned && <span className={css.pinnedBadge}>{t('clueBrowserPinnedBadge')}</span>}
|
||||
<span className={css.rowActions}>
|
||||
<button
|
||||
type="button"
|
||||
className={css.iconButton}
|
||||
aria-label={t('clueBrowserInsertRow', { title: candidate.title })}
|
||||
title={t('clueBrowserInsert')}
|
||||
disabled={busy}
|
||||
onClick={() => { void insertCandidate(candidate) }}
|
||||
>
|
||||
{pendingAction?.key === key && pendingAction.kind === 'insert'
|
||||
? <LoadingIndicator inline size={14} label="" role="presentation" /> : <IconContextInjectionOutlineRegular size={16} />}
|
||||
</button>
|
||||
<IconButton label={t('clueBrowserMoreRow', { title: candidate.title })} disabled={busy}
|
||||
aria-haspopup="menu" aria-expanded={rowMenu !== null && candidateKey(rowMenu.candidate) === key}
|
||||
icon={<span aria-hidden="true">···</span>}
|
||||
onClick={event => {
|
||||
const box = event.currentTarget.getBoundingClientRect()
|
||||
setRowMenu({ candidate, x: box.left, y: box.bottom })
|
||||
}} />
|
||||
</span>
|
||||
</>}
|
||||
meta={pinned ? <span className={css.pinnedBadge}>{t('clueBrowserPinnedBadge')}</span> : undefined}
|
||||
actions={<>
|
||||
<IconButton
|
||||
size="sm"
|
||||
label={t('clueBrowserInsertRow', { title: candidate.title })}
|
||||
title={t('clueBrowserInsert')}
|
||||
disabled={busy}
|
||||
onClick={() => { void insertCandidate(candidate) }}
|
||||
icon={pendingAction?.key === key && pendingAction.kind === 'insert'
|
||||
? <LoadingIndicator inline size={14} label="" role="presentation" /> : <IconContextInjectionOutlineRegular size={16} />}
|
||||
/>
|
||||
<IconButton label={t('clueBrowserMoreRow', { title: candidate.title })} disabled={busy}
|
||||
aria-haspopup="menu" aria-expanded={rowMenu !== null && candidateKey(rowMenu.candidate) === key}
|
||||
icon={<span aria-hidden="true">···</span>}
|
||||
onClick={event => {
|
||||
const box = event.currentTarget.getBoundingClientRect()
|
||||
setRowMenu({ candidate, x: box.left, y: box.bottom })
|
||||
}} />
|
||||
</>}
|
||||
/>
|
||||
</li>
|
||||
)
|
||||
})}
|
||||
@@ -1294,10 +1297,7 @@ export function ClueBrowser(props: ClueBrowserProps): ReactNode {
|
||||
)}
|
||||
<div ref={sentinelRef} className={css.loadSentinel} data-clue-result-sentinel>
|
||||
{moreLoading && <LoadingIndicator inline />}
|
||||
{moreError !== null && <div role="alert" className={css.stateLine}>
|
||||
<span>{moreError}</span>
|
||||
<button type="button" className={css.stateAction} onClick={loadMore}>{t('retry')}</button>
|
||||
</div>}
|
||||
{moreError !== null && <ErrorBlock message={moreError} retryLabel={t('retry')} onRetry={loadMore} />}
|
||||
</div>
|
||||
{state.kind === 'page' && state.result.limited === true && <div className={css.scopeHint}>
|
||||
{t('clueBrowserLimited')}
|
||||
|
||||
@@ -150,7 +150,6 @@
|
||||
.iconButton:hover:not(:disabled),
|
||||
.toolButton:hover:not(:disabled):not([aria-disabled='true']),
|
||||
.stateAction:hover:not(:disabled),
|
||||
.packReference:hover,
|
||||
.scopeButton:hover {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
color: var(--dsw-alias-label-primary);
|
||||
@@ -174,8 +173,6 @@
|
||||
.stateAction:focus-visible,
|
||||
.workspaceSelect:focus-visible,
|
||||
.scopeButton:focus-visible,
|
||||
.packOpen:focus-visible,
|
||||
.packReference:focus-visible,
|
||||
.rowTitle:focus-visible {
|
||||
outline: 2px solid var(--dsw-alias-brand-primary);
|
||||
outline-offset: 1px;
|
||||
@@ -239,74 +236,6 @@
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
.packRow {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
min-height: 30px;
|
||||
padding-inline: 6px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
.packRow:hover,
|
||||
.packRow:focus-within {
|
||||
background: var(--dsw-alias-interactive-bg-hover);
|
||||
}
|
||||
.packGlyph {
|
||||
flex: none;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
}
|
||||
.packOpen {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
min-height: 30px;
|
||||
box-sizing: border-box;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: var(--dsw-alias-label-primary);
|
||||
font: inherit;
|
||||
text-align: start;
|
||||
cursor: pointer;
|
||||
}
|
||||
.packOpen:focus-visible {
|
||||
outline-offset: -2px;
|
||||
}
|
||||
.packName {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-size: 13px;
|
||||
line-height: 20px;
|
||||
font-weight: 500;
|
||||
}
|
||||
.packMeta {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: none;
|
||||
gap: var(--ds-sidebar-space-2);
|
||||
min-height: 30px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.packMeta .packCount {
|
||||
max-width: 9ch;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
.packCount {
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
font-size: 11px;
|
||||
line-height: 16px;
|
||||
}
|
||||
.packReference {
|
||||
composes: iconButton iconButtonMd from '../../ui/kit.module.css';
|
||||
}
|
||||
.browserBody {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
@@ -798,15 +727,12 @@
|
||||
.searchBox .searchInput,
|
||||
.selectionReview summary,
|
||||
.querySubmit,
|
||||
.packOpen,
|
||||
.packReference,
|
||||
.iconButton {
|
||||
min-height: 44px;
|
||||
}
|
||||
.rowActions .iconButton,
|
||||
.iconButton,
|
||||
.querySubmit,
|
||||
.packReference {
|
||||
.querySubmit {
|
||||
width: 44px;
|
||||
}
|
||||
.resultRow,
|
||||
@@ -836,14 +762,6 @@
|
||||
scrollbar-width: thin;
|
||||
padding-block: 4px;
|
||||
}
|
||||
.packScroll > .emptyState {
|
||||
flex-direction: row;
|
||||
gap: var(--ds-sidebar-space-3);
|
||||
margin: 0;
|
||||
padding: var(--ds-sidebar-gutter);
|
||||
text-align: start;
|
||||
}
|
||||
.packScroll > .emptyState p { flex: 1; }
|
||||
.loadSentinel {
|
||||
min-height: 1px;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
|
||||
@@ -41,7 +41,10 @@ import { clueErrorMessage } from '../copy.ts'
|
||||
import { cluesApi, invalidateClueRequests, peekClueRequest } from '../api.ts'
|
||||
import { openCreatePackWindow } from '../windows/create-pack.tsx'
|
||||
import { openShareWindow } from '../windows/share.tsx'
|
||||
import { ActionButton, ConfirmDialog, IconButton, LoadingIndicator, Menu, SearchField } from '../../ui/index.ts'
|
||||
import {
|
||||
ActionButton, ConfirmDialog, EmptyState, ErrorBlock, IconButton, ListRow, LoadingIndicator, Menu,
|
||||
SearchField, StatusLine,
|
||||
} from '../../ui/index.ts'
|
||||
import { useScrollLoad } from '../../ui/use-scroll-load.ts'
|
||||
import { useListNavigation } from '../../ui/use-list-navigation.ts'
|
||||
import { t } from '../../locales.ts'
|
||||
@@ -383,26 +386,26 @@ export function CluePacksSection(props: CluePacksSectionProps): ReactNode {
|
||||
</div>
|
||||
|
||||
<div ref={scrollRef} className={css.packScroll} data-clue-pack-scroll>
|
||||
{phase === 'loading' && (
|
||||
<div className={css.stateLine}><LoadingIndicator inline /></div>
|
||||
)}
|
||||
{phase === 'loading' && <StatusLine plain text={<LoadingIndicator inline />} />}
|
||||
{error !== null && (
|
||||
<div className={css.stateLine} role="alert" data-clue-pack-error>
|
||||
<span>{error}</span>
|
||||
<button type="button" className={css.stateAction} onClick={() => {
|
||||
<ErrorBlock
|
||||
message={error}
|
||||
retryLabel={t('retry')}
|
||||
data-clue-pack-error
|
||||
onRetry={() => {
|
||||
invalidateClueRequests(workspaceId, 'clues.packs.list')
|
||||
void load()
|
||||
}}>{t('retry')}</button>
|
||||
</div>
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
{phase === 'ready' && visiblePacks.length === 0 && (
|
||||
<div className={css.emptyState}>
|
||||
<CluePackArtwork className={css.emptyIcon} size={24} />
|
||||
<p>{search.trim() === '' ? t('cluePacksEmpty') : t('cluePacksNoMatch')}</p>
|
||||
{search.trim() === ''
|
||||
? <button type="button" className={css.toolButton} onClick={openCreate}>{t('cluePacksNew')}</button>
|
||||
: <button type="button" className={css.toolButton} onClick={() => { setSearch(''); resetVisible() }}>{t('clueClearSearch')}</button>}
|
||||
</div>
|
||||
<EmptyState
|
||||
icon={<CluePackArtwork size={24} />}
|
||||
title={search.trim() === '' ? t('cluePacksEmpty') : t('cluePacksNoMatch')}
|
||||
actions={search.trim() === ''
|
||||
? <ActionButton size="sm" onClick={openCreate}>{t('cluePacksNew')}</ActionButton>
|
||||
: <ActionButton size="sm" onClick={() => { setSearch(''); resetVisible() }}>{t('clueClearSearch')}</ActionButton>}
|
||||
/>
|
||||
)}
|
||||
|
||||
{shown.length > 0 && (
|
||||
@@ -411,7 +414,6 @@ export function CluePacksSection(props: CluePacksSectionProps): ReactNode {
|
||||
{shown.map((pack, index) => (
|
||||
<li
|
||||
key={pack.id}
|
||||
className={css.packRow}
|
||||
onContextMenu={(event) => {
|
||||
setPackMenu({ pack, ...contextMenuPoint(event) })
|
||||
}}
|
||||
@@ -420,29 +422,25 @@ export function CluePacksSection(props: CluePacksSectionProps): ReactNode {
|
||||
if (point !== undefined) setPackMenu({ pack, ...point })
|
||||
}}
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
className={css.packOpen}
|
||||
data-list-primary tabIndex={navigation.itemTabIndex(index)}
|
||||
title={t('cluePacksManageAria', { name: pack.name })}
|
||||
aria-label={t('cluePacksManageAria', { name: pack.name })}
|
||||
onClick={() => { onOpenPack(pack) }}
|
||||
>
|
||||
<CluePackArtwork className={css.packGlyph} size={16} />
|
||||
<span className={css.packName} data-clue-pack-name>{pack.name}</span>
|
||||
</button>
|
||||
<div className={css.packMeta}>
|
||||
<span className={css.packCount}>{t('cluePacksMembers', { n: pack.members.length })}</span>
|
||||
<button
|
||||
type="button"
|
||||
className={css.packReference}
|
||||
aria-label={t('cluePacksInsertAria', { name: pack.name })}
|
||||
title={t('cluePackInsert')}
|
||||
onClick={() => { if (onInsertPack(pack)) rememberUse(pack.id) }}
|
||||
>
|
||||
<IconContextInjectionOutlineRegular size={14} />
|
||||
</button>
|
||||
</div>
|
||||
<ListRow
|
||||
title={pack.name}
|
||||
titleData={{ 'data-clue-pack-name': pack.name }}
|
||||
titleLabel={t('cluePacksManageAria', { name: pack.name })}
|
||||
titleAs="button"
|
||||
primary={navigation.itemTabIndex(index) === 0}
|
||||
onTitleClick={() => { onOpenPack(pack) }}
|
||||
leading={<CluePackArtwork size={16} />}
|
||||
meta={<span>{t('cluePacksMembers', { n: pack.members.length })}</span>}
|
||||
actions={(
|
||||
<IconButton
|
||||
size="sm"
|
||||
label={t('cluePacksInsertAria', { name: pack.name })}
|
||||
title={t('cluePackInsert')}
|
||||
onClick={() => { if (onInsertPack(pack)) rememberUse(pack.id) }}
|
||||
icon={<IconContextInjectionOutlineRegular size={14} />}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
@@ -98,21 +98,33 @@
|
||||
gap: 1px;
|
||||
}
|
||||
|
||||
/* The title is a real button when the row navigates: keyboard operation and a
|
||||
visible focus ring come for free, and the row's own padding stays intact. */
|
||||
/* The title text. Truncation lives here, so a caller's locator can land on the
|
||||
element that actually clips — a wrapper would inherit the ellipsis but not
|
||||
the measured overflow. */
|
||||
.listRowName {
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
/* A navigating row makes the whole caption (name + subtitle) one button:
|
||||
keyboard operation and a visible focus ring come for free, and the row's own
|
||||
padding stays intact. */
|
||||
.listRowTitle {
|
||||
appearance: none;
|
||||
display: block;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: stretch;
|
||||
gap: 1px;
|
||||
min-width: 0;
|
||||
flex: 1 1 auto;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: none;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
text-align: start;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
@@ -123,6 +135,7 @@
|
||||
}
|
||||
|
||||
.listRowSubtitle {
|
||||
min-width: 0;
|
||||
color: var(--dsw-alias-label-tertiary);
|
||||
font: var(--dsw-font-xxxs-11);
|
||||
white-space: nowrap;
|
||||
|
||||
+54
-24
@@ -106,6 +106,18 @@ export interface ListRowProps extends DataAttributes {
|
||||
/** Glyph or status dot at the leading edge. */
|
||||
readonly leading?: ReactNode
|
||||
readonly title: ReactNode
|
||||
/**
|
||||
* `data-*` for the title element itself. The title owns the ellipsis, so a
|
||||
* caller's locator must land on the title, not on a wrapper inside it — a
|
||||
* nested span would inherit the truncation but not the measured style.
|
||||
*/
|
||||
readonly titleData?: DataAttributes
|
||||
/**
|
||||
* Accessible name of the title button when the visible title alone would be
|
||||
* ambiguous ("Release clues" → "Manage pack: Release clues"). Ignored for a
|
||||
* plain title, which is text rather than a control.
|
||||
*/
|
||||
readonly titleLabel?: string
|
||||
/** Secondary line under the title (a subtitle, not a second fact column). */
|
||||
readonly subtitle?: ReactNode
|
||||
/** Facts at the trailing edge, before the actions. */
|
||||
@@ -122,9 +134,15 @@ export interface ListRowProps extends DataAttributes {
|
||||
readonly selected?: boolean
|
||||
/** A row that exists but is not actionable yet (unresolved reference). */
|
||||
readonly dimmed?: boolean
|
||||
readonly onContextMenu?: (event: React.MouseEvent) => void
|
||||
/** Roving tabindex: only one row of a list is in the tab order. */
|
||||
readonly primaryTabIndex?: boolean
|
||||
readonly onContextMenu?: (event: React.MouseEvent<HTMLElement>) => void
|
||||
/**
|
||||
* Roving-focus membership for {@link useListNavigation}: the title button
|
||||
* carries `data-list-primary` and is the list's one Tab stop when `true`,
|
||||
* and leaves the tab order when `false`. The hook's contract is exactly
|
||||
* "mark each title with data-list-primary", so the row honours it here
|
||||
* instead of making every caller reach into the button.
|
||||
*/
|
||||
readonly primary?: boolean
|
||||
readonly className?: string
|
||||
}
|
||||
|
||||
@@ -137,8 +155,8 @@ export interface ListRowProps extends DataAttributes {
|
||||
*/
|
||||
export function ListRow(props: ListRowProps): ReactNode {
|
||||
const {
|
||||
leading, title, subtitle, meta, actions, titleAs = 'plain', onTitleClick,
|
||||
selected, dimmed, onContextMenu, primaryTabIndex, className, ...dataProps
|
||||
leading, title, titleData, titleLabel, subtitle, meta, actions, titleAs = 'plain', onTitleClick,
|
||||
selected, dimmed, onContextMenu, primary, className, ...dataProps
|
||||
} = props
|
||||
return (
|
||||
<div
|
||||
@@ -149,19 +167,29 @@ export function ListRow(props: ListRowProps): ReactNode {
|
||||
onContextMenu={onContextMenu}
|
||||
>
|
||||
{leading !== undefined && <span className={css.listRowLeading}>{leading}</span>}
|
||||
<span className={css.listRowMain}>
|
||||
{titleAs === 'button'
|
||||
? (
|
||||
<button
|
||||
type="button"
|
||||
className={css.listRowTitle}
|
||||
tabIndex={primaryTabIndex === false ? -1 : undefined}
|
||||
onClick={onTitleClick}
|
||||
>{title}</button>
|
||||
)
|
||||
: <span className={css.listRowTitle} style={TITLE_TEXT as CSSProperties}>{title}</span>}
|
||||
{subtitle !== undefined && <span className={css.listRowSubtitle}>{subtitle}</span>}
|
||||
</span>
|
||||
{titleAs === 'button'
|
||||
? (
|
||||
// A navigating row puts the subtitle INSIDE the button: the whole
|
||||
// two-line caption is then one click target and one accessible
|
||||
// name, exactly like the browse rows this replaces.
|
||||
<button
|
||||
type="button"
|
||||
{...titleData}
|
||||
className={clsx(css.listRowMain, css.listRowTitle)}
|
||||
{...(titleLabel === undefined ? {} : { 'aria-label': titleLabel, title: titleLabel })}
|
||||
{...(primary === undefined ? {} : { 'data-list-primary': true, tabIndex: primary ? 0 : -1 })}
|
||||
onClick={onTitleClick}
|
||||
>
|
||||
<span className={css.listRowName}>{title}</span>
|
||||
{subtitle !== undefined && <span className={css.listRowSubtitle}>{subtitle}</span>}
|
||||
</button>
|
||||
)
|
||||
: (
|
||||
<span className={css.listRowMain}>
|
||||
<span {...titleData} className={css.listRowName} style={TITLE_TEXT as CSSProperties}>{title}</span>
|
||||
{subtitle !== undefined && <span className={css.listRowSubtitle}>{subtitle}</span>}
|
||||
</span>
|
||||
)}
|
||||
{meta !== undefined && <span className={css.listRowMeta}>{meta}</span>}
|
||||
{actions !== undefined && <span className={css.listRowActions}>{actions}</span>}
|
||||
</div>
|
||||
@@ -171,8 +199,10 @@ export function ListRow(props: ListRowProps): ReactNode {
|
||||
/** A text title must not inherit the button's pointer cursor. */
|
||||
const TITLE_TEXT = { cursor: 'inherit' } as const
|
||||
|
||||
/** The title text itself: truncation happens here, on whatever owns the row. */
|
||||
|
||||
/** Props of {@link EmptyState}. */
|
||||
export interface EmptyStateProps {
|
||||
export interface EmptyStateProps extends DataAttributes {
|
||||
readonly icon?: ReactNode
|
||||
readonly title: ReactNode
|
||||
readonly description?: ReactNode
|
||||
@@ -183,9 +213,9 @@ export interface EmptyStateProps {
|
||||
}
|
||||
|
||||
/** The one empty state: glyph, one-line title, optional description, actions. */
|
||||
export function EmptyState({ icon, title, description, actions, tone = 'well', className }: EmptyStateProps): ReactNode {
|
||||
export function EmptyState({ icon, title, description, actions, tone = 'well', className, ...dataProps }: EmptyStateProps): ReactNode {
|
||||
return (
|
||||
<div className={clsx(css.empty, tone === 'page' ? css.emptyPage : css.emptyWell, className)}>
|
||||
<div {...dataProps} className={clsx(css.empty, tone === 'page' ? css.emptyPage : css.emptyWell, className)}>
|
||||
{icon !== undefined && <span className={css.emptyIcon}>{icon}</span>}
|
||||
<span className={css.emptyTitle}>{title}</span>
|
||||
{description !== undefined && <span className={css.emptyDescription}>{description}</span>}
|
||||
@@ -195,7 +225,7 @@ export function EmptyState({ icon, title, description, actions, tone = 'well', c
|
||||
}
|
||||
|
||||
/** Props of {@link ErrorBlock}. */
|
||||
export interface ErrorBlockProps {
|
||||
export interface ErrorBlockProps extends DataAttributes {
|
||||
readonly message: ReactNode
|
||||
/** A sanitized second line (a reason code, a dependency id) — never a secret. */
|
||||
readonly detail?: ReactNode
|
||||
@@ -213,9 +243,9 @@ export interface ErrorBlockProps {
|
||||
* belongs to, and the four hand-written spellings this replaces had already
|
||||
* drifted in exactly that way (two put the button above, two below).
|
||||
*/
|
||||
export function ErrorBlock({ message, detail, retryLabel, onRetry, busy, className }: ErrorBlockProps): ReactNode {
|
||||
export function ErrorBlock({ message, detail, retryLabel, onRetry, busy, className, ...dataProps }: ErrorBlockProps): ReactNode {
|
||||
return (
|
||||
<div className={clsx(css.errorBlock, className)} role="alert">
|
||||
<div {...dataProps} className={clsx(css.errorBlock, className)} role="alert">
|
||||
<span className={css.errorBody}>
|
||||
<span className={css.errorMessage}>{message}</span>
|
||||
{detail !== undefined && <span className={css.errorDetail}>{detail}</span>}
|
||||
|
||||
@@ -18,6 +18,9 @@ const sections = read('src/client/ui/workbench-section.module.css')
|
||||
const switcher = read('src/client/ui/source-switcher.module.css')
|
||||
const search = read('src/client/ui/search-field.module.css')
|
||||
const controls = read('src/client/ui/controls.module.css')
|
||||
// The pack shelf's rows are the shared ListRow recipe now, so its density and
|
||||
// touch-target contract lives in the shared patterns sheet, not in the tab's.
|
||||
const patterns = read('src/client/ui/patterns.module.css')
|
||||
|
||||
describe('clue tab container-query layout', () => {
|
||||
it('makes the tab root an inline-size container and never a viewport column', () => {
|
||||
@@ -61,7 +64,10 @@ describe('clue workbench density and affordances', () => {
|
||||
|
||||
it('keeps 30px rows and reveals row actions on hover, focus or touch', () => {
|
||||
expect(tab).toMatch(/\.resultRow,[\s\S]*?\.pinRow\s*\{[^}]*min-height:\s*30px/)
|
||||
expect(tab).toMatch(/\.packRow\s*\{[^}]*min-height:\s*30px/)
|
||||
// A pack row IS a ListRow: 30px, hover/focus-revealed actions, untouched at rest.
|
||||
expect(patterns).toMatch(/\.listRow\s*\{[^}]*min-height:\s*30px/)
|
||||
expect(patterns).toMatch(/\.listRowActions\s*\{[^}]*opacity:\s*0/)
|
||||
expect(patterns).toMatch(/\.listRow:hover \.listRowActions,[\s\S]*?\{\s*opacity:\s*1/)
|
||||
const actions = /\.rowActions\s*\{([^}]+)\}/.exec(tab)?.[1]
|
||||
expect(actions).toBeDefined()
|
||||
expect(actions).toMatch(/opacity:\s*0/)
|
||||
@@ -74,7 +80,9 @@ describe('clue workbench density and affordances', () => {
|
||||
expect(tab).toMatch(/@media[^}]*pointer:\s*coarse/)
|
||||
expect(tab).toContain('min-height: 44px')
|
||||
expect(tab).toMatch(/@media[^}]*pointer:\s*coarse[\s\S]*\.rowActions \.iconButton,[^}]*width:\s*44px/)
|
||||
expect(tab).toMatch(/@media[^}]*pointer:\s*coarse[\s\S]*\.packReference[^}]*width:\s*44px/)
|
||||
// The ListRow's own coarse-pointer rule: the pack reference button is a
|
||||
// 44px target through the row, and the row itself grows to 44px.
|
||||
expect(patterns).toMatch(/@media \(pointer: coarse\) \{\s*\.listRow \{ min-height: 44px; \}/)
|
||||
})
|
||||
|
||||
it('uses the shared 32px search field with a flat query wrapper', () => {
|
||||
|
||||
@@ -97,10 +97,25 @@ describe('ListRow', () => {
|
||||
expect(onClick).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('keeps the roving tabindex contract: one row in the tab order', () => {
|
||||
view = renderRoot(createElement(ListRow, { title: 'First', titleAs: 'button', primaryTabIndex: true }))
|
||||
view.rerender(createElement(ListRow, { title: 'First', titleAs: 'button', primaryTabIndex: false }))
|
||||
expect(view.container.querySelector('button')!.tabIndex).toBe(-1)
|
||||
it('marks the roving-focus entry on the title button, not on the row shell', () => {
|
||||
// useListNavigation focuses the element carrying data-list-primary, so the
|
||||
// marker and the tab stop must both land on the real button.
|
||||
view = renderRoot(createElement(ListRow, { title: 'First', titleAs: 'button', primary: true }))
|
||||
const entry = view.container.querySelector('button')!
|
||||
expect(entry.hasAttribute('data-list-primary')).toBe(true)
|
||||
expect(entry.tabIndex).toBe(0)
|
||||
|
||||
view.rerender(createElement(ListRow, { title: 'Second', titleAs: 'button', primary: false }))
|
||||
const other = view.container.querySelector('button')!
|
||||
expect(other.hasAttribute('data-list-primary')).toBe(true)
|
||||
expect(other.tabIndex).toBe(-1)
|
||||
})
|
||||
|
||||
it('leaves the tab order alone when the row is not part of a roving list', () => {
|
||||
view = renderRoot(createElement(ListRow, { title: 'Plain', titleAs: 'button' }))
|
||||
const button = view.container.querySelector('button')!
|
||||
expect(button.hasAttribute('data-list-primary')).toBe(false)
|
||||
expect(button.tabIndex).toBe(0)
|
||||
})
|
||||
|
||||
it('mounts every slot it is given and nothing it is not', () => {
|
||||
|
||||
Reference in new issue
Block a user