@samline/notify 0.2.3 → 0.2.5
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 +3 -3
- package/dist/index.cjs.js +78 -0
- package/dist/index.esm.js +78 -0
- package/dist/notify.umd.js +78 -0
- package/dist/styles.css +27 -1
- package/docs/browser.md +6 -6
- package/docs/vanilla.md +2 -2
- package/package.json +1 -1
- package/samline-notify-0.1.9.tgz +0 -0
package/README.md
CHANGED
|
@@ -50,8 +50,8 @@ Use the browser build when your project loads scripts directly and cannot compil
|
|
|
50
50
|
|
|
51
51
|
|
|
52
52
|
```html
|
|
53
|
-
<script src="https://unpkg.com/@samline/notify@0.2.
|
|
54
|
-
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.
|
|
53
|
+
<script src="https://unpkg.com/@samline/notify@0.2.5/dist/notify.umd.js"></script>
|
|
54
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.5/dist/styles.css" />
|
|
55
55
|
|
|
56
56
|
<script>
|
|
57
57
|
// Always use an array of strings as the second argument
|
|
@@ -81,7 +81,7 @@ Choose the entrypoint matching your stack so you only import what you need.
|
|
|
81
81
|
| Use case | Import | Guide |
|
|
82
82
|
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |
|
|
83
83
|
| Vanilla JS | `import { notify, initToasters } from '@samline/notify/vanilla'` | [docs/vanilla.md](docs/vanilla.md) |
|
|
84
|
-
| Browser / CDN | `<script src="https://unpkg.com/@samline/notify@0.2.
|
|
84
|
+
| Browser / CDN | `<script src="https://unpkg.com/@samline/notify@0.2.5/dist/notify.umd.js"></script>`<br/>`const api = window.notify; api.initToasters(...);` | [docs/browser.md](docs/browser.md) |
|
|
85
85
|
| React | `import { Toaster, notify } from '@samline/notify/react'` | [docs/react.md](docs/react.md) |
|
|
86
86
|
| Vue | `import { Toaster, notify } from '@samline/notify/vue'` | [docs/vue.md](docs/vue.md) |
|
|
87
87
|
| Svelte | `import Toaster, { notify } from '@samline/notify/svelte'` | [docs/svelte.md](docs/svelte.md) |
|
package/dist/index.cjs.js
CHANGED
|
@@ -1018,6 +1018,15 @@ function animate(target, keyframesOrOptions, options) {
|
|
|
1018
1018
|
return factory(target, keyframesOrOptions, options);
|
|
1019
1019
|
}
|
|
1020
1020
|
|
|
1021
|
+
// SVG Gooey Filter para animaciones morphing estilo Sileo
|
|
1022
|
+
const gooeySVG = `<svg width="0" height="0" style="position:absolute">
|
|
1023
|
+
<filter id="sileo-gooey">
|
|
1024
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur" />
|
|
1025
|
+
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" />
|
|
1026
|
+
<feBlend in="SourceGraphic" in2="goo" />
|
|
1027
|
+
</filter>
|
|
1028
|
+
</svg>`;
|
|
1029
|
+
|
|
1021
1030
|
const POSITIONS = [
|
|
1022
1031
|
'top-left',
|
|
1023
1032
|
'top-center',
|
|
@@ -1050,6 +1059,8 @@ function createContainer(position, root, opts) {
|
|
|
1050
1059
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1051
1060
|
}
|
|
1052
1061
|
}
|
|
1062
|
+
// Aplica el filtro gooey a los toasters
|
|
1063
|
+
c.style.filter = 'url(#sileo-gooey)';
|
|
1053
1064
|
return c;
|
|
1054
1065
|
}
|
|
1055
1066
|
function renderToast(item) {
|
|
@@ -1059,6 +1070,43 @@ function renderToast(item) {
|
|
|
1059
1070
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1060
1071
|
el.style.opacity = '0';
|
|
1061
1072
|
el.style.transform = 'translateY(-6px)';
|
|
1073
|
+
// Soporte visual para fill y roundness
|
|
1074
|
+
if (item.options.fill) {
|
|
1075
|
+
el.style.background = item.options.fill;
|
|
1076
|
+
}
|
|
1077
|
+
if (item.options.roundness) {
|
|
1078
|
+
el.style.borderRadius = item.options.roundness + 'px';
|
|
1079
|
+
el.style.setProperty('--sileo-roundness', item.options.roundness + 'px');
|
|
1080
|
+
}
|
|
1081
|
+
// Badge SVG animado (efecto Sileo)
|
|
1082
|
+
const badge = document.createElement('div');
|
|
1083
|
+
badge.className = 'sileo-toast-badge';
|
|
1084
|
+
badge.setAttribute('data-sileo-badge', '');
|
|
1085
|
+
// Icono SVG custom o por tipo
|
|
1086
|
+
if (item.options.icon) {
|
|
1087
|
+
if (typeof item.options.icon === 'string') {
|
|
1088
|
+
badge.innerHTML = item.options.icon;
|
|
1089
|
+
}
|
|
1090
|
+
else if (item.options.icon instanceof HTMLElement) {
|
|
1091
|
+
badge.appendChild(item.options.icon);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
else {
|
|
1095
|
+
// Icono por tipo (ejemplo simple, puedes mejorar SVGs)
|
|
1096
|
+
badge.innerHTML = {
|
|
1097
|
+
success: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#16a34a"/><path d="M6 10.5l2.5 2.5 5-5" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1098
|
+
error: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#ef4444"/><path d="M7 7l6 6M13 7l-6 6" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1099
|
+
info: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#2563eb"/><text x="10" y="15" text-anchor="middle" font-size="12" fill="#fff">i</text></svg>',
|
|
1100
|
+
warning: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#f59e0b"/><path d="M10 6v4m0 3h.01" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1101
|
+
action: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#6366f1"/><path d="M7 10h6" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1102
|
+
loading: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="8" stroke="#fff" stroke-width="3" opacity=".3"/><path d="M18 10a8 8 0 1 1-8-8" stroke="#fff" stroke-width="3"/></svg>',
|
|
1103
|
+
}[item.options.type || 'info'] || '';
|
|
1104
|
+
}
|
|
1105
|
+
// Aplica clases custom de styles.badge si existen
|
|
1106
|
+
if (item.options.styles && item.options.styles.badge) {
|
|
1107
|
+
badge.className += ' ' + item.options.styles.badge;
|
|
1108
|
+
}
|
|
1109
|
+
// Cuerpo del toast
|
|
1062
1110
|
const body = document.createElement('div');
|
|
1063
1111
|
body.style.display = 'flex';
|
|
1064
1112
|
body.style.flexDirection = 'column';
|
|
@@ -1066,18 +1114,28 @@ function renderToast(item) {
|
|
|
1066
1114
|
const header = document.createElement('div');
|
|
1067
1115
|
header.className = 'sileo-toast-header';
|
|
1068
1116
|
header.textContent = item.options.title || '';
|
|
1117
|
+
if (item.options.styles && item.options.styles.title) {
|
|
1118
|
+
header.className += ' ' + item.options.styles.title;
|
|
1119
|
+
}
|
|
1069
1120
|
body.appendChild(header);
|
|
1070
1121
|
if (item.options.description) {
|
|
1071
1122
|
const desc = document.createElement('div');
|
|
1072
1123
|
desc.className = 'sileo-toast-desc';
|
|
1073
1124
|
desc.textContent = item.options.description;
|
|
1125
|
+
if (item.options.styles && item.options.styles.description) {
|
|
1126
|
+
desc.className += ' ' + item.options.styles.description;
|
|
1127
|
+
}
|
|
1074
1128
|
body.appendChild(desc);
|
|
1075
1129
|
}
|
|
1130
|
+
el.appendChild(badge);
|
|
1076
1131
|
el.appendChild(body);
|
|
1077
1132
|
if (item.options.button) {
|
|
1078
1133
|
const btn = document.createElement('button');
|
|
1079
1134
|
btn.className = 'sileo-toast-btn';
|
|
1080
1135
|
btn.textContent = item.options.button.title;
|
|
1136
|
+
if (item.options.styles && item.options.styles.button) {
|
|
1137
|
+
btn.className += ' ' + item.options.styles.button;
|
|
1138
|
+
}
|
|
1081
1139
|
btn.addEventListener('click', (e) => {
|
|
1082
1140
|
e.stopPropagation();
|
|
1083
1141
|
try {
|
|
@@ -1096,6 +1154,16 @@ function renderToast(item) {
|
|
|
1096
1154
|
close.innerHTML = '×';
|
|
1097
1155
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1098
1156
|
el.appendChild(close);
|
|
1157
|
+
// Soporte para autopilot: expansión/colapso automático (simulado)
|
|
1158
|
+
if (item.options.autopilot !== false) {
|
|
1159
|
+
setTimeout(() => {
|
|
1160
|
+
el.style.transform = 'scale(1.03)';
|
|
1161
|
+
el.style.transition = 'transform 0.18s cubic-bezier(.22,1,.36,1)';
|
|
1162
|
+
setTimeout(() => {
|
|
1163
|
+
el.style.transform = 'scale(1)';
|
|
1164
|
+
}, 180);
|
|
1165
|
+
}, 120);
|
|
1166
|
+
}
|
|
1099
1167
|
if (typeof item.options.duration === 'number') {
|
|
1100
1168
|
if (item.options.duration > 0) {
|
|
1101
1169
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1105,6 +1173,16 @@ function renderToast(item) {
|
|
|
1105
1173
|
}
|
|
1106
1174
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1107
1175
|
const containers = {};
|
|
1176
|
+
// Inyecta el SVG filter gooey solo una vez
|
|
1177
|
+
if (!document.getElementById('sileo-gooey-svg')) {
|
|
1178
|
+
const div = document.createElement('div');
|
|
1179
|
+
div.id = 'sileo-gooey-svg';
|
|
1180
|
+
div.style.position = 'absolute';
|
|
1181
|
+
div.style.width = '0';
|
|
1182
|
+
div.style.height = '0';
|
|
1183
|
+
div.innerHTML = gooeySVG;
|
|
1184
|
+
document.body.appendChild(div);
|
|
1185
|
+
}
|
|
1108
1186
|
positions.forEach((pos) => {
|
|
1109
1187
|
const c = createContainer(pos, root, opts);
|
|
1110
1188
|
root.appendChild(c);
|
package/dist/index.esm.js
CHANGED
|
@@ -1014,6 +1014,15 @@ function animate(target, keyframesOrOptions, options) {
|
|
|
1014
1014
|
return factory(target, keyframesOrOptions, options);
|
|
1015
1015
|
}
|
|
1016
1016
|
|
|
1017
|
+
// SVG Gooey Filter para animaciones morphing estilo Sileo
|
|
1018
|
+
const gooeySVG = `<svg width="0" height="0" style="position:absolute">
|
|
1019
|
+
<filter id="sileo-gooey">
|
|
1020
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur" />
|
|
1021
|
+
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" />
|
|
1022
|
+
<feBlend in="SourceGraphic" in2="goo" />
|
|
1023
|
+
</filter>
|
|
1024
|
+
</svg>`;
|
|
1025
|
+
|
|
1017
1026
|
const POSITIONS = [
|
|
1018
1027
|
'top-left',
|
|
1019
1028
|
'top-center',
|
|
@@ -1046,6 +1055,8 @@ function createContainer(position, root, opts) {
|
|
|
1046
1055
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1047
1056
|
}
|
|
1048
1057
|
}
|
|
1058
|
+
// Aplica el filtro gooey a los toasters
|
|
1059
|
+
c.style.filter = 'url(#sileo-gooey)';
|
|
1049
1060
|
return c;
|
|
1050
1061
|
}
|
|
1051
1062
|
function renderToast(item) {
|
|
@@ -1055,6 +1066,43 @@ function renderToast(item) {
|
|
|
1055
1066
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1056
1067
|
el.style.opacity = '0';
|
|
1057
1068
|
el.style.transform = 'translateY(-6px)';
|
|
1069
|
+
// Soporte visual para fill y roundness
|
|
1070
|
+
if (item.options.fill) {
|
|
1071
|
+
el.style.background = item.options.fill;
|
|
1072
|
+
}
|
|
1073
|
+
if (item.options.roundness) {
|
|
1074
|
+
el.style.borderRadius = item.options.roundness + 'px';
|
|
1075
|
+
el.style.setProperty('--sileo-roundness', item.options.roundness + 'px');
|
|
1076
|
+
}
|
|
1077
|
+
// Badge SVG animado (efecto Sileo)
|
|
1078
|
+
const badge = document.createElement('div');
|
|
1079
|
+
badge.className = 'sileo-toast-badge';
|
|
1080
|
+
badge.setAttribute('data-sileo-badge', '');
|
|
1081
|
+
// Icono SVG custom o por tipo
|
|
1082
|
+
if (item.options.icon) {
|
|
1083
|
+
if (typeof item.options.icon === 'string') {
|
|
1084
|
+
badge.innerHTML = item.options.icon;
|
|
1085
|
+
}
|
|
1086
|
+
else if (item.options.icon instanceof HTMLElement) {
|
|
1087
|
+
badge.appendChild(item.options.icon);
|
|
1088
|
+
}
|
|
1089
|
+
}
|
|
1090
|
+
else {
|
|
1091
|
+
// Icono por tipo (ejemplo simple, puedes mejorar SVGs)
|
|
1092
|
+
badge.innerHTML = {
|
|
1093
|
+
success: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#16a34a"/><path d="M6 10.5l2.5 2.5 5-5" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1094
|
+
error: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#ef4444"/><path d="M7 7l6 6M13 7l-6 6" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1095
|
+
info: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#2563eb"/><text x="10" y="15" text-anchor="middle" font-size="12" fill="#fff">i</text></svg>',
|
|
1096
|
+
warning: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#f59e0b"/><path d="M10 6v4m0 3h.01" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1097
|
+
action: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#6366f1"/><path d="M7 10h6" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1098
|
+
loading: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="8" stroke="#fff" stroke-width="3" opacity=".3"/><path d="M18 10a8 8 0 1 1-8-8" stroke="#fff" stroke-width="3"/></svg>',
|
|
1099
|
+
}[item.options.type || 'info'] || '';
|
|
1100
|
+
}
|
|
1101
|
+
// Aplica clases custom de styles.badge si existen
|
|
1102
|
+
if (item.options.styles && item.options.styles.badge) {
|
|
1103
|
+
badge.className += ' ' + item.options.styles.badge;
|
|
1104
|
+
}
|
|
1105
|
+
// Cuerpo del toast
|
|
1058
1106
|
const body = document.createElement('div');
|
|
1059
1107
|
body.style.display = 'flex';
|
|
1060
1108
|
body.style.flexDirection = 'column';
|
|
@@ -1062,18 +1110,28 @@ function renderToast(item) {
|
|
|
1062
1110
|
const header = document.createElement('div');
|
|
1063
1111
|
header.className = 'sileo-toast-header';
|
|
1064
1112
|
header.textContent = item.options.title || '';
|
|
1113
|
+
if (item.options.styles && item.options.styles.title) {
|
|
1114
|
+
header.className += ' ' + item.options.styles.title;
|
|
1115
|
+
}
|
|
1065
1116
|
body.appendChild(header);
|
|
1066
1117
|
if (item.options.description) {
|
|
1067
1118
|
const desc = document.createElement('div');
|
|
1068
1119
|
desc.className = 'sileo-toast-desc';
|
|
1069
1120
|
desc.textContent = item.options.description;
|
|
1121
|
+
if (item.options.styles && item.options.styles.description) {
|
|
1122
|
+
desc.className += ' ' + item.options.styles.description;
|
|
1123
|
+
}
|
|
1070
1124
|
body.appendChild(desc);
|
|
1071
1125
|
}
|
|
1126
|
+
el.appendChild(badge);
|
|
1072
1127
|
el.appendChild(body);
|
|
1073
1128
|
if (item.options.button) {
|
|
1074
1129
|
const btn = document.createElement('button');
|
|
1075
1130
|
btn.className = 'sileo-toast-btn';
|
|
1076
1131
|
btn.textContent = item.options.button.title;
|
|
1132
|
+
if (item.options.styles && item.options.styles.button) {
|
|
1133
|
+
btn.className += ' ' + item.options.styles.button;
|
|
1134
|
+
}
|
|
1077
1135
|
btn.addEventListener('click', (e) => {
|
|
1078
1136
|
e.stopPropagation();
|
|
1079
1137
|
try {
|
|
@@ -1092,6 +1150,16 @@ function renderToast(item) {
|
|
|
1092
1150
|
close.innerHTML = '×';
|
|
1093
1151
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1094
1152
|
el.appendChild(close);
|
|
1153
|
+
// Soporte para autopilot: expansión/colapso automático (simulado)
|
|
1154
|
+
if (item.options.autopilot !== false) {
|
|
1155
|
+
setTimeout(() => {
|
|
1156
|
+
el.style.transform = 'scale(1.03)';
|
|
1157
|
+
el.style.transition = 'transform 0.18s cubic-bezier(.22,1,.36,1)';
|
|
1158
|
+
setTimeout(() => {
|
|
1159
|
+
el.style.transform = 'scale(1)';
|
|
1160
|
+
}, 180);
|
|
1161
|
+
}, 120);
|
|
1162
|
+
}
|
|
1095
1163
|
if (typeof item.options.duration === 'number') {
|
|
1096
1164
|
if (item.options.duration > 0) {
|
|
1097
1165
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1101,6 +1169,16 @@ function renderToast(item) {
|
|
|
1101
1169
|
}
|
|
1102
1170
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1103
1171
|
const containers = {};
|
|
1172
|
+
// Inyecta el SVG filter gooey solo una vez
|
|
1173
|
+
if (!document.getElementById('sileo-gooey-svg')) {
|
|
1174
|
+
const div = document.createElement('div');
|
|
1175
|
+
div.id = 'sileo-gooey-svg';
|
|
1176
|
+
div.style.position = 'absolute';
|
|
1177
|
+
div.style.width = '0';
|
|
1178
|
+
div.style.height = '0';
|
|
1179
|
+
div.innerHTML = gooeySVG;
|
|
1180
|
+
document.body.appendChild(div);
|
|
1181
|
+
}
|
|
1104
1182
|
positions.forEach((pos) => {
|
|
1105
1183
|
const c = createContainer(pos, root, opts);
|
|
1106
1184
|
root.appendChild(c);
|
package/dist/notify.umd.js
CHANGED
|
@@ -1020,6 +1020,15 @@
|
|
|
1020
1020
|
return factory(target, keyframesOrOptions, options);
|
|
1021
1021
|
}
|
|
1022
1022
|
|
|
1023
|
+
// SVG Gooey Filter para animaciones morphing estilo Sileo
|
|
1024
|
+
const gooeySVG = `<svg width="0" height="0" style="position:absolute">
|
|
1025
|
+
<filter id="sileo-gooey">
|
|
1026
|
+
<feGaussianBlur in="SourceGraphic" stdDeviation="6" result="blur" />
|
|
1027
|
+
<feColorMatrix in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 18 -7" result="goo" />
|
|
1028
|
+
<feBlend in="SourceGraphic" in2="goo" />
|
|
1029
|
+
</filter>
|
|
1030
|
+
</svg>`;
|
|
1031
|
+
|
|
1023
1032
|
const POSITIONS = [
|
|
1024
1033
|
'top-left',
|
|
1025
1034
|
'top-center',
|
|
@@ -1052,6 +1061,8 @@
|
|
|
1052
1061
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1053
1062
|
}
|
|
1054
1063
|
}
|
|
1064
|
+
// Aplica el filtro gooey a los toasters
|
|
1065
|
+
c.style.filter = 'url(#sileo-gooey)';
|
|
1055
1066
|
return c;
|
|
1056
1067
|
}
|
|
1057
1068
|
function renderToast(item) {
|
|
@@ -1061,6 +1072,43 @@
|
|
|
1061
1072
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1062
1073
|
el.style.opacity = '0';
|
|
1063
1074
|
el.style.transform = 'translateY(-6px)';
|
|
1075
|
+
// Soporte visual para fill y roundness
|
|
1076
|
+
if (item.options.fill) {
|
|
1077
|
+
el.style.background = item.options.fill;
|
|
1078
|
+
}
|
|
1079
|
+
if (item.options.roundness) {
|
|
1080
|
+
el.style.borderRadius = item.options.roundness + 'px';
|
|
1081
|
+
el.style.setProperty('--sileo-roundness', item.options.roundness + 'px');
|
|
1082
|
+
}
|
|
1083
|
+
// Badge SVG animado (efecto Sileo)
|
|
1084
|
+
const badge = document.createElement('div');
|
|
1085
|
+
badge.className = 'sileo-toast-badge';
|
|
1086
|
+
badge.setAttribute('data-sileo-badge', '');
|
|
1087
|
+
// Icono SVG custom o por tipo
|
|
1088
|
+
if (item.options.icon) {
|
|
1089
|
+
if (typeof item.options.icon === 'string') {
|
|
1090
|
+
badge.innerHTML = item.options.icon;
|
|
1091
|
+
}
|
|
1092
|
+
else if (item.options.icon instanceof HTMLElement) {
|
|
1093
|
+
badge.appendChild(item.options.icon);
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
1096
|
+
else {
|
|
1097
|
+
// Icono por tipo (ejemplo simple, puedes mejorar SVGs)
|
|
1098
|
+
badge.innerHTML = {
|
|
1099
|
+
success: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#16a34a"/><path d="M6 10.5l2.5 2.5 5-5" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1100
|
+
error: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#ef4444"/><path d="M7 7l6 6M13 7l-6 6" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1101
|
+
info: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#2563eb"/><text x="10" y="15" text-anchor="middle" font-size="12" fill="#fff">i</text></svg>',
|
|
1102
|
+
warning: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#f59e0b"/><path d="M10 6v4m0 3h.01" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1103
|
+
action: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="10" fill="#6366f1"/><path d="M7 10h6" stroke="#fff" stroke-width="1.5" stroke-linecap="round"/></svg>',
|
|
1104
|
+
loading: '<svg width="20" height="20" fill="none" viewBox="0 0 20 20"><circle cx="10" cy="10" r="8" stroke="#fff" stroke-width="3" opacity=".3"/><path d="M18 10a8 8 0 1 1-8-8" stroke="#fff" stroke-width="3"/></svg>',
|
|
1105
|
+
}[item.options.type || 'info'] || '';
|
|
1106
|
+
}
|
|
1107
|
+
// Aplica clases custom de styles.badge si existen
|
|
1108
|
+
if (item.options.styles && item.options.styles.badge) {
|
|
1109
|
+
badge.className += ' ' + item.options.styles.badge;
|
|
1110
|
+
}
|
|
1111
|
+
// Cuerpo del toast
|
|
1064
1112
|
const body = document.createElement('div');
|
|
1065
1113
|
body.style.display = 'flex';
|
|
1066
1114
|
body.style.flexDirection = 'column';
|
|
@@ -1068,18 +1116,28 @@
|
|
|
1068
1116
|
const header = document.createElement('div');
|
|
1069
1117
|
header.className = 'sileo-toast-header';
|
|
1070
1118
|
header.textContent = item.options.title || '';
|
|
1119
|
+
if (item.options.styles && item.options.styles.title) {
|
|
1120
|
+
header.className += ' ' + item.options.styles.title;
|
|
1121
|
+
}
|
|
1071
1122
|
body.appendChild(header);
|
|
1072
1123
|
if (item.options.description) {
|
|
1073
1124
|
const desc = document.createElement('div');
|
|
1074
1125
|
desc.className = 'sileo-toast-desc';
|
|
1075
1126
|
desc.textContent = item.options.description;
|
|
1127
|
+
if (item.options.styles && item.options.styles.description) {
|
|
1128
|
+
desc.className += ' ' + item.options.styles.description;
|
|
1129
|
+
}
|
|
1076
1130
|
body.appendChild(desc);
|
|
1077
1131
|
}
|
|
1132
|
+
el.appendChild(badge);
|
|
1078
1133
|
el.appendChild(body);
|
|
1079
1134
|
if (item.options.button) {
|
|
1080
1135
|
const btn = document.createElement('button');
|
|
1081
1136
|
btn.className = 'sileo-toast-btn';
|
|
1082
1137
|
btn.textContent = item.options.button.title;
|
|
1138
|
+
if (item.options.styles && item.options.styles.button) {
|
|
1139
|
+
btn.className += ' ' + item.options.styles.button;
|
|
1140
|
+
}
|
|
1083
1141
|
btn.addEventListener('click', (e) => {
|
|
1084
1142
|
e.stopPropagation();
|
|
1085
1143
|
try {
|
|
@@ -1098,6 +1156,16 @@
|
|
|
1098
1156
|
close.innerHTML = '×';
|
|
1099
1157
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1100
1158
|
el.appendChild(close);
|
|
1159
|
+
// Soporte para autopilot: expansión/colapso automático (simulado)
|
|
1160
|
+
if (item.options.autopilot !== false) {
|
|
1161
|
+
setTimeout(() => {
|
|
1162
|
+
el.style.transform = 'scale(1.03)';
|
|
1163
|
+
el.style.transition = 'transform 0.18s cubic-bezier(.22,1,.36,1)';
|
|
1164
|
+
setTimeout(() => {
|
|
1165
|
+
el.style.transform = 'scale(1)';
|
|
1166
|
+
}, 180);
|
|
1167
|
+
}, 120);
|
|
1168
|
+
}
|
|
1101
1169
|
if (typeof item.options.duration === 'number') {
|
|
1102
1170
|
if (item.options.duration > 0) {
|
|
1103
1171
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1107,6 +1175,16 @@
|
|
|
1107
1175
|
}
|
|
1108
1176
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1109
1177
|
const containers = {};
|
|
1178
|
+
// Inyecta el SVG filter gooey solo una vez
|
|
1179
|
+
if (!document.getElementById('sileo-gooey-svg')) {
|
|
1180
|
+
const div = document.createElement('div');
|
|
1181
|
+
div.id = 'sileo-gooey-svg';
|
|
1182
|
+
div.style.position = 'absolute';
|
|
1183
|
+
div.style.width = '0';
|
|
1184
|
+
div.style.height = '0';
|
|
1185
|
+
div.innerHTML = gooeySVG;
|
|
1186
|
+
document.body.appendChild(div);
|
|
1187
|
+
}
|
|
1110
1188
|
positions.forEach((pos) => {
|
|
1111
1189
|
const c = createContainer(pos, root, opts);
|
|
1112
1190
|
root.appendChild(c);
|
package/dist/styles.css
CHANGED
|
@@ -43,13 +43,16 @@
|
|
|
43
43
|
background: var(--sileo-bg);
|
|
44
44
|
color: var(--sileo-foreground);
|
|
45
45
|
padding: 0.75rem 0.875rem;
|
|
46
|
-
border-radius:
|
|
46
|
+
border-radius: var(--sileo-roundness, 1rem);
|
|
47
47
|
box-shadow: 0 0.375rem 1.125rem rgba(2,6,23,0.6);
|
|
48
48
|
display: flex;
|
|
49
49
|
gap: 0.5rem;
|
|
50
50
|
align-items: center;
|
|
51
51
|
position: relative;
|
|
52
52
|
overflow: hidden;
|
|
53
|
+
/* Efecto gooey visual */
|
|
54
|
+
backdrop-filter: blur(6px) saturate(1.2);
|
|
55
|
+
filter: url(#sileo-gooey);
|
|
53
56
|
}
|
|
54
57
|
|
|
55
58
|
.sileo-toast[data-type="success"]{ border-left: 0.25rem solid var(--sileo-success); }
|
|
@@ -58,6 +61,29 @@
|
|
|
58
61
|
.sileo-toast[data-type="warning"]{ border-left: 0.25rem solid var(--sileo-warning); }
|
|
59
62
|
|
|
60
63
|
.sileo-toast-header{ font-weight: 600; font-size: 0.875rem; }
|
|
64
|
+
|
|
65
|
+
/* Badge circular con blur y animación */
|
|
66
|
+
.sileo-toast-badge {
|
|
67
|
+
width: 2.25rem;
|
|
68
|
+
height: 2.25rem;
|
|
69
|
+
min-width: 2.25rem;
|
|
70
|
+
min-height: 2.25rem;
|
|
71
|
+
border-radius: 50%;
|
|
72
|
+
background: rgba(255,255,255,0.08);
|
|
73
|
+
display: flex;
|
|
74
|
+
align-items: center;
|
|
75
|
+
justify-content: center;
|
|
76
|
+
margin-right: 0.5rem;
|
|
77
|
+
box-shadow: 0 0 0.5rem 0.1rem rgba(0,0,0,0.10);
|
|
78
|
+
backdrop-filter: blur(2.5px);
|
|
79
|
+
animation: sileo-badge-pop 0.38s cubic-bezier(.22,1,.36,1) both;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
@keyframes sileo-badge-pop {
|
|
83
|
+
0% { transform: scale(0.7); opacity: 0; }
|
|
84
|
+
60% { transform: scale(1.15); opacity: 1; }
|
|
85
|
+
100% { transform: scale(1); opacity: 1; }
|
|
86
|
+
}
|
|
61
87
|
.sileo-toast-desc{ font-size: 0.8125rem; opacity: 0.85; margin-top: 0.25rem; }
|
|
62
88
|
.sileo-toast-btn{ margin-left: 0.5rem; background: transparent; color: inherit; border: 1px solid rgba(255,255,255,0.08); padding: 0.375rem 0.5rem; border-radius: 0.375rem; cursor: pointer; }
|
|
63
89
|
.sileo-toast-close{ position: absolute; right: 0.5rem; top: 0.375rem; background: transparent; border: none; color: inherit; font-size: 1rem; cursor: pointer; }
|
package/docs/browser.md
CHANGED
|
@@ -8,8 +8,8 @@ Use this package directly in the browser when you cannot use npm modules or a bu
|
|
|
8
8
|
Add the stylesheet and UMD bundle to your HTML:
|
|
9
9
|
|
|
10
10
|
```html
|
|
11
|
-
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.
|
|
12
|
-
<script src="https://unpkg.com/@samline/notify@0.2.
|
|
11
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.5/dist/styles.css">
|
|
12
|
+
<script src="https://unpkg.com/@samline/notify@0.2.5/dist/notify.umd.js"></script>
|
|
13
13
|
<script>
|
|
14
14
|
document.addEventListener('DOMContentLoaded', () => {
|
|
15
15
|
const api = window.notify; // or window.notifications for legacy
|
|
@@ -40,8 +40,8 @@ Add the stylesheet and UMD bundle to your HTML:
|
|
|
40
40
|
|
|
41
41
|
### Advanced Options
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.5/dist/styles.css">
|
|
44
|
+
<script src="https://unpkg.com/@samline/notify@0.2.5/dist/notify.umd.js"></script>
|
|
45
45
|
| Property | Type | Default | Description |
|
|
46
46
|
| ------------- | -------------------------------------- | ----------- | ------------------------------------------- |
|
|
47
47
|
| `title` | string | — | Toast title |
|
|
@@ -55,8 +55,8 @@ All notification methods accept advanced options:
|
|
|
55
55
|
| `styles` | { title, description, badge, button } | — | Custom class overrides for sub-elements |
|
|
56
56
|
| `roundness` | number | 16 | Border radius in pixels |
|
|
57
57
|
| `autopilot` | boolean \| object | true | Auto expand/collapse timing |
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
<script src="https://unpkg.com/@samline/notify@0.2.5/dist/notify.umd.js"></script>
|
|
59
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.5/dist/styles.css" />
|
|
60
60
|
|
|
61
61
|
```js
|
|
62
62
|
api.success({
|
package/docs/vanilla.md
CHANGED
|
@@ -178,8 +178,8 @@ notify.success({
|
|
|
178
178
|
If you are not using a bundler, use the [Browser guide](./browser.md) for CDN usage. Example:
|
|
179
179
|
|
|
180
180
|
```html
|
|
181
|
-
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.
|
|
182
|
-
<script src="https://unpkg.com/@samline/notify@0.2.
|
|
181
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.5/dist/styles.css">
|
|
182
|
+
<script src="https://unpkg.com/@samline/notify@0.2.5/dist/notify.umd.js"></script>
|
|
183
183
|
<script>
|
|
184
184
|
document.addEventListener('DOMContentLoaded', () => {
|
|
185
185
|
const api = window.notify;
|
package/package.json
CHANGED
package/samline-notify-0.1.9.tgz
DELETED
|
Binary file
|