{%- set class_name = [
"btn",
"u-posr u-cursor-pointer d-inline-flex gap-1 align-items-center justify-content-center flex-nowrap flex-shrink-0",
props.variant in ["outline", "primary", "ghost", "facebook", "twitter", "instagram", "linkedin", "youtube"] ? "--" ~ props.variant : "--primary",
props.size in ["xs", "sm"] ? "--" ~ props.size : null,
props.animation in ["right", "zoom", "left", "down"] ? "--animation-" ~ props.animation : null,
props.icon_before ? "--icon-before" : null,
props.icon_only ? "--icon-only" : null,
props.full_width_mobile ? "--full-width-mobile" : null,
props.full_width ? "--full-width w-100" : null,
props.extra_class ? props.extra_class : null
]|join(' ')|trim -%}
{%- set tag = props.tag in ['button', 'a', 'span'] ? props.tag : "a" -%}
{%- set href_value = props.url is defined ? props.url : '#' -%}
{%- set href = tag == 'a' ? "href='" ~ href_value ~ "'" : null -%}
{%- set attrs = [
'class="' ~ class_name ~ '"',
] -%}
{%- if href -%}
{%- set attrs = attrs|merge([href]) -%}
{%- endif -%}
{%- if props.id %}
{%- set attrs = attrs|merge(['id="' ~ props.id ~ '"']) -%}
{%- endif -%}
{%- if props.type and tag == "button" %}
{%- set attrs = attrs|merge(['type="' ~ props.type ~ '"']) -%}
{%- endif -%}
{%- if props.onclick is defined %}
{%- set attrs = attrs|merge(['onclick="' ~ props.onclick ~ '"']) -%}
{%- endif -%}
{%- if props.blank == true and tag == "a" %}
{%- set attrs = attrs|merge(['target="_blank"']) -%}
{%- endif -%}
{%- if tag == "button" and props.title %}
{%- set attrs = attrs|merge(['aria-label="' ~ props.title ~ '"']) -%}
{%- endif -%}
{%- if props.name and tag == "button" %}
{% set attrs = attrs|merge(['name=' ~ props.name ~ '']) %}
{%- endif -%}
{%- if props.value and tag == "button" %}
{%- set attrs = attrs|merge(['value="' ~ props.value ~ '"']) -%}
{%- endif -%}
{% if props.icon_only and tag == 'a' and props.title %}
{%- set attrs = attrs|merge(['title="' ~ props.title ~ '"']) -%}
{% endif %}
{%- if props.data is defined -%}
{%- set data_attrs = [] -%}
{%- for key, attribute in props.data -%}
{%- set data_attrs = data_attrs|merge(['data-' ~ key ~ '="' ~ attribute ~ '"']) -%}
{%- endfor -%}
{%- set data_attrs = data_attrs|join(' ')|trim -%}
{%- set attrs = attrs|merge([data_attrs]) -%}
{%- endif -%}
{%- set attrs = attrs|join(' ')|trim -%}
<{{tag}} {{ attrs|raw }}>
{% if not props.icon_only %}
<span class="btn__title">
{{ props.title }}
</span>
{% endif %}
{% if props.icon %}
<span class="btn__icon d-flex align-items-center justify-content-center">
{% include "@Components/icon/icon.twig" with {props: {
src: props.icon.src,
color: props.icon.color,
size: props.icon.size,
stroke_off: props.stroke_off
}} %}
</span>
{% endif %}
</{{tag}}>