Skip to content

Commit

Permalink
Updated color of check icon for summary variant in list component to …
Browse files Browse the repository at this point in the history
…green (#3318)

* changes as per the ticket

* Update src/components/list/_list.scss

Co-authored-by: rmccar <[email protected]>

* Changes in list macro

* changes as per tech session

* snapshot update

---------

Co-authored-by: rmccar <[email protected]>
Co-authored-by: Alessio Venturini <[email protected]>
  • Loading branch information
3 people authored Aug 30, 2024
1 parent c74c189 commit 650f48a
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
4 changes: 0 additions & 4 deletions __snapshots__/layout/_template.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,6 @@ exports[`base page template matches the full configuration snapshot 1`] = `




<ul class="ons-list ons-u-mb-no ons-list--bare">


Expand Down Expand Up @@ -1460,7 +1459,6 @@ exports[`base page template matches the full configuration snapshot 1`] = `




<ul class="ons-list ons-u-mb-no ons-list--bare">


Expand Down Expand Up @@ -1525,7 +1523,6 @@ exports[`base page template matches the full configuration snapshot 1`] = `




<ul class="ons-list ons-u-mb-no ons-list--bare">


Expand Down Expand Up @@ -1606,7 +1603,6 @@ exports[`base page template matches the full configuration snapshot 1`] = `




<ul class="ons-list ons-u-mb-s ons-footer--rows ons-list--bare ons-list--inline">


Expand Down
6 changes: 6 additions & 0 deletions src/components/list/_list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
@extend .ons-u-pb-s;
@extend .ons-u-m-no;
}
.ons-list__prefix,
.ons-list__suffix {
&--icon-check .ons-icon {
fill: var(--ons-color-leaf-green) !important;
}
}
}
}

Expand Down
11 changes: 8 additions & 3 deletions src/components/list/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
{% endif %}
{% set openingTag = "<" + listEl %}
{% set closingTag = "</" + listEl + ">" %}

{{ openingTag | safe }}{% if params.id %}{{ ' ' }}id="{{ params.id }}"{% endif %}
class="ons-list{{ ' ons-list--p' if listEl == 'p' }}{{ ' ' + params.classes if params.classes else '' }}{% if params.variants %}{% if params.variants is not string %}{% for variant in variants %}{{ ' ' }}ons-list--{{ variant }}{% endfor %}{% else %}{{ ' ' }}ons-list--{{ variants }}{% endif %}{% endif %}{{ ' ' + otherClasses if otherClasses else '' }}"{% if params.attributes %}{% for attribute, value in (params.attributes.items() if params.attributes is mapping and params.attributes.items else params.attributes) %}{{ ' ' }}{{ attribute }}{% if value %}="{{ value }}"{% endif %}{% endfor %}{% endif %}>
{%- for item in params.itemsList -%}
Expand All @@ -48,7 +47,10 @@
{% endif %}

{%- if item.prefix or (params.iconPosition == 'before') -%}
<span class="ons-list__prefix" {% if listEl != 'ol' %}aria-hidden="true"{% endif %}>
<span
class="ons-list__prefix {{ 'ons-list__prefix--icon-check' if params.variants == 'summary' and params.iconType == 'check' }}"
{% if listEl != 'ol' %}aria-hidden="true"{% endif %}
>
{%- if item.prefix -%}
{{- item.prefix -}}.
{% elif params.iconPosition == 'before' %}
Expand Down Expand Up @@ -87,7 +89,10 @@
{{- itemText | safe -}}
{%- endif -%}
{%- if item.suffix or (params.iconPosition == 'after') -%}
<span class="ons-list__suffix" {% if listEl != 'ol' %}aria-hidden="true"{% endif %}>
<span
class="ons-list__suffix {{ 'ons-list__suffix--icon-check' if params.variants == 'summary' and params.iconType == 'check' }}"
{% if listEl != 'ol' %}aria-hidden="true"{% endif %}
>
{%- if item.suffix -%}
{{- item.suffix -}}
{%- elif (item.index and listEl != 'ol') or (item.index and listEl == 'ol' and 'bare' in variants) -%}
Expand Down
26 changes: 26 additions & 0 deletions src/components/list/_macro.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,32 @@ describe('macro: list', () => {
expect($('.ons-list').hasClass('ons-list--icons')).toBe(true);
});

it('has the correct icon class when variants is `summary`, `iconType` is `check` and `iconPosition` is before', () => {
const $ = cheerio.load(
renderComponent('list', {
...EXAMPLE_LIST_TEXT_ITEMS,
iconPosition: 'before',
iconType: 'check',
variants: 'summary',
}),
);

expect($('.ons-list__prefix').hasClass('ons-list__prefix--icon-check')).toBe(true);
});

it('has the correct icon class when variants is `summary`, `iconType` is `check` and `iconPosition` is `after`', () => {
const $ = cheerio.load(
renderComponent('list', {
...EXAMPLE_LIST_TEXT_ITEMS,
iconPosition: 'after',
iconType: 'check',
variants: 'summary',
}),
);

expect($('.ons-list__suffix').hasClass('ons-list__suffix--icon-check')).toBe(true);
});

it('renders a <ul> element by default', () => {
const $ = cheerio.load(renderComponent('list', EXAMPLE_LIST_TEXT_ITEMS));

Expand Down

0 comments on commit 650f48a

Please sign in to comment.