stack/src/components/link/link.twig line 1

Open in your IDE?
  1. {%- set class_name = [
  2.   "link",
  3.   "d-inline-flex align-items-center gap-1",
  4.   props.color in ['black', 'primary', 'primary-only', 'primary-to-conversion'] ? '--' ~ props.color : "",
  5.   props.icon_before == true ? '--icon-before' : null,
  6.   props.animation in ["right", "zoom"] ? "--animation-" ~ props.animation : null,
  7.   props.underline_initial ? "--underline-initial" : null,
  8.   props.extra_class|default(false) ? props.extra_class : null
  9. ]|join(' ')|trim -%}
  10. {%- set attrs = [
  11.   'class="' ~ class_name ~ '"'
  12. ] -%}
  13. {%- set attrs = attrs|merge(['href="' ~ props.url|default("#") ~ '"']) -%}
  14. {%- if props.blank %}
  15.   {%- set attrs = attrs|merge(['target="_blank"']) -%}
  16. {%- endif -%}
  17. {%- if props.title is defined %}
  18.   {%- set attrs = attrs|merge(['title="' ~ props.title ~ '"']) -%}
  19. {%- endif -%}
  20. {%- if props.onclick is defined %}
  21.   {%- set attrs = attrs|merge(['onclick="' ~ props.onclick ~ '"']) -%}
  22. {%- endif -%}
  23. {%- if props.data is defined -%}
  24.   {%- set data_attrs = [] -%}
  25.   {%- for key, attribute in props.data -%}
  26.     {%- set data_attrs = data_attrs|merge(['data-' ~ key ~ '="' ~ attribute ~ '"']) -%}
  27.   {%- endfor -%}
  28.   {%- set data_attrs = data_attrs|join(' ')|trim -%}
  29.   {%- set attrs = attrs|merge([data_attrs]) -%}
  30. {%- endif -%}
  31. {%- set attrs = attrs|join(' ')|trim -%}
  32. <a {{ attrs|raw }}>
  33.   <span class="link__title">{{ props.title }}</span>
  34.   {% if props.icon %}
  35.     <span class="link__icon d-flex align-items-center justify-content-center flex-shrink-0">
  36.       {% include "@Components/icon/icon.twig" with {props: props.icon|merge({color: props.color ?? null})} %}
  37.     </span>
  38.   {% endif %}
  39. </a>