/** * React Fabric * @version 1.0.0 * @license MIT * @copyright 2024 Adarsh Pastakia * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ import { cn } from "@react-fabric/utilities"; import type { ChildrenProp, ColorBase, CssPropWithMap, TestProps } from "../../types"; import { getIconProps } from "../../utils"; import type { IconProps } from "../icon/Icon"; import { Icon } from "../icon/Icon"; export interface CalloutProps extends ChildrenProp, CssPropWithMap<{ root: string; legend: string; title: string; icon: string }>, TestProps { /** * callout color */ color?: ColorBase | "default"; /** * legend title */ legend?: string | React.ReactElement; /** * callout icon */ icon?: IconProps; /** * callout title */ title?: string | React.ReactElement; /** * callout border style */ border?: "solid" | "dotted" | "dashed"; /** * close action handler */ onClose?: () => void; } /** * A component that displays a callout box with an optional title, icon, and legend. * It can be used to highlight important information, warnings, or notices. * The callout can be styled with different colors and border styles, and it supports a close action. * This component is useful for drawing attention to specific content within a page or application, * such as alerts, notifications, or important messages. * * @example * ```jsx * console.log("Callout closed")} * > * This is an important message that requires your attention. * * // Renders a callout box with a primary color, an icon, a title, and a close button. * ``` */ export function Callout({ children, color = "default", classNames, legend, title, icon, border = "solid", onClose, className, ...props }: CalloutProps) { return (
{legend && ( {legend} )}
{icon && } {title && (

{title}

)}
{children}
{onClose && (
)}
); }