Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.6 KB
Raw Blame
import React, { useId, type ReactNode } from 'react';
import { useTranslation } from '../../i18n';
import {
  DialogButton,
  DialogFooter,
  DialogHeader,
  DialogShell,
  DialogTile,
  FooterSpacer,
  NEUTRAL_TINT,
} from '../shared/DialogShell';

/**
 * The dialog an addon's setup row opens: the icon tile, the addon it belongs
 * to above the title, what it sets up below, and one Close. The paddle water
 * data saves on its own; the booking mail setup has its own Save and asks
 * before a way out drops what it holds unsaved.
 */
export default function AddonSetupDialog({
  icon,
  eyebrow,
  title,
  sub,
  onClose,
  blocked = false,
  children,
}: {
  icon: ReactNode;
  eyebrow: string;
  title: string;
  sub: string;
  onClose: () => void;
  /** A confirmation stacked on top holds the dialog while it is open. */
  blocked?: boolean;
  children: ReactNode;
}): React.ReactElement {
  const { t } = useTranslation();
  const labelId = useId();
  return (
    <DialogShell
      onClose={onClose}
      labelledBy={labelId}
      width="detail"
      blocked={blocked}
      header={
        <DialogHeader
          tile={<DialogTile>{icon}</DialogTile>}
          tint={NEUTRAL_TINT}
          labelId={labelId}
          eyebrow={eyebrow}
          title={title}
          sub={sub}
          subWraps
          onClose={onClose}
        />
      }
      footer={
        <DialogFooter>
          <FooterSpacer />
          <DialogButton variant="primary" onClick={onClose}>
            {t('common.close')}
          </DialogButton>
        </DialogFooter>
      }
    >
      {children}
    </DialogShell>
  );
}