Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SectionalBanner)!: fix html and less restrictive usage #988

Merged
merged 1 commit into from
Sep 10, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@ exports[`ErrorSummary matches the snapshot 1`] = `
outline-offset: -2px;
}

.c4 {
color: #1B1C1E;
font-size: 1rem;
font-weight: var(--font-semi-bold);
line-height: 1.5rem;
margin: 0;
}

.c2 {
grid-area: icon;
margin-top: var(--spacing-half);
Expand Down Expand Up @@ -80,7 +88,7 @@ exports[`ErrorSummary matches the snapshot 1`] = `

.c5 {
font-size: 0.875rem;
margin: var(--spacing-half) 0 0 0;
margin: 0;
}

.c3 {
Expand All @@ -89,13 +97,6 @@ exports[`ErrorSummary matches the snapshot 1`] = `
margin-left: var(--spacing-1halfx);
}

.c4 {
font-size: 1rem;
font-weight: var(--font-semi-bold);
line-height: 1.5;
margin: 0;
}

.c6 {
font-size: 0.875rem;
margin: var(--spacing-1x) 0 0 0;
Expand All @@ -116,12 +117,8 @@ exports[`ErrorSummary matches the snapshot 1`] = `
margin-bottom: var(--spacing-1x);
}

<section
aria-atomic="true"
aria-labelledby="uuid1"
aria-live="assertive"
<div
class="c0"
role="alert"
tabindex="-1"
>
<svg
Expand Down Expand Up @@ -175,5 +172,5 @@ exports[`ErrorSummary matches the snapshot 1`] = `
</ul>
</div>
</div>
</section>
</div>
`;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { findByTestId, getByTestId } from '../../test-utils/enzyme-selectors';
import { getByTestId } from '../../test-utils/enzyme-selectors';
import { mountWithProviders, renderWithProviders } from '../../test-utils/renderer';
import { DeviceType } from '../device-context-provider/device-context-provider';
import { SectionalBanner } from './sectional-banner';
Expand Down Expand Up @@ -43,22 +43,6 @@ describe('SectionalBanner', () => {
});

(['mobile', 'desktop'] as DeviceType[]).forEach((device) => {
it(`should not show dismiss button when type is alert (${device})`, () => {
const wrapper = mountWithProviders(
<SectionalBanner
type="alert"
onDismiss={jest.fn()}
>
Test
</SectionalBanner>,
{ wrappingComponentProps: { staticDevice: device } },
);

const dismissButton = findByTestId(wrapper, 'dismiss-button');

expect(dismissButton.exists()).toBe(false);
});

it(`should show destructive button when type is alert (${device})`, () => {
const wrapper = mountWithProviders(
<SectionalBanner
Expand Down Expand Up @@ -91,7 +75,7 @@ describe('SectionalBanner', () => {

getByTestId(wrapper, 'dismiss-button').simulate('click');

expect(onDismiss).toBeCalled();
expect(onDismiss).toHaveBeenCalled();
});

it(`should call callback when button is clicked (${device})`, () => {
Expand All @@ -109,7 +93,7 @@ describe('SectionalBanner', () => {

getByTestId(wrapper, `${device}-button`).simulate('click');

expect(onButtonClicked).toBeCalled();
expect(onButtonClicked).toHaveBeenCalled();
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ exports[`SectionalBanner should match snapshot (custom message) 1`] = `
width: 1rem;
}

.c5 {
.c4 {
font-size: 0.875rem;
margin: var(--spacing-half) 0 0 0;
margin: 0;
}

.c3 {
Expand All @@ -52,19 +52,8 @@ exports[`SectionalBanner should match snapshot (custom message) 1`] = `
margin-left: var(--spacing-1halfx);
}

.c4 {
font-size: 1rem;
font-weight: var(--font-semi-bold);
line-height: 1.5;
margin: 0;
}

<section
aria-atomic="true"
aria-labelledby="uuid1"
aria-live="polite"
<div
class="c0"
role="status"
>
<svg
aria-hidden="true"
Expand All @@ -77,14 +66,8 @@ exports[`SectionalBanner should match snapshot (custom message) 1`] = `
<div
class="c3"
>
<span
class="c4"
id="uuid1"
>
Information
</span>
<div
class="c5"
class="c4"
>
<p>
Some sub title
Expand All @@ -96,7 +79,7 @@ exports[`SectionalBanner should match snapshot (custom message) 1`] = `
</ul>
</div>
</div>
</section>
</div>
`;

exports[`SectionalBanner should match snapshot (desktop) 1`] = `
Expand Down Expand Up @@ -140,9 +123,9 @@ exports[`SectionalBanner should match snapshot (desktop) 1`] = `
width: 1rem;
}

.c5 {
.c4 {
font-size: 0.875rem;
margin: var(--spacing-half) 0 0 0;
margin: 0;
}

.c3 {
Expand All @@ -151,19 +134,8 @@ exports[`SectionalBanner should match snapshot (desktop) 1`] = `
margin-left: var(--spacing-1halfx);
}

.c4 {
font-size: 1rem;
font-weight: var(--font-semi-bold);
line-height: 1.5;
margin: 0;
}

<section
aria-atomic="true"
aria-labelledby="uuid1"
aria-live="polite"
<div
class="c0"
role="status"
>
<svg
aria-hidden="true"
Expand All @@ -176,19 +148,13 @@ exports[`SectionalBanner should match snapshot (desktop) 1`] = `
<div
class="c3"
>
<span
class="c4"
id="uuid1"
>
Information
</span>
<p
class="c5"
class="c4"
>
Test
</p>
</div>
</section>
</div>
`;

exports[`SectionalBanner should match snapshot (mobile) 1`] = `
Expand Down Expand Up @@ -231,9 +197,9 @@ exports[`SectionalBanner should match snapshot (mobile) 1`] = `
width: 1rem;
}

.c5 {
.c4 {
font-size: 1rem;
margin: var(--spacing-2x) 0 0 0;
margin: 0;
}

.c3 {
Expand All @@ -242,19 +208,8 @@ exports[`SectionalBanner should match snapshot (mobile) 1`] = `
margin-left: var(--spacing-1halfx);
}

.c4 {
font-size: 1.125rem;
font-weight: var(--font-semi-bold);
line-height: 1.7;
margin: 0;
}

<section
aria-atomic="true"
aria-labelledby="uuid1"
aria-live="polite"
<div
class="c0"
role="status"
>
<svg
aria-hidden="true"
Expand All @@ -267,17 +222,11 @@ exports[`SectionalBanner should match snapshot (mobile) 1`] = `
<div
class="c3"
>
<span
class="c4"
id="uuid1"
>
Information
</span>
<p
class="c5"
class="c4"
>
Test
</p>
</div>
</section>
</div>
`;
Loading