22
33import { InfoCircledIcon } from '@radix-ui/react-icons' ;
44import { type VariantProps , cva } from 'class-variance-authority' ;
5- import { type ComponentPropsWithoutRef } from 'react' ;
6- import * as React from 'react' ;
5+ import {
6+ CSSProperties ,
7+ type HTMLAttributes ,
8+ ReactNode ,
9+ forwardRef
10+ } from 'react' ;
711
812import styles from './callout.module.css' ;
913
@@ -31,18 +35,18 @@ const callout = cva(styles.callout, {
3135} ) ;
3236
3337export interface CalloutProps
34- extends ComponentPropsWithoutRef < 'div' > ,
38+ extends HTMLAttributes < HTMLDivElement > ,
3539 VariantProps < typeof callout > {
36- children : React . ReactNode ;
37- action ?: React . ReactNode ;
40+ children : ReactNode ;
41+ action ?: ReactNode ;
3842 dismissible ?: boolean ;
3943 onDismiss ?: ( ) => void ;
4044 width ?: string | number ;
41- style ?: React . CSSProperties ;
42- icon ?: React . ReactNode ;
45+ style ?: CSSProperties ;
46+ icon ?: ReactNode ;
4347}
4448
45- export const Callout = React . forwardRef < HTMLDivElement , CalloutProps > (
49+ export const Callout = forwardRef < HTMLDivElement , CalloutProps > (
4650 (
4751 {
4852 className,
@@ -55,7 +59,7 @@ export const Callout = React.forwardRef<HTMLDivElement, CalloutProps>(
5559 onDismiss,
5660 width,
5761 style,
58- icon,
62+ icon = < InfoCircledIcon /> ,
5963 ...props
6064 } ,
6165 ref
@@ -87,12 +91,10 @@ export const Callout = React.forwardRef<HTMLDivElement, CalloutProps>(
8791 >
8892 < div className = { styles . container } >
8993 < div className = { styles . messageContainer } >
90- { icon !== undefined ? (
94+ { icon && (
9195 < div className = { styles . icon } aria-hidden = 'true' >
9296 { icon }
9397 </ div >
94- ) : (
95- < InfoCircledIcon className = { styles . icon } aria-hidden = 'true' />
9698 ) }
9799 < div className = { styles . message } > { children } </ div >
98100 </ div >
0 commit comments