Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/components/FeatureBanner/FeatureBanner.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,25 @@ describe('<FeatureBanner />', () => {
expect(queryByText('FeatureBannerChildElement')).not.toBeNull();
});

describe('without subtitle', () => {
it('does not render subtitle', () => {
const { queryByText } = render(<FeatureBanner title="FeatureBannerTitle" />);

expect(queryByText('FeatureBannerTitle')).not.toBeNull();
});

it('renders title and children', () => {
const { queryByText } = render(
<FeatureBanner title="FeatureBannerTitle">
<span>FeatureBannerChildElement</span>
</FeatureBanner>
);

expect(queryByText('FeatureBannerTitle')).not.toBeNull();
expect(queryByText('FeatureBannerChildElement')).not.toBeNull();
});
});

describe('when dismissable', () => {
it('can be closed', async () => {
const { getByRole, queryByRole } = render(<FeatureBanner {...commonProps} dismissable />);
Expand Down
16 changes: 16 additions & 0 deletions src/components/FeatureBanner/FeatureBanner.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,19 @@ export const LiveExample: Story = {
</FeatureBanner>
),
};

export const WithoutSubtitle: Story = {
args: {
alertText: 'New',
color: 'info',
title: 'Company-Wide View of Text Messages',
},
render: (args) => (
<FeatureBanner {...args}>
<Button color="primary" outline className="fw-bold text-uppercase">
<Icon name="envelope" className="me-2" />
Feedback
</Button>
</FeatureBanner>
),
};
10 changes: 7 additions & 3 deletions src/components/FeatureBanner/FeatureBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ interface FeatureBannerProps {
children?: ReactNode;
color?: string;
dismissable?: boolean;
subtitle: ReactNode;
subtitle?: ReactNode;
title: string;
}

Expand Down Expand Up @@ -36,13 +36,17 @@ const FeatureBanner: FC<FeatureBannerProps> = ({
isOpen={visible}
>
<h2 className={`${alertStyle} text-center m-0 px-3 d-none d-sm-block`}>{alertText}</h2>
<div className={`d-flex flex-row flex-wrap p-3 w-100 ${dismissable ? 'pe-5' : ''}`}>
<div
className={`d-flex flex-row flex-wrap p-3 w-100 ${!subtitle ? 'align-items-center' : ''} ${
dismissable ? 'pe-5' : ''
}`}
>
<div className="flex-fill me-auto">
<div className="d-inline-block m-0">
<h2 className={`${alertStyle} d-inline d-sm-none me-2`}>{alertText}</h2>
<h3 className="d-inline">{title}</h3>
</div>
<p className="m-0">{subtitle}</p>
{subtitle && <p className="m-0">{subtitle}</p>}
</div>
<div className="d-inline-block my-auto">{children}</div>
</div>
Expand Down
Loading