41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { ReactNode } from "react";
|
|
import { useTranslation } from "react-i18next";
|
|
import { Link } from "react-router";
|
|
import { BannerAlert } from "~/ui/components/BannerAlert";
|
|
|
|
// Subframe migration (strangler shim):
|
|
// Keeps the original SuccessBanner API but renders the Subframe design-system BannerAlert
|
|
// (type="success"). BannerAlert has no separate title slot, so the (optional, translated) title
|
|
// is composed into the content (rendered bold) alongside text/redirect/children. As before, the
|
|
// title is only shown when provided and is passed through `t()`. `redirect` maps to
|
|
// BannerAlert's `actionLabel` (the underlined action).
|
|
|
|
interface Props {
|
|
title?: string;
|
|
text?: ReactNode | string;
|
|
redirect?: string;
|
|
children?: ReactNode;
|
|
}
|
|
|
|
export default function SuccessBanner({ title, text = "", redirect, children }: Props) {
|
|
const { t } = useTranslation();
|
|
return (
|
|
<BannerAlert
|
|
className="not-prose"
|
|
type="success"
|
|
fillContainer
|
|
actionLabel={
|
|
redirect ? (
|
|
<Link to={redirect}>
|
|
{t("shared.goTo")} {redirect}
|
|
</Link>
|
|
) : undefined
|
|
}
|
|
>
|
|
{title && <span className="font-medium">{t(title)} </span>}
|
|
{text}
|
|
{children}
|
|
</BannerAlert>
|
|
);
|
|
}
|