mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-30 16:33:16 +00:00
e459ec6e60
The setup only keeps its fields through its own Save, yet Close, the close mark, the backdrop and the phone sheet dropped them without a word. Now each way out asks, and discarding puts the saved values back.
70 lines
1.6 KiB
TypeScript
70 lines
1.6 KiB
TypeScript
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>
|
|
);
|
|
}
|