diff --git a/src/banner/banner.module.css b/src/banner/banner.module.css
index 64d4322e..ae7d7dc9 100644
--- a/src/banner/banner.module.css
+++ b/src/banner/banner.module.css
@@ -32,6 +32,7 @@
.content {
padding: var(--reactist-spacing-large);
+ align-items: flex-start;
}
.title,
@@ -74,24 +75,29 @@
.copy {
padding: calc(var(--reactist-spacing-xsmall) / 2) 0;
+ flex: 1 1 auto;
}
.copy .inlineLink:first-of-type {
margin-left: var(--reactist-spacing-xsmall);
}
+.actions {
+ align-self: center;
+}
@container banner (width < 235px) {
- .content,
- .staticContent {
+ .content {
flex-direction: column;
- align-items: flex-start;
}
-
.icon {
display: flex;
width: 100%;
align-items: center;
justify-content: space-between;
}
+ .topContent {
+ flex-direction: column;
+ align-items: stretch;
+ }
.icon:has(.closeButton:only-child) {
display: flex;
}
@@ -101,7 +107,9 @@
.icon .closeButton:only-child {
margin-left: auto;
}
-
+ .actions {
+ align-self: flex-start;
+ }
.actions .closeButton {
display: none;
}
diff --git a/src/banner/banner.stories.mdx b/src/banner/banner.stories.mdx
index 15bd8548..64716961 100644
--- a/src/banner/banner.stories.mdx
+++ b/src/banner/banner.stories.mdx
@@ -5,6 +5,8 @@ import { Stack } from '../stack'
import { Banner } from './banner'
import { Button } from '../button'
import { PromoImage } from './story-promo-image'
+import { Notice } from '../notice'
+import { CheckboxField } from '../checkbox-field'
@@ -168,6 +174,29 @@ export function BannerActionExamples({ theme }) {
}}
onClose={() => ({})}
/>
+ }
+ title="This is a sample title"
+ description={getLongDescription()}
+ action={{
+ type: 'button',
+ label: 'Action',
+ variant: 'primary',
+ }}
+ />
+ }
+ title="This is a sample title"
+ description={getLongDescription()}
+ action={{
+ type: 'button',
+ label: 'Action',
+ variant: 'primary',
+ }}
+ onClose={() => ({})}
+ />
)
@@ -230,6 +259,102 @@ export function BannerImageExamples({ theme }) {
)
}
+export function BannerContentExamples({ theme }) {
+ return (
+
+
+
+ Some extra content here
+
+
+ Some extra content here
+
+ ({})}
+ >
+ Some extra content here
+
+ }
+ >
+ Some extra content here
+
+ }
+ action={getButton('Click me!')}
+ >
+ Some extra content here
+
+ }
+ action={getButton('Click me!')}
+ >
+
+ Some extra content here
+
+
+ }
+ action={getButton('Click me!')}
+ >
+
+ {getLongDescription()}
+
+ Please check the box to continue.
+
+
+
+
+ }
+ action={getButton('Click me!')}
+ onClose={() => ({})}
+ >
+
+ {getLongDescription()}
+
+ Please check the box to continue.
+
+
+
+
+
+
+ )
+}
+
# Banner
A simple banner component meant to be used to _inform_ the user of promotional content, disclaimers, warnings, as well as success and error states.
@@ -340,6 +465,22 @@ Image banners do not feature icons but can include body text or a combination of
+### Content
+
+Banners can include extra content.
+
+
+
## Props
diff --git a/src/banner/banner.test.tsx b/src/banner/banner.test.tsx
index ae39ccfb..dd33c318 100644
--- a/src/banner/banner.test.tsx
+++ b/src/banner/banner.test.tsx
@@ -245,4 +245,13 @@ describe('Banner', () => {
const results = await axe(container)
expect(results).toHaveNoViolations()
})
+
+ it('renders a banner with children', () => {
+ render(
+
+ Child content
+ ,
+ )
+ expect(screen.getByText('Child content')).toBeInTheDocument()
+ })
})
diff --git a/src/banner/banner.tsx b/src/banner/banner.tsx
index 103342c2..70464310 100644
--- a/src/banner/banner.tsx
+++ b/src/banner/banner.tsx
@@ -66,6 +66,7 @@ type BaseBanner = {
id?: string
title?: React.ReactNode
description: Exclude
+ children?: React.ReactNode
action?: Action | React.ReactNode
inlineLinks?: InlineLink[]
} & CloseButton
@@ -112,6 +113,7 @@ const Banner = React.forwardRef(function Banner(
type,
title,
description,
+ children,
action,
icon,
image,
@@ -153,57 +155,71 @@ const Banner = React.forwardRef(function Banner(
>
{image ? {image} : null}
-
-
-
- {type === 'neutral' ? icon : }
- {closeButton}
-
+
+
+ {type === 'neutral' ? icon : }
+ {closeButton}
+
-
- {title ? (
-
- {title}
-
- ) : null}
+
+
- {description}
- {inlineLinks?.map(({ label, ...props }, index) => {
- return (
-
-
- {label}
-
- {index < inlineLinks.length - 1 ? · : ''}
-
- )
- })}
+ {title ? (
+
+ {title}
+
+ ) : null}
+
+ {description}
+ {inlineLinks?.map(({ label, ...props }, index) => {
+ return (
+
+
+ {label}
+
+ {index < inlineLinks.length - 1 ? · : ''}
+
+ )
+ })}
+
-
-
- {action || closeButton ? (
-
- {action ? (
- isActionObject(action) ? (
- action.type === 'button' ? (
-
- ) : (
-
- )
- ) : (
- action
- )
+ {action || closeButton ? (
+
+ {action ? (
+ isActionObject(action) ? (
+ action.type === 'button' ? (
+
+ ) : (
+
+ )
+ ) : (
+ action
+ )
+ ) : null}
+ {closeButton}
+
) : null}
- {closeButton}
- ) : null}
+
+ {children}
+
)