Skip to content

Commit

Permalink
Merge branch 'main' into update-bowser-banner-tests-to-fit-new-format
Browse files Browse the repository at this point in the history
  • Loading branch information
rmccar authored Nov 12, 2024
2 parents 5e35b7a + 1300be4 commit f5ab47e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/button/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
{# Default icon position before label #}
{% set iconPosition = "before" %}
{% endif %}
{% elif params.iconType is not defined and params.noIcon is not defined %}
{% elif params.iconType is not defined and params.noIcon != true %}
{% if params.url and params.newWindow %}
{# CTA link opening in new tab #}
{% set iconType = "external-link" %}
Expand Down
24 changes: 24 additions & 0 deletions src/components/button/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,30 @@ describe('macro: button', () => {
expect(iconsSpy.occurrences[0].iconType).toBe('arrow-next');
});

it('has no icon when noIcon is set to true', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
url: 'http://example.com',
noIcon: true,
});

expect(iconsSpy.occurrences[0]).toBeUndefined();
});

it('has default `arrow-next` icon when noIcon is set to false', () => {
const faker = templateFaker();
const iconsSpy = faker.spy('icon');

faker.renderComponent('button', {
url: 'http://example.com',
noIcon: false,
});

expect(iconsSpy.occurrences[0].iconType).toBe('arrow-next');
});

it('opens in a new window when `newWindow` is `true`', () => {
const $ = cheerio.load(
renderComponent('button', {
Expand Down
15 changes: 9 additions & 6 deletions src/components/section-navigation/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
class="ons-section-nav__item{{ ' ' + item.classes if item.classes else '' }}{{ ' ons-section-nav__item--active' if isCurrent == true }}"
>
{% if isCurrent == true %}
{{ openingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}"
aria-current="location">{{ item.text }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
<a
class="ons-section-nav__link ons-section-nav__item-header"
href="{{ item.url }}"
aria-current="location"
>{{ item.text }}</a
>
{% else %}
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.text }}</a>
{% endif %}
Expand Down Expand Up @@ -71,9 +74,9 @@
class="ons-section-nav__item{{ ' ' + item.classes if item.classes else '' }}{% if isCurrent == true %}{{ ' ' }}ons-section-nav__item--active{% endif %}"
>
{% if isCurrent == true %}
{{ openingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}"
aria-current="location">{{ item.text }}{{ closingHeadingTag | replace(headingLevel, sectionItemHeadingLevel | string) | safe }}
<a class="ons-section-nav__link ons-section-nav__item-header" href="{{ item.url }}" aria-current="location"
>{{ item.text }}</a
>
{% else %}
<a class="ons-section-nav__link" href="{{ item.url }}">{{ item.text }}</a>
{% endif %}
Expand Down

0 comments on commit f5ab47e

Please sign in to comment.