@rhavenside/baseline-ui 1.0.16 → 1.0.18
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/README.md +162 -11
- package/dist/baseline.css +769 -0
- package/dist/baseline.css.map +1 -1
- package/dist/baseline.js +211 -1
- package/dist/baseline.js.map +3 -3
- package/dist/baseline.min.css +1 -1
- package/dist/baseline.min.js +1 -1
- package/dist/baseline.min.js.map +4 -4
- package/package.json +1 -1
- package/src/baseline.scss +5 -0
- package/src/components/_accordion.scss +123 -0
- package/src/components/_avatar.scss +169 -0
- package/src/components/_divider.scss +92 -0
- package/src/components/_sidebar.scss +284 -0
- package/src/components/_toast.scss +241 -0
- package/src/js/baseline.js +25 -1
- package/src/js/components/accordion.js +43 -0
- package/src/js/components/sidebar.js +101 -0
- package/src/js/components/toast.js +116 -0
- package/src/tokens/_z-index.scss +6 -0
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Toast Component JavaScript
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
// Default options
|
|
6
|
+
const defaultOptions = {
|
|
7
|
+
type: 'info',
|
|
8
|
+
position: 'top-right',
|
|
9
|
+
duration: 5000,
|
|
10
|
+
title: null,
|
|
11
|
+
closable: true
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Get or create toast container
|
|
15
|
+
function getToastContainer(position) {
|
|
16
|
+
const containerId = `bl-toast-container-${position}`;
|
|
17
|
+
let container = document.getElementById(containerId);
|
|
18
|
+
|
|
19
|
+
if (!container) {
|
|
20
|
+
container = document.createElement('div');
|
|
21
|
+
container.id = containerId;
|
|
22
|
+
container.className = `bl-toast-container bl-toast-${position}`;
|
|
23
|
+
document.body.appendChild(container);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return container;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Create toast element
|
|
30
|
+
function createToastElement(message, type, title, closable) {
|
|
31
|
+
const toast = document.createElement('div');
|
|
32
|
+
toast.className = `bl-toast bl-toast-${type}`;
|
|
33
|
+
|
|
34
|
+
const content = document.createElement('div');
|
|
35
|
+
content.className = 'bl-toast-content';
|
|
36
|
+
|
|
37
|
+
if (title) {
|
|
38
|
+
const titleEl = document.createElement('div');
|
|
39
|
+
titleEl.className = 'bl-toast-title';
|
|
40
|
+
titleEl.textContent = title;
|
|
41
|
+
content.appendChild(titleEl);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const messageEl = document.createElement('div');
|
|
45
|
+
messageEl.className = 'bl-toast-message';
|
|
46
|
+
messageEl.textContent = message;
|
|
47
|
+
content.appendChild(messageEl);
|
|
48
|
+
|
|
49
|
+
toast.appendChild(content);
|
|
50
|
+
|
|
51
|
+
if (closable) {
|
|
52
|
+
const closeBtn = document.createElement('button');
|
|
53
|
+
closeBtn.className = 'bl-toast-close';
|
|
54
|
+
closeBtn.setAttribute('aria-label', 'Close');
|
|
55
|
+
closeBtn.innerHTML = '×';
|
|
56
|
+
closeBtn.addEventListener('click', () => {
|
|
57
|
+
removeToast(toast);
|
|
58
|
+
});
|
|
59
|
+
toast.appendChild(closeBtn);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
return toast;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Remove toast with animation
|
|
66
|
+
function removeToast(toast) {
|
|
67
|
+
toast.classList.add('bl-toast-closing');
|
|
68
|
+
|
|
69
|
+
toast.addEventListener('animationend', () => {
|
|
70
|
+
toast.remove();
|
|
71
|
+
|
|
72
|
+
// Remove container if empty
|
|
73
|
+
const container = toast.parentElement;
|
|
74
|
+
if (container && container.classList.contains('bl-toast-container') && container.children.length === 0) {
|
|
75
|
+
container.remove();
|
|
76
|
+
}
|
|
77
|
+
}, { once: true });
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Main showToast function
|
|
81
|
+
export function showToast(message, type = 'info', options = {}) {
|
|
82
|
+
const opts = { ...defaultOptions, ...options, type };
|
|
83
|
+
const container = getToastContainer(opts.position);
|
|
84
|
+
const toast = createToastElement(message, opts.type, opts.title, opts.closable);
|
|
85
|
+
|
|
86
|
+
container.appendChild(toast);
|
|
87
|
+
|
|
88
|
+
// Auto-dismiss after duration
|
|
89
|
+
if (opts.duration > 0) {
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
if (toast.parentElement) {
|
|
92
|
+
removeToast(toast);
|
|
93
|
+
}
|
|
94
|
+
}, opts.duration);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return toast;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Convenience functions
|
|
101
|
+
export function showToastSuccess(message, options = {}) {
|
|
102
|
+
return showToast(message, 'success', { ...options, title: options.title || 'Success' });
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function showToastError(message, options = {}) {
|
|
106
|
+
return showToast(message, 'error', { ...options, title: options.title || 'Error' });
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function showToastWarning(message, options = {}) {
|
|
110
|
+
return showToast(message, 'warning', { ...options, title: options.title || 'Warning' });
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function showToastInfo(message, options = {}) {
|
|
114
|
+
return showToast(message, 'info', { ...options, title: options.title || 'Info' });
|
|
115
|
+
}
|
|
116
|
+
|
package/src/tokens/_z-index.scss
CHANGED
|
@@ -7,10 +7,13 @@ $z-index-base: 0;
|
|
|
7
7
|
$z-index-dropdown: 9999; // Immer im Vordergrund
|
|
8
8
|
$z-index-sticky: 1020;
|
|
9
9
|
$z-index-fixed: 1030;
|
|
10
|
+
$z-index-sidebar-backdrop: 1034;
|
|
11
|
+
$z-index-sidebar: 1035;
|
|
10
12
|
$z-index-modal-backdrop: 1040;
|
|
11
13
|
$z-index-modal: 1050;
|
|
12
14
|
$z-index-popover: 1060;
|
|
13
15
|
$z-index-tooltip: 1070;
|
|
16
|
+
$z-index-toast: 1080;
|
|
14
17
|
|
|
15
18
|
// Export as CSS Custom Properties
|
|
16
19
|
:root {
|
|
@@ -18,9 +21,12 @@ $z-index-tooltip: 1070;
|
|
|
18
21
|
--z-index-dropdown: #{$z-index-dropdown};
|
|
19
22
|
--z-index-sticky: #{$z-index-sticky};
|
|
20
23
|
--z-index-fixed: #{$z-index-fixed};
|
|
24
|
+
--z-index-sidebar-backdrop: #{$z-index-sidebar-backdrop};
|
|
25
|
+
--z-index-sidebar: #{$z-index-sidebar};
|
|
21
26
|
--z-index-modal-backdrop: #{$z-index-modal-backdrop};
|
|
22
27
|
--z-index-modal: #{$z-index-modal};
|
|
23
28
|
--z-index-popover: #{$z-index-popover};
|
|
24
29
|
--z-index-tooltip: #{$z-index-tooltip};
|
|
30
|
+
--z-index-toast: #{$z-index-toast};
|
|
25
31
|
}
|
|
26
32
|
|