File tree Expand file tree Collapse file tree 1 file changed +24
-3
lines changed
Expand file tree Collapse file tree 1 file changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ type BaseBanner = {
6363 id ?: string
6464 title ?: React . ReactNode
6565 description : Exclude < React . ReactNode , null | undefined | boolean >
66- action ?: Action
66+ action ?: Action | React . ReactNode
6767 inlineLinks ?: InlineLink [ ]
6868} & CloseButton
6969
@@ -91,6 +91,18 @@ type SystemBanner = BaseBanner & {
9191
9292type BannerProps = NeutralBanner | SystemBanner
9393
94+ /**
95+ * Type guard to check if the action is an Action object (button or link)
96+ */
97+ function isActionObject ( action : Action | React . ReactNode ) : action is Action {
98+ return (
99+ typeof action === 'object' &&
100+ action !== null &&
101+ 'type' in action &&
102+ ( action . type === 'button' || action . type === 'link' )
103+ )
104+ }
105+
94106const Banner = React . forwardRef < HTMLDivElement , BannerProps > ( function Banner (
95107 {
96108 id,
@@ -175,8 +187,17 @@ const Banner = React.forwardRef<HTMLDivElement, BannerProps>(function Banner(
175187
176188 { action || closeButton ? (
177189 < Box className = { styles . actions } display = "flex" gap = "small" >
178- { action ?. type === 'button' ? < ActionButton { ...action } /> : null }
179- { action ?. type === 'link' ? < ActionLink { ...action } /> : null }
190+ { action ? (
191+ isActionObject ( action ) ? (
192+ action . type === 'button' ? (
193+ < ActionButton { ...action } />
194+ ) : (
195+ < ActionLink { ...action } />
196+ )
197+ ) : (
198+ action
199+ )
200+ ) : null }
180201 { closeButton }
181202 </ Box >
182203 ) : null }
You can’t perform that action at this time.
0 commit comments