'use client'; import { type CSSProperties } from 'react'; import { AnimatePresence, motion } from 'framer-motion'; import { Trash2 } from 'lucide-react'; import { useEditBar, type EditBarSnapshot } from './EditBarContext'; import DeleteProgressBar from './DeleteProgressBar'; /** * Condensed bulk-edit toolbar that drops into the bottom of the floating nav * once the in-page edit bar has scrolled up behind it, so the selection * count and delete controls stay reachable while you scroll a long list. * Reads its state + handlers from EditBarContext and renders nothing until a * snapshot is registered (selection mode active), so it's inert elsewhere. * * Mirrors : same height/opacity reveal, same full-width * section with a border-top divider connecting it to the row above. */ export default function StickyEditBar() { const { bar, scrolledPast } = useEditBar(); const show = scrolledPast && !!bar; return ( {show && bar && (
)}
); } function BarControls({ bar }: { bar: EditBarSnapshot }) { if (bar.deleting && bar.progress) { return ( <> {bar.waitingSec != null ? `Paced, resuming in ${bar.waitingSec}s` : 'Deleting…'} ); } if (bar.confirming) { return ( <> Delete {bar.selectedCount} record{bar.selectedCount === 1 ? '' : 's'}? This can’t be undone. ); } const selectAllDisabled = bar.totalCount === 0 || bar.allSelected; const nothingSelected = bar.selectedCount === 0; return ( <> {bar.selectedCount} selected ); } // Compact button base — tighter than the in-page bar so the row fits inside // the slim nav card. const miniButton: CSSProperties = { padding: '0.3rem 0.6rem', fontFamily: 'var(--font-serif)', fontSize: '0.75rem', }; function neutralButton(disabled: boolean): CSSProperties { return { ...miniButton, background: 'var(--bg-tertiary)', color: 'var(--text-secondary)', border: '1px solid var(--border-medium)', cursor: disabled ? 'not-allowed' : 'pointer', opacity: disabled ? 0.5 : 1, }; }