fix(manager): UI review pass 5 small fixes (fee tabs, category actions and drop line, card buttons, floor plan chips, staff buttons)
- Tabs inset: no line under the strip, the labels level with the end button. - Products: a chosen category's actions share the width equally, toned (quiet, coloured on hover); the drop line shows above / below the row by the pointer's half and the category lands exactly there (moveIdTo); grid cards' edit and archive centred. - Floor plans: the plan chips as tall as "New floor plan". - Staff: PIN and password toned like the other row buttons; toned buttons light up (soft background) under the pointer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+2
-2
@@ -50,10 +50,10 @@ Every page is on `<Page>` except Inventory → Stock (a placeholder). Two-column
|
||||
| Choose one / several | `Dropdown` (`multiple`) | **never a native `<select>` in a toolbar.** Multi: value is an array, `[]` = all (`allLabel`). Options can carry a `dot` (a zone's colour) and a `hint`. Search box from 9 options. Same heights as `Input`. Native `Select` stays only inside forms where the phone's own picker is better |
|
||||
| A toggle filter (a state) | `FilterChip` (`tone`, `count`) | |
|
||||
| Two or three views (List / Map / QR) | `Segmented` | the view in the address (`?view=`) |
|
||||
| Sections of a page or a dialog | `Tabs` (`size="lg"` on pages) | scrolls sideways only, never up/down. `inset`: the strip is a card's header (card padding at the sides, the same room above and below a button in `end`). `fill`: the tabs share the width equally (a narrow column) |
|
||||
| Sections of a page or a dialog | `Tabs` (`size="lg"` on pages) | scrolls sideways only, never up/down. `inset`: the strip is a card's header (card padding at the sides, the same room above and below a button in `end`, the labels level with it, no line under it). `fill`: the tabs share the width equally (a narrow column) |
|
||||
| A container whose list scrolls | `Pane` (`header`, `footer`, `sunken`) | header and footer stay, the body scrolls; one side of a `Page fit` |
|
||||
| A help tip | `InfoTip` | opens on hover (mouse) and on tap. Beside a switch: `Switch info={<InfoTip>…}` puts it right after the text, never after the switch |
|
||||
| Row actions that stand apart | `IconButton tone` | `danger` delete / archive · `warning` block · `info` zones · `accent` edit · `success` unblock: a **grey** square at rest; under the pointer the icon takes the colour (2026-11-21: quiet at rest). Neutral actions stay `ghost` |
|
||||
| Row actions that stand apart | `IconButton tone` | `danger` delete / archive · `warning` block · `info` zones · `accent` edit · `success` unblock: a **grey** square at rest; under the pointer it lights up in its colour (soft background, coloured icon). Every row action of a row has a tone, so they all look the same at rest. Neutral actions stay `ghost` |
|
||||
| A quiet text action that warns | `Button variant="ghost" tone="danger"` | grey text, red under the pointer ("Remove" a picture) |
|
||||
| A switch on its own in a row of buttons | `Switch` without a label | lines up with the buttons (centred), never with a text baseline |
|
||||
| Dialogs | `Dialog` `sm` 400 · `md` 520 · `lg` 720 · `xl` 920 · `wide` (~88 % of a 16:9 screen, capped on ultrawides) | the day summary is `xl`, the product editor `wide` |
|
||||
|
||||
@@ -39,7 +39,7 @@ export default function FloorPlansTab() {
|
||||
<div className="flex flex-wrap gap-1.5">
|
||||
{z.plans.map(p => (
|
||||
<button key={p.id} type="button" onClick={() => setChosen(p.id)} aria-current={plan?.id === p.id ? 'true' : undefined} data-testid="floor-plan-item" data-name={p.name}
|
||||
className={cx('px-3 py-1.5 rounded-control border text-label font-medium transition-colors duration-fast text-left',
|
||||
className={cx('inline-flex items-center h-control-sm px-3 rounded-control border text-label font-medium transition-colors duration-fast text-left',
|
||||
plan?.id === p.id ? 'border-accent bg-accent-soft text-accent-ink' : 'border-line bg-surface hover:bg-surface-2 text-ink')}>
|
||||
{p.name}
|
||||
<span className="ml-2 text-caption text-ink-3 font-normal">{t('floor.tableCount', { count: data.tables.filter(x => x.plan_id === p.id).length })}</span>
|
||||
|
||||
@@ -7,7 +7,7 @@ import { useRef, useState } from 'react'
|
||||
import { Archive, ArrowRightLeft, ChevronDown, ChevronRight, Folder, GripVertical, Pencil, Plus, Trash2, Truck } from 'lucide-react'
|
||||
import { useTranslation } from '@xenia/i18n'
|
||||
import { IconButton, Pane, SearchInput, cx } from '@xenia/ui'
|
||||
import { SCOPES, countIn, isArchived, moveId, subsOf, topLevel } from './productsLogic'
|
||||
import { SCOPES, countIn, isArchived, moveIdTo, subsOf, topLevel } from './productsLogic'
|
||||
|
||||
export function Dot({ cat, size = 'w-2 h-2' }) {
|
||||
// a category's colour is the venue's choice (data)
|
||||
@@ -27,31 +27,39 @@ export default function CategoryTree({ categories, products, scope, onScope, onA
|
||||
const dnd = (cat, level, parent) => ({
|
||||
draggable: true,
|
||||
onDragStart: e => { drag.current = { id: cat.id, level, parent }; e.dataTransfer.effectAllowed = 'move' },
|
||||
onDragOver: e => { e.preventDefault(); if (drag.current && drag.current.id !== cat.id && drag.current.level === level && drag.current.parent === parent) setDropAt(cat.id) },
|
||||
// the line shows where it lands: above the row under the pointer's upper half, below it for the lower half
|
||||
onDragOver: e => {
|
||||
e.preventDefault()
|
||||
if (!drag.current || drag.current.id === cat.id || drag.current.level !== level || drag.current.parent !== parent) return
|
||||
const r = e.currentTarget.getBoundingClientRect()
|
||||
const after = e.clientY > r.top + r.height / 2
|
||||
setDropAt(d => (d?.id === cat.id && d.after === after ? d : { id: cat.id, after }))
|
||||
},
|
||||
onDragLeave: () => setDropAt(null),
|
||||
onDrop: e => {
|
||||
e.preventDefault()
|
||||
const after = dropAt?.id === cat.id ? dropAt.after : false
|
||||
setDropAt(null)
|
||||
const d = drag.current
|
||||
drag.current = null
|
||||
if (!d || d.level !== level || d.parent !== parent) return
|
||||
const siblings = (level === 'top' ? topLevel(categories) : subsOf(categories, parent)).map(c => c.id)
|
||||
const next = moveId(siblings, d.id, cat.id)
|
||||
const next = moveIdTo(siblings, d.id, cat.id, after)
|
||||
if (next) onReorder(level, next)
|
||||
},
|
||||
})
|
||||
|
||||
const row = (cat, depth, parent) => (
|
||||
<div key={cat.id} {...dnd(cat, depth ? 'sub' : 'top', parent)} className={cx(dropAt === cat.id && 'border-t-2 border-accent')}>
|
||||
<div key={cat.id} {...dnd(cat, depth ? 'sub' : 'top', parent)} className={cx('border-y-2 border-transparent', dropAt?.id === cat.id && (dropAt.after ? '!border-b-accent' : '!border-t-accent'))}>
|
||||
<Row label={cat.name} count={countIn(products, categories, cat.id)} active={scope === cat.id} onClick={() => onScope(cat.id)} depth={depth}
|
||||
dot={<Dot cat={cat} />} drag testId={`category-${cat.id}`}
|
||||
caret={!depth && subsOf(categories, cat.id).length > 0 ? (open.has(cat.id) || !!q) : null}
|
||||
onCaret={() => setOpen(s => { const n = new Set(s); if (n.has(cat.id)) n.delete(cat.id); else n.add(cat.id); return n })}
|
||||
actions={<>
|
||||
{!depth && <IconButton size="sm" variant="ghost" label={t('products.category.newSub')} onClick={() => onAdd(cat.id)}><Plus size={14} /></IconButton>}
|
||||
<IconButton size="sm" variant="ghost" label={t('products.category.moveTitle')} onClick={() => onMove(cat)}><ArrowRightLeft size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('products.category.edit')} onClick={() => onEdit(cat)}><Pencil size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="danger" label={t('products.category.delete')} onClick={() => onDelete(cat)}><Trash2 size={14} /></IconButton>
|
||||
{!depth && <IconButton size="sm" tone="success" className="!w-full" label={t('products.category.newSub')} onClick={() => onAdd(cat.id)}><Plus size={16} /></IconButton>}
|
||||
<IconButton size="sm" tone="info" className="!w-full" label={t('products.category.moveTitle')} onClick={() => onMove(cat)}><ArrowRightLeft size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="accent" className="!w-full" label={t('products.category.edit')} onClick={() => onEdit(cat)}><Pencil size={16} /></IconButton>
|
||||
<IconButton size="sm" tone="danger" className="!w-full" label={t('products.category.delete')} onClick={() => onDelete(cat)}><Trash2 size={16} /></IconButton>
|
||||
</>} />
|
||||
</div>
|
||||
)
|
||||
@@ -100,7 +108,8 @@ function Row({ label, count, active, onClick, dot, depth = 0, caret = null, onCa
|
||||
<button type="button" className={cx('flex-1 min-w-0 truncate text-left text-body', active && 'font-semibold')} data-testid={testId}>{label}</button>
|
||||
{/* a category's own actions show on its row once it's chosen (touch screens have no hover) */}
|
||||
<span className="px-1.5 rounded-full bg-surface-2 text-caption text-ink-2 tabular-nums shrink-0">{count}</span>
|
||||
{actions && active && <span className="w-full flex justify-end gap-0.5" onClick={e => e.stopPropagation()} data-testid="category-actions">{actions}</span>}
|
||||
{/* the chosen category's actions share the row's width equally (2026-11-21) */}
|
||||
{actions && active && <span className="w-full grid grid-flow-col auto-cols-fr gap-1 pt-1" onClick={e => e.stopPropagation()} data-testid="category-actions">{actions}</span>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -162,8 +162,11 @@ function Card({ p, categories, selected, onSelect, onEdit, onRemove, onToggle })
|
||||
<div className={cx('group rounded-card border bg-surface overflow-hidden flex flex-col', selected ? 'border-accent shadow-focus' : 'border-line hover:shadow-raised')} data-testid="product-card" data-name={p.name}>
|
||||
<div className="relative h-36">
|
||||
<Photo product={p} className="w-full h-full text-display" />
|
||||
<span className="absolute top-2 left-2 flex gap-1 opacity-0 group-hover:opacity-100 focus-within:opacity-100">
|
||||
<span className="absolute top-2 left-2 flex opacity-0 group-hover:opacity-100 focus-within:opacity-100">
|
||||
<input type="checkbox" className="w-5 h-5 accent-[var(--x-accent)]" checked={selected} onChange={() => onSelect(p.id)} aria-label={t('products.select', { name: p.name })} />
|
||||
</span>
|
||||
{/* edit and archive / delete: centred on the card (2026-11-21) */}
|
||||
<span className="absolute inset-x-0 top-2 flex justify-center gap-2 opacity-0 group-hover:opacity-100 focus-within:opacity-100">
|
||||
<IconButton size="sm" variant="secondary" label={t('products.edit')} onClick={() => onEdit(p)}><Pencil size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="secondary" tone="danger" label={archived ? t('products.delete') : t('products.archive')} onClick={() => onRemove(p)}>{archived ? <Trash2 size={14} /> : <Archive size={14} />}</IconButton>
|
||||
</span>
|
||||
|
||||
@@ -123,6 +123,15 @@ export function moveId(ids, fromId, toId) {
|
||||
return next
|
||||
}
|
||||
|
||||
/** Move `fromId` to just before (or, `after`, just after) `toId`: where the drop line showed. */
|
||||
export function moveIdTo(ids, fromId, toId, after = false) {
|
||||
if (fromId === toId || !ids.includes(fromId) || !ids.includes(toId)) return null
|
||||
const rest = ids.filter(id => id !== fromId)
|
||||
const at = rest.indexOf(toId) + (after ? 1 : 0)
|
||||
const next = [...rest.slice(0, at), fromId, ...rest.slice(at)]
|
||||
return next.every((id, i) => id === ids[i]) ? null : next
|
||||
}
|
||||
|
||||
/** What it costs the venue (the breakdown's sum, else the simple cost) and the margin; null without a cost. */
|
||||
export function costOf(p) {
|
||||
const cost = p.cost_breakdown?.length ? p.cost_breakdown.reduce((s, e) => s + (Number(e.amount) || 0), 0)
|
||||
|
||||
@@ -108,8 +108,8 @@ export default function StaffPage() {
|
||||
{!support && (
|
||||
<span className="flex gap-1.5 ml-auto">
|
||||
<IconButton size="sm" variant="ghost" tone="accent" label={t('staff.edit', { name: displayName(m) })} onClick={() => open('edit', m)}><Pencil size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('staff.pin', { name: displayName(m) })} onClick={() => open('pin', m)} data-testid="staff-pin"><KeyRound size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('staff.password', { name: displayName(m) })} onClick={() => open('password', m)} data-testid="staff-password"><LockKeyhole size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="special" label={t('staff.pin', { name: displayName(m) })} onClick={() => open('pin', m)} data-testid="staff-pin"><KeyRound size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="special" label={t('staff.password', { name: displayName(m) })} onClick={() => open('password', m)} data-testid="staff-password"><LockKeyhole size={15} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" tone="info" label={t('staff.zonesOf', { name: displayName(m) })} onClick={() => open('zones', m)}><MapPin size={15} /></IconButton>
|
||||
{m.id !== me?.id && (<>
|
||||
<IconButton size="sm" variant="ghost" tone={m.is_active ? 'warning' : 'success'} label={t(m.is_active ? 'staff.block' : 'staff.unblock', { name: displayName(m) })}
|
||||
|
||||
@@ -131,3 +131,12 @@ test('the editor: every text per language; "Default" is the venue language (owne
|
||||
assert.equal(canSave({ ...f, names: {}, name: '' }, 'el'), false)
|
||||
assert.deepEqual(cleanTexts({ el: ' ', en: ' x ', fr: 'y' }), { en: 'x' })
|
||||
})
|
||||
|
||||
test('a category dropped above or below a row lands where the line showed (2026-11-21)', async () => {
|
||||
const { moveIdTo } = await import('../src/pages/products/productsLogic.js')
|
||||
assert.deepEqual(moveIdTo([1, 2, 3, 4], 1, 3, false), [2, 1, 3, 4]) // above 3
|
||||
assert.deepEqual(moveIdTo([1, 2, 3, 4], 1, 3, true), [2, 3, 1, 4]) // below 3
|
||||
assert.deepEqual(moveIdTo([1, 2, 3, 4], 4, 2, false), [1, 4, 2, 3])
|
||||
assert.equal(moveIdTo([1, 2, 3], 1, 2, false), null) // already there
|
||||
assert.equal(moveIdTo([1, 2, 3], 2, 2, true), null)
|
||||
})
|
||||
|
||||
@@ -60,7 +60,7 @@
|
||||
.x-btn--icon.x-btn--tone { background: var(--x-surface-2); }
|
||||
/* a toned toggle that is on (a favourite's heart) keeps its colour */
|
||||
.x-btn--tone[aria-pressed="true"] { color: rgb(var(--x-tone-ink)); }
|
||||
.x-btn--icon.x-btn--tone:hover:not(:disabled) { background: var(--x-surface-3); }
|
||||
.x-btn--icon.x-btn--tone:hover:not(:disabled) { background: rgb(var(--x-tone-soft)); } /* brighter under the pointer */
|
||||
.x-btn--tone-danger { --x-tone: var(--x-danger-rgb); --x-tone-soft: var(--x-danger-soft-rgb); --x-tone-ink: var(--x-danger-ink-rgb); }
|
||||
.x-btn--tone-warning { --x-tone: var(--x-warning-rgb); --x-tone-soft: var(--x-warning-soft-rgb); --x-tone-ink: var(--x-warning-ink-rgb); }
|
||||
.x-btn--tone-info { --x-tone: var(--x-info-rgb); --x-tone-soft: var(--x-info-soft-rgb); --x-tone-ink: var(--x-info-ink-rgb); }
|
||||
@@ -543,7 +543,8 @@
|
||||
.x-tabs__badge--warn { background: var(--x-danger-soft); color: var(--x-danger-ink); }
|
||||
.x-tabs__end { flex-shrink: 0; display: flex; align-items: center; gap: var(--x-space-2); }
|
||||
.x-tabs--inset { align-items: stretch; padding-inline: var(--x-pad-card); min-height: calc(var(--x-control-sm) + 2 * var(--x-pad-card)); }
|
||||
.x-tabs--inset .x-tabs__list { align-items: flex-end; }
|
||||
.x-tabs--inset { box-shadow: none; } /* a card's header: no line under it (2026-11-21) */
|
||||
.x-tabs--inset .x-tabs__list { align-items: center; } /* the labels level with the end button */
|
||||
.x-tabs--inset .x-tabs__end { padding-block: var(--x-pad-card); }
|
||||
.x-tabs--fill .x-tabs__tab { flex: 1 1 0; justify-content: center; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user