Skip to content

Commit

Permalink
remove panel title for warn announcment and bare panels
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccar committed Dec 20, 2024
1 parent f32bd96 commit a65e589
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/panel/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
<span class="ons-panel__assistive-text ons-u-vh">{{ params.assistiveTextPrefix | default("Announcement: ") }}</span>
{% endif %}

{% if params.title %}
{% if params.title and (params.variant not in ['bare', 'warn', 'warn-branded', 'announcement'] ) %}
{% if params.variant == 'error' %}
{% set defaultTitleTag = "h" ~ 2 %}
{% else %}
Expand Down
16 changes: 15 additions & 1 deletion src/components/panel/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('macro: panel', () => {
expect(results).toHaveNoViolations();
});

it('has correct class', () => {
it('has correct panel variant class', () => {
const $ = cheerio.load(
renderComponent('panel', {
...EXAMPLE_PANEL_BASIC,
Expand Down Expand Up @@ -173,6 +173,20 @@ describe('macro: panel', () => {
});
});

describe.each(['bare', 'warn', 'warn-branded', 'announcement'])('mode: %s', (panelVariant) => {
it('does not render a title when `title` is provided', () => {
const $ = cheerio.load(
renderComponent('panel', {
...EXAMPLE_PANEL_BASIC,
title: 'Panel title',
variant: panelVariant,
}),
);

expect($('.ons-panel__title').length).toBe(0);
});
});

describe.each([
['error', 'h2'],
['success', 'div'],
Expand Down

0 comments on commit a65e589

Please sign in to comment.