-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathbutton.html.twig
More file actions
77 lines (72 loc) · 3.86 KB
/
Copy pathbutton.html.twig
File metadata and controls
77 lines (72 loc) · 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
{% macro button(icon, values, type) %}
{% import '@Tabler/includes/utils.html.twig' as macros %}
{%- if type is same as (false) -%}
{# when using in dropdown actions for example, which might not have a "btn" class #}
{%- set class = "" %}
{%- elseif type is null -%}
{%- set class = "btn " -%}
{%- else -%}
{%- set class = "btn btn-" ~ type ~ " " -%}
{%- endif -%}
{%- set icon = values.icon ?? icon -%}
{%- set disabled = values.disabled ?? false -%}
{%- if values.url is defined -%}
{%- set href = values.url -%}
{%- else -%}
{% set href = values.href ?? '#' %}
{%- endif -%}
{%- set onclick = values.onclick ?? null -%}
{%- set collapse = values.collapse ?? null -%}
{%- set modal = values.modal ?? null -%}
{%- set toggle = values.toggle ?? null -%}
{%- set target = values.target ?? null -%}
{%- set id = values.id ?? null -%}
{%- set title = values.title ?? null -%}
{%- set class = class ~ ( values.class | default("")) -%}
{%- set attr = values.attr ?? {} -%}
{%- set forceTitle = icon is same as (false) or (values.combined ?? false) -%}
{%- set badge = values.badge ?? (values.label ?? null) -%}
{%- set badge_color = values.badgeColor ?? (values.labelColor ?? 'yellow') -%}
{%- set translation_domain = values.translation_domain ?? 'messages' -%}
{%- set translation_params = values.translation_params ?? {} -%}
{%- set isSubmit = values.buttonType is defined and values.buttonType == 'submit' -%}
{%- set buttonType = values.buttonType is defined and (values.buttonType == 'button' or values.buttonType == 'submit') ? 'button' : 'a' -%}
{%- set tooltip = values.tooltip ?? true -%}
{%- set accesskey = values.accesskey is defined ? values.accesskey : null -%}
{%- if type != 'link' and icon is not same as (false) and (not forceTitle and badge is null) and (type is not same as (false)) %}
{%- set class = class ~ ' btn-icon' -%}
{%- endif -%}
{%- if disabled is same as (true) %}
{%- set class = class ~ " disabled" -%}
{%- endif -%}
<{{ buttonType|raw }} class="{{ class | trim }}"
{%- if buttonType is same as ("a") -%}
{%- if disabled is same as (true) %}
aria-disabled="true"
{%- else %}
href="{{ href }}"
{% endif -%}
{%- else -%}
{%- if disabled is same as (true) %} disabled="disabled"{% endif -%}
{%- endif -%}
{%- if id is not empty %} id="{{ id }}"{% endif -%}
{%- if toggle is not empty %} data-bs-toggle="{{ toggle }}"{% endif -%}
{%- if modal is not empty %} data-bs-toggle="modal" data-bs-target="{{ modal }}"{% endif -%}
{%- if collapse is not empty %} data-bs-toggle="collapse" data-bs-target="{{ collapse }}"{% endif -%}
{%- if onclick is not empty %} onclick="{{ onclick }}"{% endif -%}
{%- if target is not empty %} {% if isSubmit %}formtarget{% else %}target{% endif -%}="{{ target }}"{% endif -%}
{%- if tooltip and not forceTitle and title is not null and type is not same as (false) %} {{ values.tooltip_attr ?? 'data-bs-toggle' }}="tooltip" data-bs-placement="top" title="{{ title|trans(translation_params, translation_domain) }}"{% endif -%}
{%- if accesskey is not empty %} accesskey="{{ accesskey }}"{% endif -%}
{{- macros.attr_to_html(attr) -}}
>
{%- if icon is not same as (false) -%}
{{ tabler_icon(icon, ("btn-sm" not in class and "btn-lg" not in class), icon) }}
{%- endif -%}
{%- if (forceTitle or icon is same as (false)) and title is not null -%}
{{ title|trans(translation_params, translation_domain) }}
{%- endif -%}
{%- if badge is not null -%}
<span class="badge bg-{{ badge_color }} text-{{ badge_color }}-fg {% if forceTitle and title is not null %}ms-1{% endif %}">{{ badge }}</span>
{%- endif -%}
</{{ buttonType|raw }}>
{% endmacro %}