mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-21 11:36:05 +00:00
feat(packing): a calmer packing list, with every item's choices in one window
A row now shows its box, its name and only what is set: the amount from two up, the pieces packed while packing, and who brings it. A click on the name opens a small window at the row with the list, amount, pieces packed, weight, bag, who brings it and who sees it, each as one pill, plus copy and delete, instead of fields, a bin and menus in menus on every row. Above the lists the Lists bar keeps Add list and gathers templates, import, export, the order, hiding packed items, the bags on a narrow screen and the clean-up in one menu; the progress moves next to the Shared/My list switch. The bag overview stays. The phone follows the same shape: one "..." sheet for the list's actions, a sheet per list for its own, a slim row and an item sheet that saves as you go. Who may change what about an item lives in one module both views read.
This commit is contained in:
@@ -3,13 +3,17 @@ import type { LucideIcon } from 'lucide-react'
|
||||
import { FileSpreadsheet, FileText, Printer, Upload } from 'lucide-react'
|
||||
import { useTranslation } from '../../i18n'
|
||||
import PackingPrintPreview from './PackingPrintPreview'
|
||||
import { PopoverItem } from './PackingPopover'
|
||||
import { usePackingExport, type PackingView } from './usePackingExport'
|
||||
|
||||
interface PackingExportMenuProps {
|
||||
tripId: number
|
||||
view: PackingView
|
||||
style: React.CSSProperties
|
||||
style?: React.CSSProperties
|
||||
className?: string
|
||||
/** 'menu' draws the three ways out as lines of the Lists menu; onChosen closes that menu. */
|
||||
variant?: 'button' | 'menu'
|
||||
onChosen?: () => void
|
||||
}
|
||||
|
||||
function MenuItem({ icon: Icon, label, onClick }: { icon: LucideIcon; label: string; onClick: () => void }) {
|
||||
@@ -31,7 +35,7 @@ function MenuItem({ icon: Icon, label, onClick }: { icon: LucideIcon; label: str
|
||||
* as PDF, a Markdown checklist, or CSV in the import's own format. Covers the view on
|
||||
* screen and renders nothing while that view is empty.
|
||||
*/
|
||||
export default function PackingExportMenu({ tripId, view, style, className }: PackingExportMenuProps): React.ReactElement | null {
|
||||
export default function PackingExportMenu({ tripId, view, style, className, variant = 'button', onChosen }: PackingExportMenuProps): React.ReactElement | null {
|
||||
const { t } = useTranslation()
|
||||
const packingExport = usePackingExport(tripId, view)
|
||||
const [open, setOpen] = useState(false)
|
||||
@@ -55,9 +59,19 @@ export default function PackingExportMenu({ tripId, view, style, className }: Pa
|
||||
|
||||
const choose = (action: () => void | Promise<void>) => () => {
|
||||
setOpen(false)
|
||||
onChosen?.()
|
||||
void action()
|
||||
}
|
||||
|
||||
if (variant === 'menu') return (
|
||||
<>
|
||||
<PopoverItem icon={<Printer size={13} />} label={t('packing.exportPrint')} onClick={choose(packingExport.openPrint)} />
|
||||
<PopoverItem icon={<FileText size={13} />} label={t('packing.exportMarkdown')} onClick={choose(packingExport.exportMarkdown)} />
|
||||
<PopoverItem icon={<FileSpreadsheet size={13} />} label={t('packing.exportCsv')} onClick={choose(packingExport.exportCsv)} />
|
||||
<PackingPrintPreview html={packingExport.printHtml} title={packingExport.printTitle} onClose={packingExport.closePrint} />
|
||||
</>
|
||||
)
|
||||
|
||||
return (
|
||||
// A flex box, so the button stretches to the row height like its neighbours in the header.
|
||||
<div ref={menuRef} className="relative flex">
|
||||
|
||||
Reference in New Issue
Block a user