basecoat-css 1.0.0-beta.7 → 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.
- package/LICENSE.md +21 -0
- package/README.md +82 -35
- package/dist/base/base.css +3 -45
- package/dist/basecoat-base.cdn.css +61 -22
- package/dist/basecoat-base.cdn.min.css +1 -1
- package/dist/basecoat-compat.cdn.css +16 -20
- package/dist/basecoat-compat.cdn.min.css +1 -1
- package/dist/basecoat-components.css +1 -0
- package/dist/basecoat-luma.cdn.css +130 -92
- package/dist/basecoat-luma.cdn.min.css +1 -1
- package/dist/basecoat-lyra.cdn.css +135 -96
- package/dist/basecoat-lyra.cdn.min.css +1 -1
- package/dist/basecoat-maia.cdn.css +123 -85
- package/dist/basecoat-maia.cdn.min.css +1 -1
- package/dist/basecoat-mira.cdn.css +133 -95
- package/dist/basecoat-mira.cdn.min.css +1 -1
- package/dist/basecoat-nova.cdn.css +135 -96
- package/dist/basecoat-nova.cdn.min.css +1 -1
- package/dist/basecoat-rhea.cdn.css +130 -92
- package/dist/basecoat-rhea.cdn.min.css +1 -1
- package/dist/basecoat-sera.cdn.css +110 -71
- package/dist/basecoat-sera.cdn.min.css +1 -1
- package/dist/basecoat-vega.cdn.css +131 -92
- package/dist/basecoat-vega.cdn.min.css +1 -1
- package/dist/basecoat.cdn.css +131 -92
- package/dist/basecoat.cdn.min.css +1 -1
- package/dist/compat/legacy.css +19 -1
- package/dist/components/input-group.css +1 -1
- package/dist/components/scrollbar.css +46 -0
- package/dist/components/select.css +16 -16
- package/dist/styles/luma.css +15 -15
- package/dist/styles/lyra.css +14 -14
- package/dist/styles/maia.css +15 -15
- package/dist/styles/mira.css +16 -16
- package/dist/styles/nova.css +14 -14
- package/dist/styles/rhea.css +15 -15
- package/dist/styles/sera.css +16 -16
- package/dist/styles/vega.css +14 -14
- package/package.json +26 -6
- package/templates/jinja/combobox.html.jinja +147 -0
- package/templates/jinja/command.html.jinja +210 -0
- package/templates/jinja/dialog.html.jinja +97 -0
- package/templates/jinja/dropdown-menu.html.jinja +130 -0
- package/templates/jinja/popover.html.jinja +51 -0
- package/templates/jinja/select.html.jinja +191 -0
- package/templates/jinja/sidebar.html.jinja +149 -0
- package/templates/jinja/tabs.html.jinja +82 -0
- package/templates/jinja/toast.html.jinja +139 -0
- package/templates/nunjucks/combobox.njk +157 -0
- package/templates/nunjucks/command.njk +203 -0
- package/templates/nunjucks/dialog.njk +92 -0
- package/templates/nunjucks/dropdown-menu.njk +125 -0
- package/templates/nunjucks/popover.njk +48 -0
- package/templates/nunjucks/select.njk +184 -0
- package/templates/nunjucks/sidebar.njk +144 -0
- package/templates/nunjucks/tabs.njk +39 -0
- package/templates/nunjucks/toast.njk +137 -0
|
@@ -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 %}
|