diff --git a/src/client/clues/windows/collect.module.css b/src/client/clues/windows/collect.module.css index 6ccdb502..974949fb 100644 --- a/src/client/clues/windows/collect.module.css +++ b/src/client/clues/windows/collect.module.css @@ -17,7 +17,6 @@ .selection > summary:focus-visible { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 1px; } .selectionTitle { margin-inline-start: 8px; color: var(--dsw-alias-label-primary); overflow-wrap: anywhere; } .selectionList { max-height: 96px; overflow: auto; margin: 4px 0 0; padding-inline-start: 20px; color: var(--dsw-alias-label-secondary); overflow-wrap: anywhere; } -.destinationSummary { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--dsw-alias-label-secondary); } .count { flex: none; margin: 0; @@ -121,66 +120,12 @@ font-size: 11px; font-variant-numeric: tabular-nums; } -.field { - display: flex; - flex-direction: column; - gap: var(--ds-sidebar-space-1); - flex: none; -} -.fieldLabel { - color: var(--dsw-alias-label-tertiary); - font-size: 11px; - line-height: 16px; -} -.textInput { - composes: input from "../../ui/kit.module.css"; -} -.fieldError { - display: flex; - flex-wrap: wrap; - align-items: center; - gap: var(--ds-sidebar-space-2); - color: var(--dsw-alias-state-error-primary); - font-size: 11px; - line-height: 16px; - overflow-wrap: anywhere; -} .hint { color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; } -.footer { - display: flex; - align-items: center; - flex: none; - gap: var(--ds-sidebar-space-2); - min-width: 0; - justify-content: flex-end; - padding-top: var(--ds-sidebar-space-2); - border-top: 1px solid var(--dsw-alias-border-l1); -} -.footer > button { - flex: none; -} -.action { - composes: button from "../../ui/kit.module.css"; -} -.primary { - composes: buttonPrimary from "../../ui/kit.module.css"; - background: var(--dsw-alias-button-primary-fill); - color: var(--dsw-alias-label-primary-foreground); -} -.primary:hover:not(:disabled) { - background: var(--dsw-alias-button-primary-hover); -} -.stateAction { - composes: button buttonGhost from "../../ui/kit.module.css"; -} @media (pointer: coarse) { - .action, - .primary, - .textInput, .destinationRow { min-height: 44px; } diff --git a/src/client/clues/windows/collect.tsx b/src/client/clues/windows/collect.tsx index 90c59295..12344eda 100644 --- a/src/client/clues/windows/collect.tsx +++ b/src/client/clues/windows/collect.tsx @@ -43,7 +43,7 @@ import { cluesApi, peekClueRequest } from '../api.ts' import { clueErrorMessage } from '../copy.ts' import { CluePackArtwork } from '../artwork.tsx' import { LoadingIndicator } from '../../ui/LoadingIndicator.tsx' -import { ActionButton, Notice, TextInput } from '../../ui/index.ts' +import { ActionButton, ActionFooter, ErrorBlock, Field, TextInput } from '../../ui/index.ts' import { t } from '../../locales.ts' import css from './collect.module.css' @@ -420,14 +420,13 @@ export function ClueCollectPage(
{packsPhase === 'loading' && } {packsPhase === 'error' && ( - - {packsError ?? t('error')} - - + { void loadPacks() }} + /> )} - {error !== null && {error}} + {error !== null && } {matchingPacks.map(pack => (
{destination === '__new' && ( - + )} -
- - {destinationName ?? t('clueSharePacks')} - - {t('cancel')} - - {submitLabel} - -
+ {destinationName ?? t('clueSharePacks')}} + end={<> + {t('cancel')} + + {submitLabel} + + } + /> ) diff --git a/src/client/clues/windows/comments.module.css b/src/client/clues/windows/comments.module.css index eb07e180..16ea2dc0 100644 --- a/src/client/clues/windows/comments.module.css +++ b/src/client/clues/windows/comments.module.css @@ -12,5 +12,3 @@ .composer { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; } .composer textarea { width: 100%; min-height: 72px; } .composer .actions { justify-content: flex-end; } -.error { color: var(--dsw-alias-state-error-primary); overflow-wrap: anywhere; } -.error button { margin-inline-start: 8px; } diff --git a/src/client/clues/windows/comments.tsx b/src/client/clues/windows/comments.tsx index c815a82f..b7afe614 100644 --- a/src/client/clues/windows/comments.tsx +++ b/src/client/clues/windows/comments.tsx @@ -5,7 +5,7 @@ import type { ClueComment, ClueCommentCapabilities, ClueDiscussionPage } from '. import { markdownTextProps } from '../../markdown-labels.tsx' import { t, type CopyKey } from '../../locales.ts' import { LoadingIndicator } from '../../ui/LoadingIndicator.tsx' -import { ActionButton, Notice, TextArea } from '../../ui/index.ts' +import { ActionButton, ErrorBlock, Notice, TextArea } from '../../ui/index.ts' import { clueErrorMessage } from '../copy.ts' import { personLabel, formatResourceTime } from '../resource-summary.tsx' import { ResourceSelectionActions, type ClueSelectionActionTarget } from '../selection-actions.tsx' @@ -126,7 +126,14 @@ export function ResourceDiscussion(props: ResourceDiscussionProps): ReactNode { })} {page?.status === 'ok' && page.items.length === 0 && !loading &&

{copy('clueDiscussionEmpty')}

} {page !== undefined && page.status !== 'ok' &&

{copy(page.status === 'not-captured' ? 'clueDiscussionNotCaptured' : 'clueDiscussionUnavailable')}

} - {(error !== undefined || page?.error !== undefined) &&
{error ?? page?.error?.message} { props.onLoad() }}>{t('retry')}
} + {(error !== undefined || page?.error !== undefined) && ( + { props.onLoad() }} + /> + )} {page?.nextCursor !== undefined && { props.onLoad(page.nextCursor) }}>{copy('clueDiscussionMore')}} {canCreate &&
{ event.preventDefault(); void submit() }}> diff --git a/src/client/clues/windows/create-pack.module.css b/src/client/clues/windows/create-pack.module.css index 22f21d32..30ed259a 100644 --- a/src/client/clues/windows/create-pack.module.css +++ b/src/client/clues/windows/create-pack.module.css @@ -20,77 +20,3 @@ color: var(--dsw-alias-label-primary); font: var(--dsw-font-xxs-12); } - -.field { - display: flex; - flex-direction: column; - gap: var(--ds-sidebar-space-2); - min-width: 0; -} - -.label { - color: var(--dsw-alias-label-secondary); - font: var(--dsw-font-xxs-strong-12); -} - -.input { - composes: input from "../../ui/kit.module.css"; - width: 100%; -} - -.input::placeholder { - color: var(--dsw-alias-label-tertiary); -} - -.input:focus-visible { - outline: 2px solid var(--dsw-alias-brand-primary); - outline-offset: 1px; -} - -.input:disabled { - opacity: 0.4; -} - -.error { - margin: 0; - padding: 6px 8px; - border: 1px solid var(--dsw-alias-state-error-primary); - border-radius: var(--ds-sidebar-radius); - color: var(--dsw-alias-label-secondary); - overflow-wrap: anywhere; -} - -.actions { - display: flex; - align-items: center; - justify-content: flex-end; - gap: var(--ds-sidebar-space-2); - flex: none; - margin: auto calc(-1 * var(--ds-sidebar-gutter)) calc(-1 * var(--ds-sidebar-gutter)); - padding: var(--ds-sidebar-space-3) var(--ds-sidebar-gutter); - border-top: 1px solid var(--dsw-alias-border-l1); -} - -.button { - composes: button from "../../ui/kit.module.css"; -} - -.primary { - composes: buttonPrimary from "../../ui/kit.module.css"; - background: var(--dsw-alias-button-primary-fill); - color: var(--dsw-alias-label-primary-foreground); -} -.primary:hover:not(:disabled) { - background: var(--dsw-alias-button-primary-hover); -} - - - - -@media (hover: none), (pointer: coarse) { - .button, - .primary { - min-height: 44px; - } -} - diff --git a/src/client/clues/windows/create-pack.tsx b/src/client/clues/windows/create-pack.tsx index 9b3e2a3f..f9a6b4f6 100644 --- a/src/client/clues/windows/create-pack.tsx +++ b/src/client/clues/windows/create-pack.tsx @@ -23,7 +23,7 @@ import type { BetterSidebarCluesClientFace } from '../registry.ts' import type { BetterSidebarWindowsClientFace, WindowHandle } from '../../windows/types.ts' import { clueErrorMessage } from '../copy.ts' import { t } from '../../locales.ts' -import { ActionButton, Notice, TextInput } from '../../ui/index.ts' +import { ActionButton, ActionFooter, Field, Notice, TextInput } from '../../ui/index.ts' import css from './create-pack.module.css' /** The stable window id of one workspace's creation surface. */ @@ -132,27 +132,25 @@ export function CreatePackPage(props: OpenCreatePackWindowOptions & { readonly g aria-busy={busy} onSubmit={(event) => { event.preventDefault(); if (!guard.busy) void submit() }} > - + {error !== null && {error}} -
+ {t('cancel')} {t('cluePacksCreate')} -
+ } />
) } diff --git a/src/client/clues/windows/share.module.css b/src/client/clues/windows/share.module.css index 8cae6678..35b54430 100644 --- a/src/client/clues/windows/share.module.css +++ b/src/client/clues/windows/share.module.css @@ -31,23 +31,6 @@ padding-bottom: 8px; } -.tab { - composes: button from "../../ui/kit.module.css"; -} - -.tab[data-active='true'] { - border-color: transparent; - background: var(--dsw-alias-interactive-bg-active); - color: var(--dsw-alias-label-primary); -} - -.tab:focus-visible, -.select:focus-visible, -.packRow:focus-within { - outline: 2px solid var(--dsw-alias-brand-primary); - outline-offset: 1px; -} - .body { display: flex; flex-direction: column; @@ -61,75 +44,13 @@ overflow-wrap: anywhere; } -.field { - display: flex; - flex-direction: column; - gap: var(--ds-sidebar-space-1); - min-width: 0; -} - .fieldLabel { color: var(--dsw-alias-label-tertiary); font-size: 11px; line-height: 16px; } -.select { - align-self: flex-start; - min-width: 0; - max-width: 100%; - box-sizing: border-box; - min-height: var(--ds-sidebar-control-height); - padding: 4px 8px; - border: 1px solid var(--dsw-alias-border-l2); - border-radius: var(--ds-sidebar-radius); - background: var(--dsw-alias-bg-base); - color: var(--dsw-alias-label-primary); -} - -.packPicker { - display: flex; - flex-direction: column; - gap: var(--ds-sidebar-space-1); - max-height: 180px; - overflow: auto; - margin: 0; - padding: 0; - list-style: none; -} - -.packRow { - display: flex; - align-items: center; - gap: var(--ds-sidebar-space-2); - min-width: 0; - box-sizing: border-box; - min-height: var(--ds-sidebar-control-height); - padding: 4px 8px; - border-radius: var(--ds-sidebar-radius); - cursor: pointer; -} - -.packRow:hover { - background: var(--dsw-alias-interactive-bg-hover); -} - -.packName { - flex: 1 1 auto; - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} - -.packCount { - flex: none; - color: var(--dsw-alias-label-tertiary); - font-size: 11px; -} - .actions, -.foot, .summaryRow { display: flex; flex-wrap: wrap; @@ -137,41 +58,11 @@ gap: var(--ds-sidebar-space-2); } -.footerStatus { - flex: 1; - min-width: 0; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - color: var(--dsw-alias-label-secondary); - font-variant-numeric: tabular-nums; -} - -.foot { - justify-content: flex-end; - flex: none; - margin: 0 calc(-1 * var(--ds-sidebar-gutter)) calc(-1 * var(--ds-sidebar-gutter)); - padding: var(--ds-sidebar-space-3) var(--ds-sidebar-gutter); - border-top: 1px solid var(--dsw-alias-border-l1); -} - .action { composes: button from "../../ui/kit.module.css"; } -.primary { - composes: buttonPrimary from "../../ui/kit.module.css"; - background: var(--dsw-alias-button-primary-fill); - color: var(--dsw-alias-label-primary-foreground); -} -.primary:hover:not(:disabled) { - background: var(--dsw-alias-button-primary-hover); -} - - - -.progress, -.done { +.progress { padding: 4px 8px; border: 1px solid var(--dsw-alias-border-l1); border-radius: var(--ds-sidebar-radius); @@ -180,14 +71,6 @@ overflow-wrap: anywhere; } -.error { - padding: 4px 8px; - border: 1px solid var(--dsw-alias-state-error-primary); - border-radius: var(--ds-sidebar-radius); - color: var(--dsw-alias-label-secondary); - overflow-wrap: anywhere; -} - .summary { display: flex; flex-direction: column; @@ -266,57 +149,11 @@ scrollbar-width: thin; scrollbar-gutter: stable; } -.tab:hover:not([data-active='true']) { background: var(--dsw-alias-interactive-bg-hover); } -.tab[data-active='true'] { font-weight: 500; } -.tab:disabled, .select:disabled { opacity: 0.4; cursor: default; } -.packCount, .itemMeta { font-variant-numeric: tabular-nums; } -.packRow:has(input:checked) { background: var(--dsw-alias-interactive-bg-active); } -.packPicker { border: 1px solid var(--dsw-alias-border-l1); border-radius: var(--ds-sidebar-radius); padding: 4px; } -.packRow input { accent-color: var(--dsw-alias-state-business-primary); } +.itemMeta { font-variant-numeric: tabular-nums; } .hint { font: var(--dsw-font-xxs-12); } .itemRow + .itemRow { border-top: 1px solid var(--dsw-alias-border-l1); } .summaryRow { font-variant-numeric: tabular-nums; } .fileRow input { max-width: 100%; min-width: 0; color: var(--dsw-alias-label-secondary); font: inherit; } @media (pointer: coarse) { - .tab, .action, .primary, .select, .packRow { min-height: 44px; } + .action { min-height: 44px; } } - -.content > .error, -.content > .done { - position: sticky; - top: 0; - z-index: 1; - background: var(--dsw-alias-bg-layer-1); -} -.modeChoices { - display: grid; - grid-template-columns: repeat(2, minmax(0, 1fr)); - gap: 8px; - min-width: 0; - margin: 0; - padding: 0; - border: 0; -} -.modeChoices > legend { margin-bottom: 6px; } -.modeChoice { - display: flex; - align-items: center; - gap: 8px; - min-width: 0; - min-height: 44px; - padding: 8px; - border: 1px solid var(--dsw-alias-border-l2); - border-radius: var(--ds-sidebar-radius); - color: var(--dsw-alias-label-secondary); - cursor: pointer; -} -.modeChoice[data-selected='true'] { - border-color: var(--dsw-alias-brand-primary); - background: var(--dsw-alias-interactive-bg-active); - color: var(--dsw-alias-label-primary); -} -.modeChoice input { flex: none; accent-color: var(--dsw-alias-brand-primary); } -.modeChoice:has(input:focus-visible) { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; } -.modeChoices:disabled { opacity: 0.4; } -.modeChoices:disabled .modeChoice { cursor: default; } -@container (max-width: 390px) { .modeChoices { grid-template-columns: minmax(0, 1fr); } } diff --git a/src/client/clues/windows/share.tsx b/src/client/clues/windows/share.tsx index 9b9b777e..fec61410 100644 --- a/src/client/clues/windows/share.tsx +++ b/src/client/clues/windows/share.tsx @@ -37,7 +37,9 @@ import { } from '../share-client.ts' import { cluesApi, peekClueRequest } from '../api.ts' import { t } from '../../locales.ts' -import { ActionButton, Checkbox, Notice, Tabs } from '../../ui/index.ts' +import { + ActionButton, ActionFooter, ChoiceCard, EmptyState, ErrorBlock, Field, Notice, Tabs, +} from '../../ui/index.ts' import { LoadingIndicator } from '../../ui/LoadingIndicator.tsx' import css from './share.module.css' @@ -441,56 +443,50 @@ export function SharePage(props: OpenShareWindowOptions): ReactNode { {failure !== null && {failure}} {direction === 'export' ? (
-
- {t('clueSharePacks')} + {packsLoading ? : packsError - ? ( -
- {t('error')} - -
- ) + ? { void loadPacks() }} /> : packs.length === 0 - ? {t('clueBrowserNoPacks')} + ? : ( -
    - {packs.map(pack => ( -
  • - -
  • - ))} -
+ ({ + value: pack.id, + title: pack.name, + meta: t('cluePacksMembers', { n: pack.members.length }), + }))} + onChange={id => { togglePack(id) }} + /> )} -
+ -
- {t('clueShareMode')} - {(['snapshot', 'references'] as const).map(value => ( - - ))} -
+ + ({ + value, + title: t(value === 'snapshot' ? 'clueShareModeSnapshot' : 'clueShareModeReference'), + }))} + onChange={value => { + setMode(value as typeof mode) + setPreview(null) + setInspection(null) + setMessage(null) + setFailure(null) + }} + /> + {progress !== null &&
{progressLine(progress)}
} @@ -618,10 +614,10 @@ export function SharePage(props: OpenShareWindowOptions): ReactNode { )}
-
- - {direction === 'export' ? t('clueSharePackCount', { n: selectedPacks.size }) : fileName ?? t('clueShareNoFile')} - + {busy ? (
+ } + /> ) } diff --git a/src/client/ui/patterns.module.css b/src/client/ui/patterns.module.css index 2dbbae1f..d54943a7 100644 --- a/src/client/ui/patterns.module.css +++ b/src/client/ui/patterns.module.css @@ -287,6 +287,9 @@ flex-direction: column; gap: var(--ds-sidebar-space-1); min-width: 0; + margin: 0; + padding: 0; + border: 0; } .choice { @@ -442,8 +445,24 @@ font: var(--dsw-font-xxxs-11); } +.actionFooterBleed { + flex: none; + margin: auto calc(-1 * var(--ds-sidebar-gutter)) calc(-1 * var(--ds-sidebar-gutter)); + padding-inline: var(--ds-sidebar-gutter); +} + +.actionFooterStart { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + font-variant-numeric: tabular-nums; +} + .actionFooterEnd { display: inline-flex; + flex: none; align-items: center; gap: var(--ds-sidebar-space-2); margin-left: auto; diff --git a/src/client/ui/patterns.tsx b/src/client/ui/patterns.tsx index 84211f19..5cc0fc71 100644 --- a/src/client/ui/patterns.tsx +++ b/src/client/ui/patterns.tsx @@ -312,6 +312,8 @@ export interface ChoiceCardProps { readonly selected: readonly string[] readonly onChange: (value: string, checked: boolean) => void readonly label?: string + /** Locks the whole group, the way a native `
` does. */ + readonly disabled?: boolean readonly className?: string } @@ -323,10 +325,10 @@ export interface ChoiceCardProps { * screen-reader announcements and `:checked` styling all come for free, and * only its picture is replaced by {@link ChoiceCard}'s own mark. */ -export function ChoiceCard({ type, name, options, selected, onChange, label, className }: ChoiceCardProps): ReactNode { +export function ChoiceCard({ type, name, options, selected, onChange, label, disabled, className }: ChoiceCardProps): ReactNode { return ( -
+
{options.map(option => { const checked = selected.includes(option.value) return ( @@ -337,7 +339,7 @@ export function ChoiceCard({ type, name, options, selected, onChange, label, cla name={name} value={option.value} checked={checked} - disabled={option.disabled} + disabled={disabled === true || option.disabled === true} onChange={event => { onChange(option.value, event.target.checked) }} />
+
) } @@ -395,6 +397,8 @@ export interface ActionFooterProps { readonly start?: ReactNode /** Trailing actions, in reading order. */ readonly end?: ReactNode + /** Reach the edges of a gutter-padded window root so the hairline spans the window. */ + readonly bleed?: boolean readonly className?: string } @@ -404,10 +408,10 @@ export interface ActionFooterProps { * Its separator is the page's ONE horizontal hairline at that edge, so callers * pass actions and never re-declare the border. */ -export function ActionFooter({ start, end, className }: ActionFooterProps): ReactNode { +export function ActionFooter({ start, end, bleed, className }: ActionFooterProps): ReactNode { return ( -
- {start !== undefined && {start}} +
+ {start !== undefined && {start}} {end !== undefined && {end}}
) diff --git a/tests/ui-patterns.spec.tsx b/tests/ui-patterns.spec.tsx index 20aa515f..af97a4a7 100644 --- a/tests/ui-patterns.spec.tsx +++ b/tests/ui-patterns.spec.tsx @@ -265,6 +265,14 @@ describe('ChoiceCard', () => { expect(view.container.querySelector('[class*="choiceMeta"]')).toBeNull() }) + it('locks every option through the native fieldset when the group is disabled', () => { + view = renderRoot(createElement(ChoiceCard, { + type: 'radio', name: 'mode', label: 'Mode', options, selected: ['snapshot'], onChange: () => {}, disabled: true, + })) + expect(view.container.querySelector('fieldset[aria-label="Mode"]')!.disabled).toBe(true) + expect([...view.container.querySelectorAll('input')].every(input => input.matches(':disabled'))).toBe(true) + }) + it('refuses a disabled option without hiding it', () => { view = renderRoot(createElement(ChoiceCard, { type: 'checkbox', name: 'cap', options: [{ value: 'a', title: 'A', disabled: true }], selected: [], onChange: () => {}, @@ -313,5 +321,13 @@ describe('ActionFooter', () => { expect(footer.firstElementChild!.textContent).toBe('2 of 12 selected') expect(footer.querySelector('[data-slot="save"]')).not.toBeNull() expect(footer.querySelector('[class*="actionFooterEnd"]')).not.toBeNull() + expect(footer.firstElementChild!.getAttribute('role')).toBe('status') + }) + + it('bleeds to the window edge only when asked', () => { + view = renderRoot(createElement(ActionFooter, { end: 'x' })) + expect(byClass(view.container, 'actionFooterBleed')).toBeNull() + view.rerender(createElement(ActionFooter, { end: 'x', bleed: true })) + expect(byClass(view.container, 'actionFooterBleed')).not.toBeNull() }) })