Skip to content

Commit

Permalink
Remove redundant code
Browse files Browse the repository at this point in the history
  • Loading branch information
adi-unni committed Oct 6, 2023
1 parent 62639ad commit 02cc4ed
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 25 deletions.
8 changes: 4 additions & 4 deletions src/components/card/_card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
flex-direction: column;
margin-bottom: 1rem;
width: fit-content;
}

&__remove--margin {
margin-bottom: 0;
}
& > .ons-card__title {
margin-bottom: 0;
}
}

&__image--reorder {
order: 1;
Expand Down
29 changes: 8 additions & 21 deletions src/components/card/_macro.njk
Original file line number Diff line number Diff line change
Expand Up @@ -6,36 +6,23 @@

<div class="ons-card">

{%- if params.image -%}
{%- if params.url -%}
<a href="{{ params.url }}" class="ons-card__link">
{%- endif -%}
<h{{ titleSize }} class="ons-card__title ons-card__title--reorder {{ params.titleClasses | default('ons-u-fs-m')}} ons-card__remove--margin" id="{{ params.id }}">
<h{{ titleSize }} class="ons-card__title ons-card__title--reorder {{ params.titleClasses | default('ons-u-fs-m')}}" id="{{ params.id }}">
{{ params.title }}
</h{{ titleSize }}>
{% if params.image.smallSrc %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
{% elif params.image == true or params.image.placeholderURL %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
{% endif %}
{%- if params.image -%}
{% if params.image.smallSrc %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="200" width="303"{% if params.image.largeSrc %} srcset="{{ params.image.smallSrc }} 1x, {{ params.image.largeSrc }} 2x"{% endif %} src="{{ params.image.smallSrc }}" alt="{{ params.image.alt }}" loading="lazy">
{% elif params.image == true or params.image.placeholderURL %}
<img class="ons-card__image ons-u-mb-s ons-card__image--reorder" height="100" width="303" srcset="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png 1x, {{ params.image.placeholderURL if params.image.placeholderURL }}/img/large/placeholder-card.png 2x" src="{{ params.image.placeholderURL if params.image.placeholderURL }}/img/small/placeholder-card.png" alt="" loading="lazy">
{% endif %}
{%- endif -%}
{%- if params.url -%}
</a>
{%- endif -%}

{%- else -%}

{%- if params.url -%}
<a class="ons-card__link" href="{{ params.url }}">
{%- endif -%}
<h{{ titleSize }} class="ons-card__title ons-card__title--reorder {{ params.titleClasses | default('ons-u-fs-m')}} ons-card__remove--margin" id="{{ params.id }}">
{{ params.title }}
</h{{ titleSize }}>
{%- if params.url -%}
</a>
{%- endif -%}

{%- endif -%}

<p id="{{ params.textId }}">{{ params.text }}</p>

{% if params.itemsList -%}
Expand Down

0 comments on commit 02cc4ed

Please sign in to comment.