feat(signage): menu look part by part, board-only names, stack bar, Delete key (owner review 3)
- Menus (slides and widgets): headings / names / prices each with size, colour, font, bold / italic / underline and alignment; dots size, colour and style; line and letter spacing; photo size and shape (menuLook) - Names aligned right end together, prices in a page-wide column - Names for one board only (names, category_names) with a pencil on the board's list; the catalogue name stays for the waiters - Fixed: menu lists inherited the page's fixed line height (big text overlapped); a menu slide's list grew past the screen (no 2nd column) - Stacks: parts sized by dragging the lines on the bar; "Add a widget" - Delete / Backspace removes the picked widget Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -10,15 +10,18 @@
|
||||
// crossed eye (a green eye on the ones shown): a click shows / hides it; seconds per page explained;
|
||||
// the text's look on one row. `board` mode: the same editor for a menu widget's list (no background,
|
||||
// widgets, width or place; its own products per page).
|
||||
// Owner review 3 (2026-11-21): the look part by part (MenuLook: headings, names, prices, dots,
|
||||
// spacing, photos); a pencil beside each category and product on the board gives it a name for
|
||||
// this board only (the catalogue keeps its own: the waiters' names stay as they are).
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, Eye, EyeOff, X } from 'lucide-react'
|
||||
import { AlignCenter, AlignLeft, AlignRight, ArrowDown, ArrowUp, Eye, EyeOff, Pencil, RotateCcw, X } from 'lucide-react'
|
||||
import { MENU_LANGUAGES, SALES_POINTS } from '@xenia/access'
|
||||
import { useFormat, useTranslation } from '@xenia/i18n'
|
||||
import { Dropdown, Field, IconButton, Input, Segmented, Select, Switch } from '@xenia/ui'
|
||||
import client from '../../api/client'
|
||||
import { BADGES, boardOrder, moveGroup, moveItem, toggled } from './signageLogic'
|
||||
import { BackgroundField, ColourField, Range, Section } from './SignageFields'
|
||||
import { TextLook } from './SlideEditor'
|
||||
import MenuLook from './MenuLook'
|
||||
import { BackgroundField, Range, Section } from './SignageFields'
|
||||
import WidgetsEditor from './WidgetsEditor'
|
||||
|
||||
let catalogue = null // categories and products, read once for every menu editor on the page
|
||||
@@ -52,6 +55,13 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
||||
const badges = c.badges || {}
|
||||
const digits = v => Number(String(v).replace(/\D/g, ''))
|
||||
const hidden = new Set(c.exclude_ids || [])
|
||||
// this board's own names: empty = the catalogue's again
|
||||
const rename = (key, id, name) => {
|
||||
const next = { ...(c[key] || {}) }
|
||||
if (name && name.trim()) next[String(id)] = name.trim()
|
||||
else delete next[String(id)]
|
||||
setC({ [key]: next })
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grid gap-7" data-testid={testid}>
|
||||
@@ -120,7 +130,8 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
||||
<div key={`${g.category?.id ?? 'all'}`} className="grid gap-1" data-testid="signage-menu-group" data-name={g.category?.name ?? ''}>
|
||||
{g.category && (
|
||||
<div className="flex items-center gap-1">
|
||||
<span className="text-label font-semibold text-ink flex-1">{g.category.name}</span>
|
||||
<OwnName name={g.category.name} original={g.category.original} onSave={v => rename('category_names', g.category.id, v)}
|
||||
className="text-label font-semibold text-ink" testid="signage-category-name" />
|
||||
<IconButton size="sm" variant="ghost" label={t('display.earlier')} disabled={gi === 0} onClick={() => reorder(moveGroup(groups, gi, -1))} data-testid="signage-group-up"><ArrowUp size={14} /></IconButton>
|
||||
<IconButton size="sm" variant="ghost" label={t('display.later')} disabled={gi === groups.length - 1} onClick={() => reorder(moveGroup(groups, gi, 1))}><ArrowDown size={14} /></IconButton>
|
||||
</div>
|
||||
@@ -131,7 +142,8 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
||||
return (
|
||||
<li key={it.id} className="flex items-center gap-1.5 pl-2 rounded-control hover:bg-surface"
|
||||
data-testid="signage-menu-row" data-id={it.id} data-hidden={off ? 'true' : undefined}>
|
||||
<span className={`flex-1 min-w-0 truncate text-label ${off ? 'text-ink-3 opacity-70' : it.available ? 'text-ink' : 'text-ink-3 line-through'}`}>{it.name}</span>
|
||||
<OwnName name={it.name} original={it.original} onSave={v => rename('names', it.id, v)} testid="signage-item-name"
|
||||
className={`text-label ${off ? 'text-ink-3 opacity-70' : it.available ? 'text-ink' : 'text-ink-3 line-through'}`} />
|
||||
{off && <span className="text-caption text-ink-3">{t('signage.menu.hiddenTag')}</span>}
|
||||
{it.price != null && <span className={`text-caption tabular-nums ${off ? 'text-ink-3 opacity-70' : 'text-ink-2'}`}>{formatMoney(it.price)}</span>}
|
||||
<Select size="sm" value={badges[String(it.id)] || ''} aria-label={t('signage.menu.badge')} data-testid="signage-menu-badge" disabled={off}
|
||||
@@ -208,9 +220,7 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
||||
</div>
|
||||
</Section>
|
||||
|
||||
<TextLook c={c} setC={setC} align={false}>
|
||||
<ColourField compact label={t('signage.accent')} value={c.accent_colour || '#f59e0b'} onChange={v => setC({ accent_colour: v })} testid="signage-accent" />
|
||||
</TextLook>
|
||||
<MenuLook c={c} setC={setC} />
|
||||
{!board && <>
|
||||
<BackgroundField value={c.background} onChange={background => setC({ background })} media={media} onMedia={onMedia}
|
||||
misfit={misfit.includes(c.background?.media_id)} />
|
||||
@@ -220,3 +230,36 @@ export default function MenuEditor({ slide, onChange, media, onMedia, misfit = [
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* A category's or product's name on the board, with a pencil (shown on hover or focus) to give it a
|
||||
* name for this board only; the catalogue's name shows under it then, with a button to go back to it.
|
||||
*/
|
||||
function OwnName({ name, original, onSave, className = '', testid }) {
|
||||
const { t } = useTranslation('manager')
|
||||
const [edit, setEdit] = useState(null)
|
||||
if (edit != null) {
|
||||
const done = () => { onSave(edit); setEdit(null) }
|
||||
return (
|
||||
<span className="flex-1 min-w-0">
|
||||
<Input size="sm" autoFocus value={edit} maxLength={80} aria-label={t('signage.menu.ownName')} data-testid={`${testid}-input`}
|
||||
onChange={e => setEdit(e.target.value)} onBlur={done}
|
||||
onKeyDown={e => { if (e.key === 'Enter') done(); if (e.key === 'Escape') setEdit(null) }} />
|
||||
</span>
|
||||
)
|
||||
}
|
||||
return (
|
||||
<span className="group/name flex-1 min-w-0 flex items-center gap-1">
|
||||
<span className="min-w-0 grid">
|
||||
<span className={`truncate ${className}`} data-testid={testid}>{name}</span>
|
||||
{original && <span className="truncate text-caption text-ink-3" title={t('signage.menu.catalogueName')}>{t('signage.menu.catalogueNameIs', { name: original })}</span>}
|
||||
</span>
|
||||
<IconButton size="sm" variant="ghost" label={t('signage.menu.rename')} onClick={() => setEdit(name)} data-testid={`${testid}-edit`}
|
||||
className="opacity-0 group-hover/name:opacity-100 focus-visible:opacity-100 shrink-0"><Pencil size={13} /></IconButton>
|
||||
{original && (
|
||||
<IconButton size="sm" variant="ghost" label={t('signage.menu.renameBack')} onClick={() => onSave('')} data-testid={`${testid}-reset`}
|
||||
className="opacity-0 group-hover/name:opacity-100 focus-visible:opacity-100 shrink-0"><RotateCcw size={13} /></IconButton>
|
||||
)}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user