Components Menus and overlays

PreviewDialog

A dialog whose values preview live in the document: the kit supplies begin, update and end.

import { PreviewDialog } from '@kition/tessera-ui'

When to use

  • Filters and adjustments (blur, levels) people tune by eye.

Examples

A filter
preview-dialog.tsx
import { useState } from 'react'
import { Button, GradientSlider, PreviewDialog } from '@kition/tessera-ui'

// A dialog whose changes preview live in the document; the kit supplies begin, update and end.
export default function Demo() {
  const [open, setOpen] = useState(false)
  const [amount, setAmount] = useState(40)
  return (
    <>
      <Button onClick={() => setOpen(true)}>Gaussian Blur…</Button>
      {open ? (
        <PreviewDialog
          title="Gaussian Blur"
          preview={{ begin: () => undefined, update: () => undefined, end: () => undefined, draft: amount }}
          onOk={() => setOpen(false)}
          onCancel={() => setOpen(false)}
          onReset={() => setAmount(40)}
        >
          <GradientSlider label="Radius" value={amount} min={0} max={250} onChange={(value) => setAmount(value)} />
        </PreviewDialog>
      ) : null}
    </>
  )
}

Props

PreviewDialog

PropTypeDefaultDescription
titlerequiredstring—
previewPreviewDialogPreview—Shows the Preview check box (on at first) when given; without it the dialog behaves as Dialog.
okLabelstring—
okDisabledbooleanfalse
hideOkbooleanfalseDraws no OK: one button (Cancel, named by cancelLabel) for a dialog that only shows information.
onOkrequired() => Promise<void> | void—Runs the command. The dialog does not close itself: once this resolves, the kit unmounts it (unless keepOpen). A failure shows in the dialog and leaves it open, previewing again.
onCancelrequired() => void—Cancel, Escape, or a press outside (when modal). The kit unmounts the dialog. Not while OK runs.
cancelLabelstring—The Cancel button's label ("Done" in upstream's Find, "Close" for information).
onReset() => void—Alt turns Cancel into Reset, which calls this (restores the dialog's defaults).
keepOpenbooleanfalseOK runs without closing, and the preview stays open (upstream's Find).
modalbooleantrueBlocks the page (the default). With false there is no backdrop: a press outside does not cancel, Tab may leave the dialog, and the editor keeps its keys (to move the playhead under a picture preview). Escape still cancels.
childrenrequiredReactNode—
uiIdstring—The dialog's Kit UI id.
ids{ ok?: string; cancel?: string; preview?: string }—The buttons' Kit UI ids; Reset is the Cancel button.
testIdstring'preview-dialog'
position{ x: number; y: number } | null—Where the dialog sits (with onMove), as Dialog's; absent: where the layout puts it.
onMove(position: { x: number; y: number }) => void—Makes the dialog movable by its title, as Dialog's (a kit keeps the place); absent, it does not move.

Used in

1 of Kition's 16 kits use this component.

  • Film