mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-12-03 13:19:58 -05:00
ui: let a confirmation choose its width
Confirm hardcoded `size='tiny'` and its props interface accepted no size, so every confirmation in the app was 380px whatever it held. That is right for eight of the nine call sites and for the ~30 prose confirmations `useAPIButton` renders behind a `confirmContent` -- and wrong for TaggedDeleteConfirmModal, which lists file paths beside their tags in a two-column table and had no way to say so. `size` is now a default, not a fixture, in the same vocabulary as Modal. Only TaggedDeleteConfirmModal changes: `large`, 620px. The table scrolls sideways in its own container, so the width decides how much of a path is readable without dragging, and at 380px that was the first two directories. Tests, written first: - Confirm resolves to `sm` by default and `lg` when a call site asks, measured off the `--modal-size` Mantine writes on the modal root rather than restated. - TaggedDeleteConfirmModal renders at `lg` while a plain confirmation beside it stays `sm`, so it cannot pass by confirmations having become wide for everyone. - The existing "no unknown size name" guard now scans `<Confirm` too, since Confirm forwards the name to Modal and is the same hazard, with a premise check that at least one confirmation names a size. Both new tests read EVERY modal root, not the first. A modal is portalled to document.body, so two renders in one test both land there and querySelector returns whichever opened first -- which is how the first version reported the default twice and read as though the size prop had no effect. The gallery gains the wide confirmation next to the narrow one, so both are checkable in all four themes. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
90c2868c4f
commit
1d4374854a
5 changed files with 146 additions and 4 deletions
|
|
@ -146,6 +146,7 @@ let toastCounter = 0;
|
|||
export function ThemeSamplePage() {
|
||||
const {theme} = useContext(ThemeContext);
|
||||
const [confirmOpen, setConfirmOpen] = useState(false);
|
||||
const [wideConfirmOpen, setWideConfirmOpen] = useState(false);
|
||||
const [comments, setComments] = useState(true);
|
||||
const [hotspot, setHotspot] = useState(true);
|
||||
const [dismissed, setDismissed] = useState(false);
|
||||
|
|
@ -929,7 +930,14 @@ export function ThemeSamplePage() {
|
|||
<Button role='danger' icon='trash' onClick={() => setConfirmOpen(true)}>
|
||||
Wipe download history
|
||||
</Button>
|
||||
<Button role='danger' icon='trash' onClick={() => setWideConfirmOpen(true)}>
|
||||
Delete tagged files
|
||||
</Button>
|
||||
</Row>
|
||||
<p style={{fontSize: 12, color: 'var(--muted)', marginBottom: 0, marginTop: 10}}>
|
||||
A confirmation is 380px wide, which suits a question. One that has to show
|
||||
what it is about takes a size, in the same vocabulary as Modal.
|
||||
</p>
|
||||
</Panel>
|
||||
</Section>
|
||||
|
||||
|
|
@ -948,5 +956,35 @@ export function ThemeSamplePage() {
|
|||
videos/Wranglerstar/ (312 files) will not be deleted.
|
||||
</p>
|
||||
</Confirm>
|
||||
|
||||
<Confirm
|
||||
open={wideConfirmOpen}
|
||||
size='large'
|
||||
destructive
|
||||
title={<><Icon name='warning sign'/> Tagged files will be deleted</>}
|
||||
confirmLabel='Delete'
|
||||
onConfirm={() => setWideConfirmOpen(false)}
|
||||
onCancel={() => setWideConfirmOpen(false)}
|
||||
>
|
||||
<p style={{marginTop: 0}}>The following tagged files will be deleted:</p>
|
||||
<Table>
|
||||
<Table.Header>
|
||||
<Table.Row>
|
||||
<Table.HeaderCell>File</Table.HeaderCell>
|
||||
<Table.HeaderCell>Tags</Table.HeaderCell>
|
||||
</Table.Row>
|
||||
</Table.Header>
|
||||
<Table.Body>
|
||||
<Table.Row>
|
||||
<Table.Cell>videos/Practical Engineering/Season 2024/Spillways.mp4</Table.Cell>
|
||||
<Table.Cell>favorite, water</Table.Cell>
|
||||
</Table.Row>
|
||||
<Table.Row>
|
||||
<Table.Cell>archives/en.wikipedia.org/Sluice_gate.html</Table.Cell>
|
||||
<Table.Cell>water</Table.Cell>
|
||||
</Table.Row>
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</Confirm>
|
||||
</div>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue