Details modal

A record read in a modal: its key facts and actions, tabs over its history, and moving to the previous or next record.

Open full screen

A panel opens over any screen and keeps its own look in every direction: it has no direction of its own.

npx wideset add block-modal-details

Import the default export from @/blocks/wideset/modal-details. The files below are relative to your project's source directory.

Installed with this block
  • block-styles
  • button
  • icon-button
  • modal
  • tabs
  • utils
blocks/wideset/modal-details/index.tsx
'use client';

import '@/styles/wideset-blocks.css';

import { Button } from '@/components/ui/wideset/button/Button';
import { useState } from 'react';

import { orders } from './data';
import { OrderDetailsModal } from './order-details-modal';

/** Details modal: a record read over the page, here over an empty page that reopens it. */
export default function ModalDetailsBlock() {
  const [open, setOpen] = useState(true);
  // The middle order of three, so both steps in the footer have somewhere to go.
  const [index, setIndex] = useState(1);

  return (
    <div className="ws-block-utility bg-ws-static-foreground flex h-dvh items-center justify-center">
      <Button variant="secondary" preset="border" onClick={() => setOpen(true)}>
        Open order
      </Button>
      <OrderDetailsModal
        order={orders[index]}
        open={open}
        onOpenChange={setOpen}
        onPrevious={index > 0 ? () => setIndex((index) => index - 1) : undefined}
        onNext={index < orders.length - 1 ? () => setIndex((index) => index + 1) : undefined}
      />
    </div>
  );
}