@samline/notify 0.2.7 → 0.3.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/README.md +3 -3
- package/dist/index.cjs.js +0 -78
- package/dist/index.esm.js +0 -78
- package/dist/notify.umd.js +0 -78
- package/dist/styles.css +1 -27
- package/docs/browser.md +13 -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.
|
|
54
|
-
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.
|
|
53
|
+
<script src="https://unpkg.com/@samline/notify@0.3.0/dist/notify.umd.js"></script>
|
|
54
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.3.0/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.3/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,15 +1018,6 @@ 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
|
-
|
|
1030
1021
|
const POSITIONS = [
|
|
1031
1022
|
'top-left',
|
|
1032
1023
|
'top-center',
|
|
@@ -1059,8 +1050,6 @@ function createContainer(position, root, opts) {
|
|
|
1059
1050
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1060
1051
|
}
|
|
1061
1052
|
}
|
|
1062
|
-
// Aplica el filtro gooey a los toasters
|
|
1063
|
-
c.style.filter = 'url(#sileo-gooey)';
|
|
1064
1053
|
return c;
|
|
1065
1054
|
}
|
|
1066
1055
|
function renderToast(item) {
|
|
@@ -1070,43 +1059,6 @@ function renderToast(item) {
|
|
|
1070
1059
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1071
1060
|
el.style.opacity = '0';
|
|
1072
1061
|
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
|
|
1110
1062
|
const body = document.createElement('div');
|
|
1111
1063
|
body.style.display = 'flex';
|
|
1112
1064
|
body.style.flexDirection = 'column';
|
|
@@ -1114,28 +1066,18 @@ function renderToast(item) {
|
|
|
1114
1066
|
const header = document.createElement('div');
|
|
1115
1067
|
header.className = 'sileo-toast-header';
|
|
1116
1068
|
header.textContent = item.options.title || '';
|
|
1117
|
-
if (item.options.styles && item.options.styles.title) {
|
|
1118
|
-
header.className += ' ' + item.options.styles.title;
|
|
1119
|
-
}
|
|
1120
1069
|
body.appendChild(header);
|
|
1121
1070
|
if (item.options.description) {
|
|
1122
1071
|
const desc = document.createElement('div');
|
|
1123
1072
|
desc.className = 'sileo-toast-desc';
|
|
1124
1073
|
desc.textContent = item.options.description;
|
|
1125
|
-
if (item.options.styles && item.options.styles.description) {
|
|
1126
|
-
desc.className += ' ' + item.options.styles.description;
|
|
1127
|
-
}
|
|
1128
1074
|
body.appendChild(desc);
|
|
1129
1075
|
}
|
|
1130
|
-
el.appendChild(badge);
|
|
1131
1076
|
el.appendChild(body);
|
|
1132
1077
|
if (item.options.button) {
|
|
1133
1078
|
const btn = document.createElement('button');
|
|
1134
1079
|
btn.className = 'sileo-toast-btn';
|
|
1135
1080
|
btn.textContent = item.options.button.title;
|
|
1136
|
-
if (item.options.styles && item.options.styles.button) {
|
|
1137
|
-
btn.className += ' ' + item.options.styles.button;
|
|
1138
|
-
}
|
|
1139
1081
|
btn.addEventListener('click', (e) => {
|
|
1140
1082
|
e.stopPropagation();
|
|
1141
1083
|
try {
|
|
@@ -1154,16 +1096,6 @@ function renderToast(item) {
|
|
|
1154
1096
|
close.innerHTML = '×';
|
|
1155
1097
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1156
1098
|
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
|
-
}
|
|
1167
1099
|
if (typeof item.options.duration === 'number') {
|
|
1168
1100
|
if (item.options.duration > 0) {
|
|
1169
1101
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1173,16 +1105,6 @@ function renderToast(item) {
|
|
|
1173
1105
|
}
|
|
1174
1106
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1175
1107
|
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
|
-
}
|
|
1186
1108
|
positions.forEach((pos) => {
|
|
1187
1109
|
const c = createContainer(pos, root, opts);
|
|
1188
1110
|
root.appendChild(c);
|
package/dist/index.esm.js
CHANGED
|
@@ -1014,15 +1014,6 @@ 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
|
-
|
|
1026
1017
|
const POSITIONS = [
|
|
1027
1018
|
'top-left',
|
|
1028
1019
|
'top-center',
|
|
@@ -1055,8 +1046,6 @@ function createContainer(position, root, opts) {
|
|
|
1055
1046
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1056
1047
|
}
|
|
1057
1048
|
}
|
|
1058
|
-
// Aplica el filtro gooey a los toasters
|
|
1059
|
-
c.style.filter = 'url(#sileo-gooey)';
|
|
1060
1049
|
return c;
|
|
1061
1050
|
}
|
|
1062
1051
|
function renderToast(item) {
|
|
@@ -1066,43 +1055,6 @@ function renderToast(item) {
|
|
|
1066
1055
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1067
1056
|
el.style.opacity = '0';
|
|
1068
1057
|
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
|
|
1106
1058
|
const body = document.createElement('div');
|
|
1107
1059
|
body.style.display = 'flex';
|
|
1108
1060
|
body.style.flexDirection = 'column';
|
|
@@ -1110,28 +1062,18 @@ function renderToast(item) {
|
|
|
1110
1062
|
const header = document.createElement('div');
|
|
1111
1063
|
header.className = 'sileo-toast-header';
|
|
1112
1064
|
header.textContent = item.options.title || '';
|
|
1113
|
-
if (item.options.styles && item.options.styles.title) {
|
|
1114
|
-
header.className += ' ' + item.options.styles.title;
|
|
1115
|
-
}
|
|
1116
1065
|
body.appendChild(header);
|
|
1117
1066
|
if (item.options.description) {
|
|
1118
1067
|
const desc = document.createElement('div');
|
|
1119
1068
|
desc.className = 'sileo-toast-desc';
|
|
1120
1069
|
desc.textContent = item.options.description;
|
|
1121
|
-
if (item.options.styles && item.options.styles.description) {
|
|
1122
|
-
desc.className += ' ' + item.options.styles.description;
|
|
1123
|
-
}
|
|
1124
1070
|
body.appendChild(desc);
|
|
1125
1071
|
}
|
|
1126
|
-
el.appendChild(badge);
|
|
1127
1072
|
el.appendChild(body);
|
|
1128
1073
|
if (item.options.button) {
|
|
1129
1074
|
const btn = document.createElement('button');
|
|
1130
1075
|
btn.className = 'sileo-toast-btn';
|
|
1131
1076
|
btn.textContent = item.options.button.title;
|
|
1132
|
-
if (item.options.styles && item.options.styles.button) {
|
|
1133
|
-
btn.className += ' ' + item.options.styles.button;
|
|
1134
|
-
}
|
|
1135
1077
|
btn.addEventListener('click', (e) => {
|
|
1136
1078
|
e.stopPropagation();
|
|
1137
1079
|
try {
|
|
@@ -1150,16 +1092,6 @@ function renderToast(item) {
|
|
|
1150
1092
|
close.innerHTML = '×';
|
|
1151
1093
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1152
1094
|
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
|
-
}
|
|
1163
1095
|
if (typeof item.options.duration === 'number') {
|
|
1164
1096
|
if (item.options.duration > 0) {
|
|
1165
1097
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1169,16 +1101,6 @@ function renderToast(item) {
|
|
|
1169
1101
|
}
|
|
1170
1102
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1171
1103
|
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
|
-
}
|
|
1182
1104
|
positions.forEach((pos) => {
|
|
1183
1105
|
const c = createContainer(pos, root, opts);
|
|
1184
1106
|
root.appendChild(c);
|
package/dist/notify.umd.js
CHANGED
|
@@ -1020,15 +1020,6 @@
|
|
|
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
|
-
|
|
1032
1023
|
const POSITIONS = [
|
|
1033
1024
|
'top-left',
|
|
1034
1025
|
'top-center',
|
|
@@ -1061,8 +1052,6 @@
|
|
|
1061
1052
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1062
1053
|
}
|
|
1063
1054
|
}
|
|
1064
|
-
// Aplica el filtro gooey a los toasters
|
|
1065
|
-
c.style.filter = 'url(#sileo-gooey)';
|
|
1066
1055
|
return c;
|
|
1067
1056
|
}
|
|
1068
1057
|
function renderToast(item) {
|
|
@@ -1072,43 +1061,6 @@
|
|
|
1072
1061
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1073
1062
|
el.style.opacity = '0';
|
|
1074
1063
|
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
|
|
1112
1064
|
const body = document.createElement('div');
|
|
1113
1065
|
body.style.display = 'flex';
|
|
1114
1066
|
body.style.flexDirection = 'column';
|
|
@@ -1116,28 +1068,18 @@
|
|
|
1116
1068
|
const header = document.createElement('div');
|
|
1117
1069
|
header.className = 'sileo-toast-header';
|
|
1118
1070
|
header.textContent = item.options.title || '';
|
|
1119
|
-
if (item.options.styles && item.options.styles.title) {
|
|
1120
|
-
header.className += ' ' + item.options.styles.title;
|
|
1121
|
-
}
|
|
1122
1071
|
body.appendChild(header);
|
|
1123
1072
|
if (item.options.description) {
|
|
1124
1073
|
const desc = document.createElement('div');
|
|
1125
1074
|
desc.className = 'sileo-toast-desc';
|
|
1126
1075
|
desc.textContent = item.options.description;
|
|
1127
|
-
if (item.options.styles && item.options.styles.description) {
|
|
1128
|
-
desc.className += ' ' + item.options.styles.description;
|
|
1129
|
-
}
|
|
1130
1076
|
body.appendChild(desc);
|
|
1131
1077
|
}
|
|
1132
|
-
el.appendChild(badge);
|
|
1133
1078
|
el.appendChild(body);
|
|
1134
1079
|
if (item.options.button) {
|
|
1135
1080
|
const btn = document.createElement('button');
|
|
1136
1081
|
btn.className = 'sileo-toast-btn';
|
|
1137
1082
|
btn.textContent = item.options.button.title;
|
|
1138
|
-
if (item.options.styles && item.options.styles.button) {
|
|
1139
|
-
btn.className += ' ' + item.options.styles.button;
|
|
1140
|
-
}
|
|
1141
1083
|
btn.addEventListener('click', (e) => {
|
|
1142
1084
|
e.stopPropagation();
|
|
1143
1085
|
try {
|
|
@@ -1156,16 +1098,6 @@
|
|
|
1156
1098
|
close.innerHTML = '×';
|
|
1157
1099
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1158
1100
|
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
|
-
}
|
|
1169
1101
|
if (typeof item.options.duration === 'number') {
|
|
1170
1102
|
if (item.options.duration > 0) {
|
|
1171
1103
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1175,16 +1107,6 @@
|
|
|
1175
1107
|
}
|
|
1176
1108
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1177
1109
|
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
|
-
}
|
|
1188
1110
|
positions.forEach((pos) => {
|
|
1189
1111
|
const c = createContainer(pos, root, opts);
|
|
1190
1112
|
root.appendChild(c);
|
package/dist/styles.css
CHANGED
|
@@ -43,16 +43,13 @@
|
|
|
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: 0.625rem;
|
|
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);
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
.sileo-toast[data-type="success"]{ border-left: 0.25rem solid var(--sileo-success); }
|
|
@@ -61,29 +58,6 @@
|
|
|
61
58
|
.sileo-toast[data-type="warning"]{ border-left: 0.25rem solid var(--sileo-warning); }
|
|
62
59
|
|
|
63
60
|
.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
|
-
}
|
|
87
61
|
.sileo-toast-desc{ font-size: 0.8125rem; opacity: 0.85; margin-top: 0.25rem; }
|
|
88
62
|
.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; }
|
|
89
63
|
.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
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
|
|
2
2
|
# Browser / CDN usage
|
|
3
3
|
|
|
4
|
+
```html
|
|
5
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.3.0/dist/styles.css">
|
|
6
|
+
<script src="https://unpkg.com/@samline/notify@0.3.0/dist/notify.umd.js"></script>
|
|
4
7
|
Use this package directly in the browser when you cannot use npm modules or a bundler (e.g. Shopify, WordPress, static HTML).
|
|
5
8
|
|
|
6
9
|
## Quick start
|
|
@@ -8,19 +11,23 @@ Use this package directly in the browser when you cannot use npm modules or a bu
|
|
|
8
11
|
Add the stylesheet and UMD bundle to your HTML:
|
|
9
12
|
|
|
10
13
|
```html
|
|
11
|
-
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.
|
|
12
|
-
<script src="https://unpkg.com/@samline/notify@0.2.
|
|
14
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.3/dist/styles.css">
|
|
15
|
+
<script src="https://unpkg.com/@samline/notify@0.2.3/dist/notify.umd.js"></script>
|
|
13
16
|
<script>
|
|
14
17
|
document.addEventListener('DOMContentLoaded', () => {
|
|
15
18
|
const api = window.notify; // or window.notifications for legacy
|
|
16
19
|
// Always use an array of strings as the second argument
|
|
17
20
|
// Correct usage:
|
|
18
21
|
api.initToasters(document.body, ['top-left']);
|
|
22
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.3.0/dist/styles.css">
|
|
23
|
+
<script src="https://unpkg.com/@samline/notify@0.3.0/dist/notify.umd.js"></script>
|
|
19
24
|
api.notify({ title: 'Hello', description: 'No-bundler usage', type: 'info' });
|
|
20
25
|
});
|
|
21
26
|
</script>
|
|
22
27
|
```
|
|
23
28
|
|
|
29
|
+
<script src="https://unpkg.com/@samline/notify@0.3.0/dist/notify.umd.js"></script>
|
|
30
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.3.0/dist/styles.css" />
|
|
24
31
|
|
|
25
32
|
|
|
26
33
|
## API
|
|
@@ -40,8 +47,8 @@ Add the stylesheet and UMD bundle to your HTML:
|
|
|
40
47
|
|
|
41
48
|
### Advanced Options
|
|
42
49
|
|
|
43
|
-
|
|
44
|
-
|
|
50
|
+
All notification methods accept advanced options:
|
|
51
|
+
|
|
45
52
|
| Property | Type | Default | Description |
|
|
46
53
|
| ------------- | -------------------------------------- | ----------- | ------------------------------------------- |
|
|
47
54
|
| `title` | string | — | Toast title |
|
|
@@ -55,8 +62,8 @@ Add the stylesheet and UMD bundle to your HTML:
|
|
|
55
62
|
| `styles` | { title, description, badge, button } | — | Custom class overrides for sub-elements |
|
|
56
63
|
| `roundness` | number | 16 | Border radius in pixels |
|
|
57
64
|
| `autopilot` | boolean \| object | true | Auto expand/collapse timing |
|
|
58
|
-
|
|
59
|
-
|
|
65
|
+
|
|
66
|
+
#### Example: Advanced Toast
|
|
60
67
|
|
|
61
68
|
```js
|
|
62
69
|
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.
|
|
182
|
-
<script src="https://unpkg.com/@samline/notify@0.
|
|
181
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.3.0/dist/styles.css">
|
|
182
|
+
<script src="https://unpkg.com/@samline/notify@0.3.0/dist/notify.umd.js"></script>
|
|
183
183
|
<script>
|
|
184
184
|
document.addEventListener('DOMContentLoaded', () => {
|
|
185
185
|
const api = window.notify;
|
package/package.json
CHANGED
|
Binary file
|