basecoat-css 1.0.0-beta.6 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +82 -35
  3. package/dist/base/base.css +3 -45
  4. package/dist/basecoat-base.cdn.css +226 -22
  5. package/dist/basecoat-base.cdn.min.css +1 -1
  6. package/dist/basecoat-compat.cdn.css +16 -20
  7. package/dist/basecoat-compat.cdn.min.css +1 -1
  8. package/dist/basecoat-components.css +2 -0
  9. package/dist/basecoat-luma.cdn.css +375 -91
  10. package/dist/basecoat-luma.cdn.min.css +1 -1
  11. package/dist/basecoat-lyra.cdn.css +358 -96
  12. package/dist/basecoat-lyra.cdn.min.css +1 -1
  13. package/dist/basecoat-maia.cdn.css +364 -84
  14. package/dist/basecoat-maia.cdn.min.css +1 -1
  15. package/dist/basecoat-mira.cdn.css +366 -94
  16. package/dist/basecoat-mira.cdn.min.css +1 -1
  17. package/dist/basecoat-nova.cdn.css +369 -96
  18. package/dist/basecoat-nova.cdn.min.css +1 -1
  19. package/dist/basecoat-rhea.cdn.css +376 -91
  20. package/dist/basecoat-rhea.cdn.min.css +1 -1
  21. package/dist/basecoat-sera.cdn.css +342 -71
  22. package/dist/basecoat-sera.cdn.min.css +1 -1
  23. package/dist/basecoat-vega.cdn.css +366 -92
  24. package/dist/basecoat-vega.cdn.min.css +1 -1
  25. package/dist/basecoat.cdn.css +366 -92
  26. package/dist/basecoat.cdn.min.css +1 -1
  27. package/dist/compat/legacy.css +19 -1
  28. package/dist/components/drawer.css +89 -0
  29. package/dist/components/input-group.css +1 -1
  30. package/dist/components/scrollbar.css +46 -0
  31. package/dist/components/select.css +16 -16
  32. package/dist/js/all.js +85 -0
  33. package/dist/js/all.min.js +1 -1
  34. package/dist/js/drawer.js +84 -0
  35. package/dist/js/drawer.min.js +1 -0
  36. package/dist/styles/luma.css +47 -14
  37. package/dist/styles/lyra.css +64 -14
  38. package/dist/styles/maia.css +47 -14
  39. package/dist/styles/mira.css +48 -15
  40. package/dist/styles/nova.css +64 -14
  41. package/dist/styles/rhea.css +47 -14
  42. package/dist/styles/sera.css +66 -16
  43. package/dist/styles/vega.css +64 -14
  44. package/package.json +28 -6
  45. package/templates/jinja/combobox.html.jinja +147 -0
  46. package/templates/jinja/command.html.jinja +210 -0
  47. package/templates/jinja/dialog.html.jinja +97 -0
  48. package/templates/jinja/dropdown-menu.html.jinja +130 -0
  49. package/templates/jinja/popover.html.jinja +51 -0
  50. package/templates/jinja/select.html.jinja +191 -0
  51. package/templates/jinja/sidebar.html.jinja +149 -0
  52. package/templates/jinja/tabs.html.jinja +82 -0
  53. package/templates/jinja/toast.html.jinja +139 -0
  54. package/templates/nunjucks/combobox.njk +157 -0
  55. package/templates/nunjucks/command.njk +203 -0
  56. package/templates/nunjucks/dialog.njk +92 -0
  57. package/templates/nunjucks/dropdown-menu.njk +125 -0
  58. package/templates/nunjucks/popover.njk +48 -0
  59. package/templates/nunjucks/select.njk +184 -0
  60. package/templates/nunjucks/sidebar.njk +144 -0
  61. package/templates/nunjucks/tabs.njk +39 -0
  62. package/templates/nunjucks/toast.njk +137 -0
@@ -0,0 +1,184 @@
1
+ {#
2
+ Renders a select component.
3
+
4
+ @param id {string} [optional] - Unique identifier for the select component.
5
+ @param selected {string|array} [optional] - The initially selected value(s).
6
+ @param name {string} [optional] - The name attribute for the hidden input storing the selected value.
7
+ @param multiple {boolean} [optional] [default=false] - Enables multiple selection mode.
8
+ @param placeholder {string} [optional] - Placeholder text shown when no option is selected.
9
+ @param close_on_select {boolean} [optional] [default=false] - Closes the popover when selecting an option in multiple mode.
10
+ @param format {string} [optional] [default="value"] - Hidden input serialization format: "value" or "object".
11
+ @param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
12
+ @param trigger_attrs {object} [optional] - Additional HTML attributes for the trigger button.
13
+ @param popover_attrs {object} [optional] - Additional HTML attributes for the popover content div.
14
+ @param listbox_attrs {object} [optional] - Additional HTML attributes for the listbox div.
15
+ @param input_attrs {object} [optional] - Additional HTML attributes for the hidden input.
16
+ #}
17
+ {% macro select(
18
+ id=None,
19
+ selected=None,
20
+ name=None,
21
+ items=None,
22
+ multiple=false,
23
+ placeholder=None,
24
+ close_on_select=false,
25
+ format="value",
26
+ main_attrs={},
27
+ trigger_attrs={},
28
+ popover_attrs={},
29
+ listbox_attrs={},
30
+ input_attrs={}
31
+ ) %}
32
+ {% set id = id or ("select-" + (range(100000, 999999) | random | string)) %}
33
+
34
+ {% if selected is defined and selected is not none and selected is iterable and selected is not string %}
35
+ {% set selectedArray = selected %}
36
+ {% elif selected is defined and selected is not none %}
37
+ {% set selectedArray = [selected] %}
38
+ {% else %}
39
+ {% set selectedArray = [] %}
40
+ {% endif %}
41
+ {% set first_option = [] %}
42
+ {% set selected_options = [] %}
43
+
44
+ {% if items %}
45
+ {% for item in items %}
46
+ {% if item.type == "group" %}
47
+ {% for sub_item in item.items %}
48
+ {% if not first_option[0] %}
49
+ {% set first_option = (first_option.push(sub_item), first_option) %}
50
+ {% endif %}
51
+ {% if sub_item.value in selectedArray %}
52
+ {% set selected_options = (selected_options.push(sub_item), selected_options) %}
53
+ {% endif %}
54
+ {% endfor %}
55
+ {% else %}
56
+ {% if not first_option[0] %}
57
+ {% set first_option = (first_option.push(item), first_option) %}
58
+ {% endif %}
59
+ {% if item.value in selectedArray %}
60
+ {% set selected_options = (selected_options.push(item), selected_options) %}
61
+ {% endif %}
62
+ {% endif %}
63
+ {% endfor %}
64
+ {% endif %}
65
+
66
+ {% set default_option = (selected_options[0] if selected_options[0] else (None if placeholder else (first_option[0] if first_option[0] else None))) %}
67
+ {% set labels = [] %}
68
+ {% if multiple and selected_options %}
69
+ {% for opt in selected_options %}
70
+ {% set labels = (labels.push(opt.label), labels) %}
71
+ {% endfor %}
72
+ {% endif %}
73
+ {% set default_label = (labels | join(', ') if (multiple and selected_options) else ((placeholder or '') if (placeholder and not selected_options) else (default_option.label if default_option else ''))) %}
74
+ {% set selected_payload = [] %}
75
+ {% if multiple and selected_options %}
76
+ {% for opt in selected_options %}
77
+ {% set selected_payload = (selected_payload.push({ value: opt.value, label: opt.label }), selected_payload) %}
78
+ {% endfor %}
79
+ {% elif default_option %}
80
+ {% set selected_payload = [{ value: default_option.value, label: default_option.label }] %}
81
+ {% endif %}
82
+
83
+ <div
84
+ id="{{ id }}"
85
+ class="select {{ main_attrs.class }}"
86
+ {% if format == "object" %}data-format="object"{% endif %}
87
+ {% if placeholder %}data-placeholder="{{ placeholder }}"{% endif %}
88
+ {% if multiple and close_on_select %}data-close-on-select="true"{% endif %}
89
+ {% for key, value in main_attrs %}
90
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
91
+ {% endfor %}
92
+ >
93
+ <button
94
+ type="button"
95
+ class="{{ trigger_attrs.class }}"
96
+ id="{{ id }}-trigger"
97
+ aria-haspopup="listbox"
98
+ aria-expanded="false"
99
+ aria-controls="{{ id }}-listbox"
100
+ {% for key, value in trigger_attrs %}
101
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
102
+ {% endfor %}
103
+ >
104
+ <span class="truncate">{{ default_label }}</span>
105
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-chevron-down-icon lucide-chevron-down text-muted-foreground opacity-50 shrink-0"><path d="m6 9 6 6 6-6"/></svg>
106
+ </button>
107
+ <div
108
+ id="{{ id }}-popover"
109
+ data-popover
110
+ aria-hidden="true"
111
+ {% for key, value in popover_attrs %}
112
+ {{ key }}="{{ value }}"
113
+ {% endfor %}
114
+ >
115
+ <div
116
+ role="listbox"
117
+ id="{{ id }}-listbox"
118
+ aria-orientation="vertical"
119
+ aria-labelledby="{{ id }}-trigger"
120
+ {% if multiple %}aria-multiselectable="true"{% endif %}
121
+ {% for key, value in listbox_attrs %}
122
+ {{ key }}="{{ value }}"
123
+ {% endfor %}
124
+ >
125
+ {% if items and items.length > 0 %}
126
+ {{ render_select_items(items, selectedArray, id ~ "-items" if id else "items") }}
127
+ {% else %}
128
+ {{ caller() if caller }}
129
+ {% endif %}
130
+ </div>
131
+ </div>
132
+ <input
133
+ type="hidden"
134
+ name="{{ name or id ~ '-value' }}"
135
+ value="{% if format == 'object' %}{{ (selected_payload if multiple else (selected_payload[0] if selected_payload[0] else None)) | dump }}{% elif multiple %}{{ selectedArray | dump }}{% else %}{{ (default_option.value if default_option) or '' }}{% endif %}"
136
+ {% for key, value in input_attrs %}
137
+ {% if key != 'name' and key != 'value' %}{{ key }}="{{ value }}"{% endif %}
138
+ {% endfor %}
139
+ >
140
+ </div>
141
+ {% endmacro %}
142
+
143
+ {#
144
+ Renders a list of items for the select component.
145
+
146
+ @param items {array} - The array of items to render.
147
+ @param parent_id_prefix {string} [optional] - The prefix for the item id.
148
+ #}
149
+ {% macro render_select_items(items, selectedArray, parent_id_prefix="items") %}
150
+ {% for item in items %}
151
+ {% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
152
+ {% if item.type == "group" %}
153
+ {% set group_label_id = item.id if item.id else "group-label-" + item_id %}
154
+ <div
155
+ role="group"
156
+ aria-labelledby="{{ group_label_id }}"
157
+ {% if item.attrs %}
158
+ {% for key, value in item.attrs %}
159
+ {{ key }}="{{ value }}"
160
+ {% endfor %}
161
+ {% endif %}
162
+ >
163
+ <div role="heading" id="{{ group_label_id }}">{{ item.label }}</div>
164
+ {{ render_select_items(item.items, selectedArray, item_id) if item.items }}
165
+ </div>
166
+ {% elif item.type == "separator" %}
167
+ <hr role="separator" />
168
+ {% elif item.type == "item" or not item.type %}
169
+ <div
170
+ id="{{ item_id }}"
171
+ role="option"
172
+ {% if item.value is defined and item.value is not none %}data-value="{{ item.value }}"{% endif %}
173
+ {% if item.value in selectedArray %}aria-selected="true"{% endif %}
174
+ {% if item.attrs %}
175
+ {% for key, value in item.attrs %}
176
+ {{ key }}="{{ value }}"
177
+ {% endfor %}
178
+ {% endif %}
179
+ >
180
+ {{ item.label | safe }}
181
+ </div>
182
+ {% endif %}
183
+ {% endfor %}
184
+ {% endmacro %}
@@ -0,0 +1,144 @@
1
+ {#
2
+ Renders a sidebar component.
3
+
4
+ @param id {string} [optional] - Unique identifier for the sidebar component.
5
+ @param label {string} [optional] - Label for the sidebar navigation.
6
+ @param open {boolean} [optional] - Whether the sidebar is open.
7
+ @param side {string} [optional] - Side of the sidebar to display.
8
+ @param header {string} [optional] - Header content for the sidebar.
9
+ @param footer {string} [optional] - Footer content for the sidebar.
10
+ @param menu {array} [optional] - Array of menu items for the sidebar.
11
+ @param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
12
+ @param header_attrs {object} [optional] - Additional HTML attributes for the header element.
13
+ @param content_attrs {object} [optional] - Additional HTML attributes for the content section.
14
+ @param footer_attrs {object} [optional] - Additional HTML attributes for the footer element.
15
+ #}
16
+ {% macro sidebar(
17
+ id=None,
18
+ label="Sidebar navigation",
19
+ open=true,
20
+ side=None,
21
+ header=None,
22
+ footer=None,
23
+ menu=None,
24
+ main_attrs={},
25
+ header_attrs={},
26
+ content_attrs={},
27
+ footer_attrs={}
28
+ ) %}
29
+ <aside
30
+ {% if id %}id="{{ id }}"{% endif %}
31
+ class="sidebar {{ main_attrs.class }}"
32
+ data-side="{{ side if side else "left" }}"
33
+ aria-hidden="{{ "true" if not open else "false" }}"
34
+ {{ "inert" if not open }}
35
+ {% for key, value in main_attrs %}
36
+ {% if key != "class" %}{{ key }}="{{ value }}"{% endif %}
37
+ {% endfor %}
38
+ >
39
+ <nav
40
+ aria-label="{{ label }}"
41
+ >
42
+ {% if header %}
43
+ <header
44
+ {% for key, value in header_attrs %}
45
+ {{ key }}="{{ value }}"
46
+ {% endfor %}
47
+ >
48
+ {{ header | safe }}
49
+ </header>
50
+ {% endif %}
51
+
52
+ <section
53
+ {% for key, value in content_attrs %}
54
+ {{ key }}="{{ value }}"
55
+ {% endfor %}
56
+ >
57
+ {% if menu %}
58
+ {{ render_sidebar_content(menu, id ~ "-content" if id else "content") }}
59
+ {% else %}
60
+ {{ caller() if caller }}
61
+ {% endif %}
62
+ </section>
63
+
64
+ {% if footer %}
65
+ <footer
66
+ {% for key, value in footer_attrs %}
67
+ {{ key }}="{{ value }}"
68
+ {% endfor %}
69
+ >
70
+ {{ footer | safe }}
71
+ </footer>
72
+ {% endif %}
73
+ </nav>
74
+ </aside>
75
+ {% endmacro %}
76
+
77
+ {#
78
+ Renders sidebar content recursively (groups, items, submenus, separators).
79
+
80
+ @param items {array} - The array of items to render.
81
+ @param parent_id_prefix {string} [optional] - Prefix for generating element IDs.
82
+ #}
83
+ {% macro render_sidebar_content(items, parent_id_prefix="content") %}
84
+ {% for item in items %}
85
+ {% set item_id = parent_id_prefix ~ "-" ~ loop.index %}
86
+
87
+ {% if item.type == "group" %}
88
+ {% set group_label_id = item.id if item.id else "group-label-" + item_id %}
89
+ <div
90
+ role="group"
91
+ {% if item.label %}aria-labelledby="{{ group_label_id }}"{% endif %}
92
+ {% if item.attrs %}
93
+ {% for key, value in item.attrs %}
94
+ {{ key }}="{{ value }}"
95
+ {% endfor %}
96
+ {% endif %}
97
+ >
98
+ {% if item.label %}
99
+ <h3 id="{{ group_label_id }}">{{ item.label }}</h3>
100
+ {% endif %}
101
+ <ul>
102
+ {{ render_sidebar_content(item.items, item_id) if item.items }}
103
+ </ul>
104
+ </div>
105
+ {% elif item.type == "separator" %}
106
+ <hr role="separator"/>
107
+ {% elif item.type == "submenu" %}
108
+ <li>
109
+ <details
110
+ id="submenu-{{ item_id }}"
111
+ {{ "open" if item.open }}
112
+ {% if item.attrs %}
113
+ {% for key, value in item.attrs %}
114
+ {% if key != "open" %}{{ key }}="{{ value }}"{% endif %}
115
+ {% endfor %}
116
+ {% endif %}
117
+ >
118
+ <summary aria-controls="submenu-{{ item_id }}-content">
119
+ {% if item.icon %}{{ item.icon | safe }}{% endif %}
120
+ <span>{{ item.label | safe }}</span>
121
+ </summary>
122
+ <ul id="submenu-{{ item_id }}-content">
123
+ {{ render_sidebar_content(item.items, item_id) if item.items }}
124
+ </ul>
125
+ </details>
126
+ </li>
127
+ {% elif item.type == "item" or not item.type %}
128
+ <li>
129
+ <a
130
+ href="{{ item.url }}"
131
+ {% if item.current %}aria-current="page"{% endif %}
132
+ {% if item.attrs %}
133
+ {% for key, value in item.attrs %}
134
+ {% if key != "href" and key != "aria-current" %}{{ key }}="{{ value }}"{% endif %}
135
+ {% endfor %}
136
+ {% endif %}
137
+ >
138
+ {% if item.icon %}{{ item.icon | safe }}{% endif %}
139
+ <span>{{ item.label | safe }}</span>
140
+ </a>
141
+ </li>
142
+ {% endif %}
143
+ {% endfor %}
144
+ {% endmacro %}
@@ -0,0 +1,39 @@
1
+ {#
2
+ Renders a tabs component.
3
+
4
+ @param id {string} - Unique identifier for the tabs component.
5
+ @param tabsets {array} - An array of objects, each representing a tab and panel.
6
+ Each object should have:
7
+ - tab {string}: HTML content for the tab button.
8
+ - panel {string} [optional]: HTML content for the tab panel.
9
+ - tab_attrs {object} [optional]: Additional HTML attributes for the tab button.
10
+ - panel_attrs {object} [optional]: Additional HTML attributes for the tab panel div.
11
+ @param main_attrs {object} [optional] - Additional HTML attributes for the main container div.
12
+ @param tablist_attrs {object} [optional] - Additional HTML attributes for the tablist nav element.
13
+ Set aria-orientation="vertical" for vertical tabs or data-variant="line" for line tabs.
14
+ @param default_tab_index {number} [optional] [default=1] - The 1-based index of the tab to be active initially.
15
+ #}
16
+ {%- macro tabs(
17
+ id=None,
18
+ tabsets=[],
19
+ main_attrs={},
20
+ tablist_attrs={},
21
+ default_tab_index=1
22
+ )
23
+ -%}
24
+ {%- set id = id or ("tabs-" + (range(100000, 999999) | random | string)) -%}
25
+ {%- set orientation = tablist_attrs['aria-orientation'] or 'horizontal' -%}
26
+ <div class="tabs {{ main_attrs.class }}" id="{{ id }}"{% for key, value in main_attrs %}{% if key != 'class' %} {{ key }}="{{ value }}"{% endif %}{% endfor %}>
27
+ <nav role="tablist" aria-orientation="{{ orientation }}"{% for key, value in tablist_attrs %}{% if key != 'aria-orientation' %} {{ key }}="{{ value }}"{% endif %}{% endfor %}>
28
+ {% for tabset in tabsets %}
29
+ {%- set tab_attrs = tabset.tab_attrs or {} -%}
30
+ <button type="button" role="tab" id="{{ id }}-tab-{{ loop.index }}" aria-controls="{{ id }}-panel-{{ loop.index }}" aria-selected="{{ 'true' if loop.index == default_tab_index else 'false' }}" tabindex="{{ '0' if loop.index == default_tab_index and not tab_attrs.disabled and tab_attrs['aria-disabled'] != 'true' else '-1' }}"{% if tab_attrs %}{% for key, value in tab_attrs %} {{ key }}="{{ value }}"{% endfor %}{% endif %}>{{ tabset.tab | safe }}</button>
31
+ {% endfor %}
32
+ </nav>
33
+ {% for tabset in tabsets %}
34
+ {% if tabset.panel %}
35
+ <div role="tabpanel" id="{{ id }}-panel-{{ loop.index }}" aria-labelledby="{{ id }}-tab-{{ loop.index }}" tabindex="-1" aria-selected="{{ 'true' if loop.index == default_tab_index else 'false' }}"{% if loop.index != default_tab_index %} hidden{% endif %}{% if tabset.panel_attrs %}{% for key, value in tabset.panel_attrs %} {{ key }}="{{ value }}"{% endfor %}{% endif %}>{{ tabset.panel | safe }}</div>
36
+ {% endif %}
37
+ {% endfor %}
38
+ </div>
39
+ {%- endmacro -%}
@@ -0,0 +1,137 @@
1
+ {#
2
+ Renders a toaster container and individual toast messages.
3
+ Can render the initial container or be used with htmx OOB swaps to add toasts dynamically.
4
+
5
+ @param id {string} [optional] [default="toaster"] - Unique identifier for the toaster container.
6
+ @param toasts {array} [optional] - An array of toast objects to render initially. See the <code>toast()</code> macro for more details.
7
+ @param attrs {object} [optional] - Additional HTML attributes for the main toaster container div.
8
+
9
+ Supports caller() for custom toast markup.
10
+ #}
11
+ {% macro toaster(
12
+ id="toaster",
13
+ toasts=[],
14
+ attrs={}
15
+ ) %}
16
+ <div
17
+ id="{{ id }}"
18
+ class="toaster {{ attrs.class }}"
19
+ {% for key, value in attrs %}
20
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
21
+ {% endfor %}
22
+ >
23
+ {% for item in toasts %}
24
+ {{ toast(
25
+ category=item.category,
26
+ title=item.title,
27
+ description=item.description,
28
+ action=item.action,
29
+ cancel=item.cancel,
30
+ duration=item.duration,
31
+ icon=item.icon,
32
+ attrs=item.attrs or {}
33
+ ) }}
34
+ {% endfor %}
35
+ {{ caller() if caller }}
36
+ </div>
37
+ {% endmacro %}
38
+
39
+ {#
40
+ Renders a single toast message.
41
+
42
+ @param category {string} [optional] [default="success"] - Type of toast ('success', 'error', 'info', 'warning'). Determines icon and ARIA role.
43
+ @param title {string} [optional] - The main title text of the toast.
44
+ @param description {string} [optional] - The secondary description text.
45
+ @param duration {number} [optional] - Timeout in milliseconds. Use -1 to keep the toast open.
46
+ @param icon {string} [optional] - Custom icon HTML. Defaults to the category icon.
47
+ @param action {object} [optional] - Defines an action button.
48
+ - label {string}: Button text.
49
+ - onclick {string}: JavaScript code to execute on click.
50
+ - href {string}: URL for an anchor link button.
51
+ @param cancel {object} [optional] - Defines a cancel/dismiss button (similar structure to action).
52
+ - label {string}: Button text.
53
+ - onclick {string}: JavaScript code to execute on click.
54
+ - href {string}: URL for an anchor link button.
55
+ @param attrs {object} [optional] - Additional HTML attributes for the toast div.
56
+ #}
57
+ {% macro toast(
58
+ category="success",
59
+ title="",
60
+ description="",
61
+ action=None,
62
+ cancel=None,
63
+ duration=None,
64
+ icon=None,
65
+ attrs={}
66
+ ) %}
67
+ {% set action_href = action.href if action and action.href else (action.url if action and action.url else None) %}
68
+ {% set cancel_href = cancel.href if cancel and cancel.href else (cancel.url if cancel and cancel.url else None) %}
69
+ <div
70
+ class="toast {{ attrs.class }}"
71
+ role="{{ 'alert' if category == 'error' else 'status' }}"
72
+ aria-atomic="true"
73
+ aria-hidden="false"
74
+ {% if category %}data-category="{{ category }}"{% endif %}
75
+ {% if duration is not none %}data-duration="{{ duration }}"{% endif %}
76
+ {% for key, value in attrs %}
77
+ {% if key != 'class' %}{{ key }}="{{ value }}"{% endif %}
78
+ {% endfor %}
79
+ >
80
+ <div class="toast-content">
81
+ {% if icon %}
82
+ {{ icon | safe }}
83
+ {% elif category in ["error", "success", "info", "warning"] %}
84
+ {% if category == "success" %}
85
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m9 12 2 2 4-4"/></svg>
86
+ {% elif category == "error" %}
87
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="m15 9-6 6"/><path d="m9 9 6 6"/></svg>
88
+ {% elif category == "info" %}
89
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
90
+ {% elif category == "warning" %}
91
+ <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>
92
+ {% endif %}
93
+ {% endif %}
94
+ <section>
95
+ {% if title %}<h2>{{ title }}</h2>{% endif %}
96
+ {% if description %}<p>{{ description }}</p>{% endif %}
97
+ </section>
98
+ {% if action or cancel %}
99
+ <footer>
100
+ {% if action %}
101
+ {% if action_href %}
102
+ <a
103
+ href="{{ action_href }}"
104
+ class="btn" data-size="sm"
105
+ data-toast-action
106
+ >{{ action.label }}</a>
107
+ {% else %}
108
+ <button
109
+ type="button"
110
+ class="btn"
111
+ data-size="sm"
112
+ data-toast-action
113
+ {% if action.onclick %}onclick="{{ action.onclick }}"{% endif %}
114
+ >{{ action.label }}</button>
115
+ {% endif %}
116
+ {% endif %}
117
+ {% if cancel %}
118
+ {% if cancel_href %}
119
+ <a
120
+ href="{{ cancel_href }}"
121
+ class="btn" data-variant="outline" data-size="sm"
122
+ data-toast-cancel
123
+ >{{ cancel.label }}</a>
124
+ {% else %}
125
+ <button
126
+ type="button"
127
+ class="btn" data-variant="outline" data-size="sm"
128
+ data-toast-cancel
129
+ {% if cancel.onclick %}onclick="{{ cancel.onclick }}"{% endif %}
130
+ >{{ cancel.label }}</button>
131
+ {% endif %}
132
+ {% endif %}
133
+ </footer>
134
+ {% endif %}
135
+ </div>
136
+ </div>
137
+ {% endmacro %}