'use client' import { forwardRef } from 'react' import { isBezierIcon } from '@channel.io/bezier-icons' import classNames from 'classnames' import { warn } from '~/src/utils/assert' import { isNil } from '~/src/utils/type' import { Button } from '~/src/components/Button' import { Icon } from '~/src/components/Icon' import { LegacyIcon, isIconName } from '~/src/components/LegacyIcon' import { Text } from '~/src/components/Text' import { type BannerProps, type BannerVariant, type RenderLinkFunc, } from './Banner.types' import styles from './Banner.module.scss' const BANNER_TEST_ID = 'bezier-banner' function getActionButtonColorVariant(variant: BannerVariant) { return ( { default: 'monochrome-dark', blue: 'blue', cobalt: 'cobalt', green: 'green', orange: 'orange', red: 'red', alt: 'monochrome-dark', } as const )[variant] } const externalLinkRenderer: RenderLinkFunc = ({ content, linkTo }) => ( {content} ) /** * `Banner` is a component you use when you want to communicate instructions, warnings, recommendations, and other information well. * @example * ```tsx * * ``` */ export const Banner = forwardRef(function Banner( { className, variant = 'default', icon, iconColor, content, hasLink = false, linkText, linkTo, renderLink = externalLinkRenderer, actionIcon, onClickAction, ...rest }, forwardedRef ) { if (isIconName(icon)) { warn( 'Deprecation: IconName as a value for the icon property of Banner has been deprecated. Use the Icon of bezier-icons instead.', 'Banner.IconName' ) } return (
{!isNil(icon) && (
{isBezierIcon(icon) ? ( ) : ( )}
)}
{content} {hasLink && renderLink({ content: ( {linkText} ), linkTo, })}
{!isNil(actionIcon) && (
)}
) })