/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ import { BanIcon, ExclamationIcon, InformationCircleIcon, XIcon, } from "@heroicons/react/solid"; import { CustomContentProps, SnackbarContent, useSnackbar } from "notistack"; import { forwardRef } from "react"; import { MessageLevel, MessageSource } from "../lib/stores"; // https://notistack.com/examples/advanced/custom-component#custom-variant-(typescript) declare module "notistack" { interface VariantOverrides { message: { title: string; level: MessageLevel; codeframe: string | undefined; }; } } interface MessageProps extends CustomContentProps { title: string; level: MessageLevel; source: MessageSource; codeframe: string | undefined; } const Message = forwardRef( ({ id, title, level, source, codeframe }, ref) => { const { closeSnackbar } = useSnackbar(); const isDismissible = source !== MessageSource.Playground; return (
{level === MessageLevel.Warning ? (
) : level === MessageLevel.Error ? (
) : (
)}

{title}

{codeframe ? (
                {codeframe}
              
) : null}
{isDismissible ? ( ) : null}
); } ); Message.displayName = "MessageComponent"; export default Message;