74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
"use client";
|
|
/*
|
|
* Documentation:
|
|
* Button — https://app.subframe.com/f023064a5ca0/library?component=Button_3b777358-b86b-40af-9327-891efc6826fe
|
|
* Confirm Dialog — https://app.subframe.com/f023064a5ca0/library?component=Confirm+Dialog_7826382f-0b13-45d9-ac8f-238fa6de9121
|
|
*/
|
|
|
|
import React from "react";
|
|
import { FeatherAlertTriangle } from "@subframe/core";
|
|
import * as SubframeUtils from "../../utils";
|
|
import { Button } from "../Button";
|
|
|
|
export interface ConfirmDialogRootProps
|
|
extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
|
|
state?: "open" | "processing" | "closed";
|
|
title?: React.ReactNode;
|
|
description?: React.ReactNode;
|
|
confirmLabel?: React.ReactNode;
|
|
cancelLabel?: React.ReactNode;
|
|
className?: string;
|
|
}
|
|
|
|
const ConfirmDialogRoot = React.forwardRef<
|
|
HTMLDivElement,
|
|
ConfirmDialogRootProps
|
|
>(function ConfirmDialogRoot(
|
|
{
|
|
state = "open",
|
|
title,
|
|
description,
|
|
confirmLabel,
|
|
cancelLabel,
|
|
className,
|
|
...otherProps
|
|
}: ConfirmDialogRootProps,
|
|
ref
|
|
) {
|
|
return (
|
|
<div
|
|
className={SubframeUtils.twClassNames(
|
|
"group/7826382f flex h-full w-full flex-col items-center justify-center gap-2 bg-surface-neutral-overlay group/confirmdialog",
|
|
{ hidden: state === "closed" },
|
|
className
|
|
)}
|
|
ref={ref}
|
|
{...otherProps}
|
|
>
|
|
<div className="flex w-96 flex-col items-start gap-6 rounded-lg border border-solid border-border-default bg-surface-neutral-modal px-6 py-6 shadow-lg max-w-full mobile:w-full mobile:flex-none">
|
|
<div className="flex h-12 w-12 flex-none items-center justify-center gap-2 rounded-round bg-surface-feedback-subtle-negative">
|
|
<FeatherAlertTriangle className="text-heading-0 font-heading-0 text-icon-feedback-negative" />
|
|
</div>
|
|
<div className="flex w-full flex-col items-start gap-2">
|
|
{title ? (
|
|
<span className="w-full text-heading-0 font-heading-0 text-text-neutral-primary">
|
|
{title}
|
|
</span>
|
|
) : null}
|
|
{description ? (
|
|
<span className="w-full text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
|
{description}
|
|
</span>
|
|
) : null}
|
|
</div>
|
|
<div className="flex w-full items-center justify-end gap-2 mobile:flex-col-reverse mobile:items-stretch">
|
|
<Button variant="tertiary">{cancelLabel}</Button>
|
|
<Button variant="destructive">{confirmLabel}</Button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
});
|
|
|
|
export const ConfirmDialog = ConfirmDialogRoot;
|