-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathbuttons.html.twig
More file actions
108 lines (91 loc) · 3.73 KB
/
Copy pathbuttons.html.twig
File metadata and controls
108 lines (91 loc) · 3.73 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
{% macro action_cardtoolbutton(icon, attrs) -%}
{% import '@Tabler/components/button.html.twig' as macro %}
{{ macro.button(icon, attrs) }}
{%- endmacro %}
{% macro action_collapsebutton(label, target) -%}
{{ _self.action_cardtoolbutton('collapse', {collapse: target, title: label|default('')}) }}
{%- endmacro %}
{% macro link_button(label, href, icon, type, size) -%}
{% import '@Tabler/components/button.html.twig' as macro %}
{% set _href = href ?? '#' %}
{% set _icon = icon ?? false %}
{% set _type = type ?? 'primary' %}
{% set _size = size ?? null %}
{{ macro.button(_icon, {
title: label,
combined: true,
href: _href,
class: _size ? 'btn-' ~ _size : ''
}, _type) }}
{%- endmacro %}
{% macro action_button(label, action, icon, type, size) -%}
{% import '@Tabler/components/button.html.twig' as macro %}
{% set _icon = icon ?? false %}
{% set _type = type ?? 'primary' %}
{% set _size = size ?? null %}
{{ macro.button(_icon, {
title: label,
class: _size ? 'btn-' ~ _size : '',
buttonType: 'button',
attr: {'data-action': action}
}, _type) }}
{%- endmacro %}
{% macro submit_button(icon, user_values, type) -%}
{% import '@Tabler/components/button.html.twig' as macro %}
{% set default_values = {
combined : true,
attr : {type: 'submit'},
disabled : false,
buttonType : 'submit',
} %}
{% set values_attr = default_values.attr | merge(user_values.attr|default({})) %}
{% set values = default_values | merge(user_values|default({})) %}
{% set values = values | merge({'attr' : values_attr}) %}
{{ macro.button(icon, values, type) }}
{%- endmacro %}
{% macro dropdown_button(button, actions, options) -%}
{% import '@Tabler/components/button.html.twig' as macro %}
{% import '@Tabler/includes/utils.html.twig' as utils %}
{% set button_default = {
buttonType : 'button',
class: '',
combined : true,
attr : {
'data-bs-toggle' : 'dropdown'
},
} %}
{% set options = (options|default({})) | merge({icon_class: 'me-2 text-center'}) %}
{% set values_attr = button_default.attr | merge(button.attr|default({})) %}
{% set values = button_default | merge(button|default({})) %}
{% set values = values | merge({'attr' : values_attr}) %}
<div class="dropdown">
{{ macro.button(
button.icon ?? false,
(values|merge({class: values.class ~ ' dropdown-toggle'})),
button.type ?? null
) }}
{% if actions is iterable and actions|length > 0 %}
<div class="dropdown-menu">
{% for action in actions %}
{% set _title = action.title ?? null %}
{% if action.url is defined %}
{% set _href = action.url %}
{% else %}
{% set _href = action.href ?? '#' %}
{% endif %}
{% set _icon = action.icon ?? false %}
{% set _attr = action.attr ?? {} %}
{% set _class = 'dropdown-item ' ~ (action.class ?? '') %}
<a class="{{ _class }}" href="{{ _href }}" {{ utils.attr_to_html(_attr) }}>
{%- if _icon is not same as (false) -%}
<span class="{{ options.icon_class }}">{{ tabler_icon(_icon, false) }}</span>
{% endif %}
{%- if _title is not null -%}
{{ _title|raw }}
{% endif %}
</a>
{% endfor %}
</div>
{% endif %}
</div>
{%- endmacro %}