diff --git a/src/components/FeatureBanner/FeatureBanner.spec.tsx b/src/components/FeatureBanner/FeatureBanner.spec.tsx
index 9690fe1b9..2d749b6f2 100644
--- a/src/components/FeatureBanner/FeatureBanner.spec.tsx
+++ b/src/components/FeatureBanner/FeatureBanner.spec.tsx
@@ -1,4 +1,4 @@
-import { render } from '@testing-library/react';
+import { render, waitFor } from '@testing-library/react';
import React from 'react';
import FeatureBanner from './FeatureBanner';
@@ -38,4 +38,16 @@ describe('', () => {
expect(queryByText('FeatureBannerChildElement')).not.toBeNull();
});
+
+ describe('when dismissable', () => {
+ it('can be closed', async () => {
+ const { getByRole, queryByRole } = render();
+ const closeButton = getByRole('button');
+ expect(queryByRole('alert')).not.toBeNull();
+ closeButton.click();
+ await waitFor(() => {
+ expect(queryByRole('alert')).toBeNull();
+ });
+ });
+ });
});
diff --git a/src/components/FeatureBanner/FeatureBanner.stories.tsx b/src/components/FeatureBanner/FeatureBanner.stories.tsx
index 98f17b361..c87bbf938 100644
--- a/src/components/FeatureBanner/FeatureBanner.stories.tsx
+++ b/src/components/FeatureBanner/FeatureBanner.stories.tsx
@@ -26,6 +26,7 @@ export const LiveExample: Story = {
args: {
alertText: 'New',
color: 'info',
+ dismissable: false,
title: 'Company-Wide View of Text Messages',
subtitle: 'View all text messages sent by your company from this page.',
},
diff --git a/src/components/FeatureBanner/FeatureBanner.tsx b/src/components/FeatureBanner/FeatureBanner.tsx
index e1ea0c353..632adabaa 100644
--- a/src/components/FeatureBanner/FeatureBanner.tsx
+++ b/src/components/FeatureBanner/FeatureBanner.tsx
@@ -1,10 +1,11 @@
-import React, { FC, ReactNode } from 'react';
+import React, { FC, ReactNode, useState } from 'react';
import { Alert } from 'reactstrap';
interface FeatureBannerProps {
alertText?: string;
children?: ReactNode;
color?: string;
+ dismissable?: boolean;
subtitle: ReactNode;
title: string;
}
@@ -12,20 +13,30 @@ interface FeatureBannerProps {
const defaultProps = {
alertText: 'new',
color: 'info',
+ dismissable: false,
};
const FeatureBanner: FC = ({
alertText = defaultProps.alertText,
color = defaultProps.color,
+ dismissable = defaultProps.dismissable,
title,
subtitle,
children,
}) => {
const alertStyle = 'fw-bold text-uppercase';
+ const [visible, setVisible] = useState(true);
+ const toggle = dismissable ? () => setVisible(!visible) : undefined;
return (
-
+
{alertText}
-