@samline/notify 0.2.3 → 0.2.6
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 +81 -0
- package/dist/index.esm.js +81 -0
- package/dist/notify.umd.js +81 -0
- package/dist/styles.css +53 -2
- 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.6/dist/notify.umd.js"></script>
|
|
54
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.6/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.6/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,18 @@ 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="8" 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 30 -14" result="goo" />
|
|
1026
|
+
<feComponentTransfer in="goo" result="thresholded">
|
|
1027
|
+
<feFuncA type="table" tableValues="0 1" />
|
|
1028
|
+
</feComponentTransfer>
|
|
1029
|
+
<feBlend in="SourceGraphic" in2="thresholded" mode="normal" />
|
|
1030
|
+
</filter>
|
|
1031
|
+
</svg>`;
|
|
1032
|
+
|
|
1021
1033
|
const POSITIONS = [
|
|
1022
1034
|
'top-left',
|
|
1023
1035
|
'top-center',
|
|
@@ -1050,6 +1062,8 @@ function createContainer(position, root, opts) {
|
|
|
1050
1062
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1051
1063
|
}
|
|
1052
1064
|
}
|
|
1065
|
+
// Aplica el filtro gooey a los toasters
|
|
1066
|
+
c.style.filter = 'url(#sileo-gooey)';
|
|
1053
1067
|
return c;
|
|
1054
1068
|
}
|
|
1055
1069
|
function renderToast(item) {
|
|
@@ -1059,6 +1073,43 @@ function renderToast(item) {
|
|
|
1059
1073
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1060
1074
|
el.style.opacity = '0';
|
|
1061
1075
|
el.style.transform = 'translateY(-6px)';
|
|
1076
|
+
// Soporte visual para fill y roundness
|
|
1077
|
+
if (item.options.fill) {
|
|
1078
|
+
el.style.background = item.options.fill;
|
|
1079
|
+
}
|
|
1080
|
+
if (item.options.roundness) {
|
|
1081
|
+
el.style.borderRadius = item.options.roundness + 'px';
|
|
1082
|
+
el.style.setProperty('--sileo-roundness', item.options.roundness + 'px');
|
|
1083
|
+
}
|
|
1084
|
+
// Badge SVG animado (efecto Sileo)
|
|
1085
|
+
const badge = document.createElement('div');
|
|
1086
|
+
badge.className = 'sileo-toast-badge';
|
|
1087
|
+
badge.setAttribute('data-sileo-badge', '');
|
|
1088
|
+
// Icono SVG custom o por tipo
|
|
1089
|
+
if (item.options.icon) {
|
|
1090
|
+
if (typeof item.options.icon === 'string') {
|
|
1091
|
+
badge.innerHTML = item.options.icon;
|
|
1092
|
+
}
|
|
1093
|
+
else if (item.options.icon instanceof HTMLElement) {
|
|
1094
|
+
badge.appendChild(item.options.icon);
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
else {
|
|
1098
|
+
// Icono por tipo (ejemplo simple, puedes mejorar SVGs)
|
|
1099
|
+
badge.innerHTML = {
|
|
1100
|
+
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>',
|
|
1101
|
+
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>',
|
|
1102
|
+
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>',
|
|
1103
|
+
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>',
|
|
1104
|
+
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>',
|
|
1105
|
+
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>',
|
|
1106
|
+
}[item.options.type || 'info'] || '';
|
|
1107
|
+
}
|
|
1108
|
+
// Aplica clases custom de styles.badge si existen
|
|
1109
|
+
if (item.options.styles && item.options.styles.badge) {
|
|
1110
|
+
badge.className += ' ' + item.options.styles.badge;
|
|
1111
|
+
}
|
|
1112
|
+
// Cuerpo del toast
|
|
1062
1113
|
const body = document.createElement('div');
|
|
1063
1114
|
body.style.display = 'flex';
|
|
1064
1115
|
body.style.flexDirection = 'column';
|
|
@@ -1066,18 +1117,28 @@ function renderToast(item) {
|
|
|
1066
1117
|
const header = document.createElement('div');
|
|
1067
1118
|
header.className = 'sileo-toast-header';
|
|
1068
1119
|
header.textContent = item.options.title || '';
|
|
1120
|
+
if (item.options.styles && item.options.styles.title) {
|
|
1121
|
+
header.className += ' ' + item.options.styles.title;
|
|
1122
|
+
}
|
|
1069
1123
|
body.appendChild(header);
|
|
1070
1124
|
if (item.options.description) {
|
|
1071
1125
|
const desc = document.createElement('div');
|
|
1072
1126
|
desc.className = 'sileo-toast-desc';
|
|
1073
1127
|
desc.textContent = item.options.description;
|
|
1128
|
+
if (item.options.styles && item.options.styles.description) {
|
|
1129
|
+
desc.className += ' ' + item.options.styles.description;
|
|
1130
|
+
}
|
|
1074
1131
|
body.appendChild(desc);
|
|
1075
1132
|
}
|
|
1133
|
+
el.appendChild(badge);
|
|
1076
1134
|
el.appendChild(body);
|
|
1077
1135
|
if (item.options.button) {
|
|
1078
1136
|
const btn = document.createElement('button');
|
|
1079
1137
|
btn.className = 'sileo-toast-btn';
|
|
1080
1138
|
btn.textContent = item.options.button.title;
|
|
1139
|
+
if (item.options.styles && item.options.styles.button) {
|
|
1140
|
+
btn.className += ' ' + item.options.styles.button;
|
|
1141
|
+
}
|
|
1081
1142
|
btn.addEventListener('click', (e) => {
|
|
1082
1143
|
e.stopPropagation();
|
|
1083
1144
|
try {
|
|
@@ -1096,6 +1157,16 @@ function renderToast(item) {
|
|
|
1096
1157
|
close.innerHTML = '×';
|
|
1097
1158
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1098
1159
|
el.appendChild(close);
|
|
1160
|
+
// Soporte para autopilot: expansión/colapso automático (simulado)
|
|
1161
|
+
if (item.options.autopilot !== false) {
|
|
1162
|
+
setTimeout(() => {
|
|
1163
|
+
el.style.transform = 'scale(1.03)';
|
|
1164
|
+
el.style.transition = 'transform 0.18s cubic-bezier(.22,1,.36,1)';
|
|
1165
|
+
setTimeout(() => {
|
|
1166
|
+
el.style.transform = 'scale(1)';
|
|
1167
|
+
}, 180);
|
|
1168
|
+
}, 120);
|
|
1169
|
+
}
|
|
1099
1170
|
if (typeof item.options.duration === 'number') {
|
|
1100
1171
|
if (item.options.duration > 0) {
|
|
1101
1172
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1105,6 +1176,16 @@ function renderToast(item) {
|
|
|
1105
1176
|
}
|
|
1106
1177
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1107
1178
|
const containers = {};
|
|
1179
|
+
// Inyecta el SVG filter gooey solo una vez
|
|
1180
|
+
if (!document.getElementById('sileo-gooey-svg')) {
|
|
1181
|
+
const div = document.createElement('div');
|
|
1182
|
+
div.id = 'sileo-gooey-svg';
|
|
1183
|
+
div.style.position = 'absolute';
|
|
1184
|
+
div.style.width = '0';
|
|
1185
|
+
div.style.height = '0';
|
|
1186
|
+
div.innerHTML = gooeySVG;
|
|
1187
|
+
document.body.appendChild(div);
|
|
1188
|
+
}
|
|
1108
1189
|
positions.forEach((pos) => {
|
|
1109
1190
|
const c = createContainer(pos, root, opts);
|
|
1110
1191
|
root.appendChild(c);
|
package/dist/index.esm.js
CHANGED
|
@@ -1014,6 +1014,18 @@ 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="8" 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 30 -14" result="goo" />
|
|
1022
|
+
<feComponentTransfer in="goo" result="thresholded">
|
|
1023
|
+
<feFuncA type="table" tableValues="0 1" />
|
|
1024
|
+
</feComponentTransfer>
|
|
1025
|
+
<feBlend in="SourceGraphic" in2="thresholded" mode="normal" />
|
|
1026
|
+
</filter>
|
|
1027
|
+
</svg>`;
|
|
1028
|
+
|
|
1017
1029
|
const POSITIONS = [
|
|
1018
1030
|
'top-left',
|
|
1019
1031
|
'top-center',
|
|
@@ -1046,6 +1058,8 @@ function createContainer(position, root, opts) {
|
|
|
1046
1058
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1047
1059
|
}
|
|
1048
1060
|
}
|
|
1061
|
+
// Aplica el filtro gooey a los toasters
|
|
1062
|
+
c.style.filter = 'url(#sileo-gooey)';
|
|
1049
1063
|
return c;
|
|
1050
1064
|
}
|
|
1051
1065
|
function renderToast(item) {
|
|
@@ -1055,6 +1069,43 @@ function renderToast(item) {
|
|
|
1055
1069
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1056
1070
|
el.style.opacity = '0';
|
|
1057
1071
|
el.style.transform = 'translateY(-6px)';
|
|
1072
|
+
// Soporte visual para fill y roundness
|
|
1073
|
+
if (item.options.fill) {
|
|
1074
|
+
el.style.background = item.options.fill;
|
|
1075
|
+
}
|
|
1076
|
+
if (item.options.roundness) {
|
|
1077
|
+
el.style.borderRadius = item.options.roundness + 'px';
|
|
1078
|
+
el.style.setProperty('--sileo-roundness', item.options.roundness + 'px');
|
|
1079
|
+
}
|
|
1080
|
+
// Badge SVG animado (efecto Sileo)
|
|
1081
|
+
const badge = document.createElement('div');
|
|
1082
|
+
badge.className = 'sileo-toast-badge';
|
|
1083
|
+
badge.setAttribute('data-sileo-badge', '');
|
|
1084
|
+
// Icono SVG custom o por tipo
|
|
1085
|
+
if (item.options.icon) {
|
|
1086
|
+
if (typeof item.options.icon === 'string') {
|
|
1087
|
+
badge.innerHTML = item.options.icon;
|
|
1088
|
+
}
|
|
1089
|
+
else if (item.options.icon instanceof HTMLElement) {
|
|
1090
|
+
badge.appendChild(item.options.icon);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
// Icono por tipo (ejemplo simple, puedes mejorar SVGs)
|
|
1095
|
+
badge.innerHTML = {
|
|
1096
|
+
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>',
|
|
1097
|
+
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>',
|
|
1098
|
+
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>',
|
|
1099
|
+
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>',
|
|
1100
|
+
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>',
|
|
1101
|
+
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>',
|
|
1102
|
+
}[item.options.type || 'info'] || '';
|
|
1103
|
+
}
|
|
1104
|
+
// Aplica clases custom de styles.badge si existen
|
|
1105
|
+
if (item.options.styles && item.options.styles.badge) {
|
|
1106
|
+
badge.className += ' ' + item.options.styles.badge;
|
|
1107
|
+
}
|
|
1108
|
+
// Cuerpo del toast
|
|
1058
1109
|
const body = document.createElement('div');
|
|
1059
1110
|
body.style.display = 'flex';
|
|
1060
1111
|
body.style.flexDirection = 'column';
|
|
@@ -1062,18 +1113,28 @@ function renderToast(item) {
|
|
|
1062
1113
|
const header = document.createElement('div');
|
|
1063
1114
|
header.className = 'sileo-toast-header';
|
|
1064
1115
|
header.textContent = item.options.title || '';
|
|
1116
|
+
if (item.options.styles && item.options.styles.title) {
|
|
1117
|
+
header.className += ' ' + item.options.styles.title;
|
|
1118
|
+
}
|
|
1065
1119
|
body.appendChild(header);
|
|
1066
1120
|
if (item.options.description) {
|
|
1067
1121
|
const desc = document.createElement('div');
|
|
1068
1122
|
desc.className = 'sileo-toast-desc';
|
|
1069
1123
|
desc.textContent = item.options.description;
|
|
1124
|
+
if (item.options.styles && item.options.styles.description) {
|
|
1125
|
+
desc.className += ' ' + item.options.styles.description;
|
|
1126
|
+
}
|
|
1070
1127
|
body.appendChild(desc);
|
|
1071
1128
|
}
|
|
1129
|
+
el.appendChild(badge);
|
|
1072
1130
|
el.appendChild(body);
|
|
1073
1131
|
if (item.options.button) {
|
|
1074
1132
|
const btn = document.createElement('button');
|
|
1075
1133
|
btn.className = 'sileo-toast-btn';
|
|
1076
1134
|
btn.textContent = item.options.button.title;
|
|
1135
|
+
if (item.options.styles && item.options.styles.button) {
|
|
1136
|
+
btn.className += ' ' + item.options.styles.button;
|
|
1137
|
+
}
|
|
1077
1138
|
btn.addEventListener('click', (e) => {
|
|
1078
1139
|
e.stopPropagation();
|
|
1079
1140
|
try {
|
|
@@ -1092,6 +1153,16 @@ function renderToast(item) {
|
|
|
1092
1153
|
close.innerHTML = '×';
|
|
1093
1154
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1094
1155
|
el.appendChild(close);
|
|
1156
|
+
// Soporte para autopilot: expansión/colapso automático (simulado)
|
|
1157
|
+
if (item.options.autopilot !== false) {
|
|
1158
|
+
setTimeout(() => {
|
|
1159
|
+
el.style.transform = 'scale(1.03)';
|
|
1160
|
+
el.style.transition = 'transform 0.18s cubic-bezier(.22,1,.36,1)';
|
|
1161
|
+
setTimeout(() => {
|
|
1162
|
+
el.style.transform = 'scale(1)';
|
|
1163
|
+
}, 180);
|
|
1164
|
+
}, 120);
|
|
1165
|
+
}
|
|
1095
1166
|
if (typeof item.options.duration === 'number') {
|
|
1096
1167
|
if (item.options.duration > 0) {
|
|
1097
1168
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1101,6 +1172,16 @@ function renderToast(item) {
|
|
|
1101
1172
|
}
|
|
1102
1173
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1103
1174
|
const containers = {};
|
|
1175
|
+
// Inyecta el SVG filter gooey solo una vez
|
|
1176
|
+
if (!document.getElementById('sileo-gooey-svg')) {
|
|
1177
|
+
const div = document.createElement('div');
|
|
1178
|
+
div.id = 'sileo-gooey-svg';
|
|
1179
|
+
div.style.position = 'absolute';
|
|
1180
|
+
div.style.width = '0';
|
|
1181
|
+
div.style.height = '0';
|
|
1182
|
+
div.innerHTML = gooeySVG;
|
|
1183
|
+
document.body.appendChild(div);
|
|
1184
|
+
}
|
|
1104
1185
|
positions.forEach((pos) => {
|
|
1105
1186
|
const c = createContainer(pos, root, opts);
|
|
1106
1187
|
root.appendChild(c);
|
package/dist/notify.umd.js
CHANGED
|
@@ -1020,6 +1020,18 @@
|
|
|
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="8" 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 30 -14" result="goo" />
|
|
1028
|
+
<feComponentTransfer in="goo" result="thresholded">
|
|
1029
|
+
<feFuncA type="table" tableValues="0 1" />
|
|
1030
|
+
</feComponentTransfer>
|
|
1031
|
+
<feBlend in="SourceGraphic" in2="thresholded" mode="normal" />
|
|
1032
|
+
</filter>
|
|
1033
|
+
</svg>`;
|
|
1034
|
+
|
|
1023
1035
|
const POSITIONS = [
|
|
1024
1036
|
'top-left',
|
|
1025
1037
|
'top-center',
|
|
@@ -1052,6 +1064,8 @@
|
|
|
1052
1064
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1053
1065
|
}
|
|
1054
1066
|
}
|
|
1067
|
+
// Aplica el filtro gooey a los toasters
|
|
1068
|
+
c.style.filter = 'url(#sileo-gooey)';
|
|
1055
1069
|
return c;
|
|
1056
1070
|
}
|
|
1057
1071
|
function renderToast(item) {
|
|
@@ -1061,6 +1075,43 @@
|
|
|
1061
1075
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1062
1076
|
el.style.opacity = '0';
|
|
1063
1077
|
el.style.transform = 'translateY(-6px)';
|
|
1078
|
+
// Soporte visual para fill y roundness
|
|
1079
|
+
if (item.options.fill) {
|
|
1080
|
+
el.style.background = item.options.fill;
|
|
1081
|
+
}
|
|
1082
|
+
if (item.options.roundness) {
|
|
1083
|
+
el.style.borderRadius = item.options.roundness + 'px';
|
|
1084
|
+
el.style.setProperty('--sileo-roundness', item.options.roundness + 'px');
|
|
1085
|
+
}
|
|
1086
|
+
// Badge SVG animado (efecto Sileo)
|
|
1087
|
+
const badge = document.createElement('div');
|
|
1088
|
+
badge.className = 'sileo-toast-badge';
|
|
1089
|
+
badge.setAttribute('data-sileo-badge', '');
|
|
1090
|
+
// Icono SVG custom o por tipo
|
|
1091
|
+
if (item.options.icon) {
|
|
1092
|
+
if (typeof item.options.icon === 'string') {
|
|
1093
|
+
badge.innerHTML = item.options.icon;
|
|
1094
|
+
}
|
|
1095
|
+
else if (item.options.icon instanceof HTMLElement) {
|
|
1096
|
+
badge.appendChild(item.options.icon);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
else {
|
|
1100
|
+
// Icono por tipo (ejemplo simple, puedes mejorar SVGs)
|
|
1101
|
+
badge.innerHTML = {
|
|
1102
|
+
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>',
|
|
1103
|
+
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>',
|
|
1104
|
+
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>',
|
|
1105
|
+
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>',
|
|
1106
|
+
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>',
|
|
1107
|
+
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>',
|
|
1108
|
+
}[item.options.type || 'info'] || '';
|
|
1109
|
+
}
|
|
1110
|
+
// Aplica clases custom de styles.badge si existen
|
|
1111
|
+
if (item.options.styles && item.options.styles.badge) {
|
|
1112
|
+
badge.className += ' ' + item.options.styles.badge;
|
|
1113
|
+
}
|
|
1114
|
+
// Cuerpo del toast
|
|
1064
1115
|
const body = document.createElement('div');
|
|
1065
1116
|
body.style.display = 'flex';
|
|
1066
1117
|
body.style.flexDirection = 'column';
|
|
@@ -1068,18 +1119,28 @@
|
|
|
1068
1119
|
const header = document.createElement('div');
|
|
1069
1120
|
header.className = 'sileo-toast-header';
|
|
1070
1121
|
header.textContent = item.options.title || '';
|
|
1122
|
+
if (item.options.styles && item.options.styles.title) {
|
|
1123
|
+
header.className += ' ' + item.options.styles.title;
|
|
1124
|
+
}
|
|
1071
1125
|
body.appendChild(header);
|
|
1072
1126
|
if (item.options.description) {
|
|
1073
1127
|
const desc = document.createElement('div');
|
|
1074
1128
|
desc.className = 'sileo-toast-desc';
|
|
1075
1129
|
desc.textContent = item.options.description;
|
|
1130
|
+
if (item.options.styles && item.options.styles.description) {
|
|
1131
|
+
desc.className += ' ' + item.options.styles.description;
|
|
1132
|
+
}
|
|
1076
1133
|
body.appendChild(desc);
|
|
1077
1134
|
}
|
|
1135
|
+
el.appendChild(badge);
|
|
1078
1136
|
el.appendChild(body);
|
|
1079
1137
|
if (item.options.button) {
|
|
1080
1138
|
const btn = document.createElement('button');
|
|
1081
1139
|
btn.className = 'sileo-toast-btn';
|
|
1082
1140
|
btn.textContent = item.options.button.title;
|
|
1141
|
+
if (item.options.styles && item.options.styles.button) {
|
|
1142
|
+
btn.className += ' ' + item.options.styles.button;
|
|
1143
|
+
}
|
|
1083
1144
|
btn.addEventListener('click', (e) => {
|
|
1084
1145
|
e.stopPropagation();
|
|
1085
1146
|
try {
|
|
@@ -1098,6 +1159,16 @@
|
|
|
1098
1159
|
close.innerHTML = '×';
|
|
1099
1160
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1100
1161
|
el.appendChild(close);
|
|
1162
|
+
// Soporte para autopilot: expansión/colapso automático (simulado)
|
|
1163
|
+
if (item.options.autopilot !== false) {
|
|
1164
|
+
setTimeout(() => {
|
|
1165
|
+
el.style.transform = 'scale(1.03)';
|
|
1166
|
+
el.style.transition = 'transform 0.18s cubic-bezier(.22,1,.36,1)';
|
|
1167
|
+
setTimeout(() => {
|
|
1168
|
+
el.style.transform = 'scale(1)';
|
|
1169
|
+
}, 180);
|
|
1170
|
+
}, 120);
|
|
1171
|
+
}
|
|
1101
1172
|
if (typeof item.options.duration === 'number') {
|
|
1102
1173
|
if (item.options.duration > 0) {
|
|
1103
1174
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1107,6 +1178,16 @@
|
|
|
1107
1178
|
}
|
|
1108
1179
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1109
1180
|
const containers = {};
|
|
1181
|
+
// Inyecta el SVG filter gooey solo una vez
|
|
1182
|
+
if (!document.getElementById('sileo-gooey-svg')) {
|
|
1183
|
+
const div = document.createElement('div');
|
|
1184
|
+
div.id = 'sileo-gooey-svg';
|
|
1185
|
+
div.style.position = 'absolute';
|
|
1186
|
+
div.style.width = '0';
|
|
1187
|
+
div.style.height = '0';
|
|
1188
|
+
div.innerHTML = gooeySVG;
|
|
1189
|
+
document.body.appendChild(div);
|
|
1190
|
+
}
|
|
1110
1191
|
positions.forEach((pos) => {
|
|
1111
1192
|
const c = createContainer(pos, root, opts);
|
|
1112
1193
|
root.appendChild(c);
|
package/dist/styles.css
CHANGED
|
@@ -43,13 +43,20 @@
|
|
|
43
43
|
background: var(--sileo-bg);
|
|
44
44
|
color: var(--sileo-foreground);
|
|
45
45
|
padding: 0.75rem 0.875rem;
|
|
46
|
-
border-radius:
|
|
47
|
-
|
|
46
|
+
border-radius: var(--sileo-roundness, 1rem);
|
|
47
|
+
/* Multiple layered shadows for depth (outer, mid, subtle glow) */
|
|
48
|
+
box-shadow:
|
|
49
|
+
0 0.75rem 1.6rem rgba(2,6,23,0.55),
|
|
50
|
+
0 0.25rem 0.6rem rgba(2,6,23,0.35),
|
|
51
|
+
inset 0 0.25rem 0.6rem rgba(255,255,255,0.02);
|
|
48
52
|
display: flex;
|
|
49
53
|
gap: 0.5rem;
|
|
50
54
|
align-items: center;
|
|
51
55
|
position: relative;
|
|
52
56
|
overflow: hidden;
|
|
57
|
+
/* Efecto gooey visual */
|
|
58
|
+
backdrop-filter: blur(6px) saturate(1.2);
|
|
59
|
+
filter: url(#sileo-gooey);
|
|
53
60
|
}
|
|
54
61
|
|
|
55
62
|
.sileo-toast[data-type="success"]{ border-left: 0.25rem solid var(--sileo-success); }
|
|
@@ -58,6 +65,50 @@
|
|
|
58
65
|
.sileo-toast[data-type="warning"]{ border-left: 0.25rem solid var(--sileo-warning); }
|
|
59
66
|
|
|
60
67
|
.sileo-toast-header{ font-weight: 600; font-size: 0.875rem; }
|
|
68
|
+
|
|
69
|
+
/* Badge circular con blur y animación */
|
|
70
|
+
.sileo-toast-badge {
|
|
71
|
+
width: 2.25rem;
|
|
72
|
+
height: 2.25rem;
|
|
73
|
+
min-width: 2.25rem;
|
|
74
|
+
min-height: 2.25rem;
|
|
75
|
+
border-radius: 50%;
|
|
76
|
+
background: rgba(255,255,255,0.08);
|
|
77
|
+
display: flex;
|
|
78
|
+
align-items: center;
|
|
79
|
+
justify-content: center;
|
|
80
|
+
margin-right: 0.5rem;
|
|
81
|
+
box-shadow: 0 0 0.5rem 0.08rem rgba(0,0,0,0.12), 0 0 0.25rem rgba(16,24,40,0.2) inset;
|
|
82
|
+
backdrop-filter: blur(2.5px);
|
|
83
|
+
animation: sileo-badge-pop 0.38s cubic-bezier(.22,1,.36,1) both;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/* Left accent / green rim similar to Sileo */
|
|
87
|
+
.sileo-toast::before{
|
|
88
|
+
content: '';
|
|
89
|
+
position: absolute;
|
|
90
|
+
left: 0;
|
|
91
|
+
top: 8%;
|
|
92
|
+
bottom: 8%;
|
|
93
|
+
width: 0.6rem;
|
|
94
|
+
border-radius: 999px;
|
|
95
|
+
background: linear-gradient(180deg, rgba(34,197,94,1) 0%, rgba(6,95,70,1) 100%);
|
|
96
|
+
box-shadow: 0 6px 18px rgba(16,185,129,0.18);
|
|
97
|
+
transform: translateX(-8%);
|
|
98
|
+
pointer-events: none;
|
|
99
|
+
mix-blend-mode: screen;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* Slight top badge overlap to create the 'pill' effect */
|
|
103
|
+
.sileo-toast[data-type="success"] .sileo-toast-badge{
|
|
104
|
+
box-shadow: 0 6px 18px rgba(16,185,129,0.12), 0 0 0.25rem rgba(0,0,0,0.18) inset;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@keyframes sileo-badge-pop {
|
|
108
|
+
0% { transform: scale(0.7); opacity: 0; }
|
|
109
|
+
60% { transform: scale(1.15); opacity: 1; }
|
|
110
|
+
100% { transform: scale(1); opacity: 1; }
|
|
111
|
+
}
|
|
61
112
|
.sileo-toast-desc{ font-size: 0.8125rem; opacity: 0.85; margin-top: 0.25rem; }
|
|
62
113
|
.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
114
|
.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.6/dist/styles.css">
|
|
12
|
+
<script src="https://unpkg.com/@samline/notify@0.2.6/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.6/dist/styles.css">
|
|
44
|
+
<script src="https://unpkg.com/@samline/notify@0.2.6/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.6/dist/notify.umd.js"></script>
|
|
59
|
+
<link rel="stylesheet" href="https://unpkg.com/@samline/notify@0.2.6/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.6/dist/styles.css">
|
|
182
|
+
<script src="https://unpkg.com/@samline/notify@0.2.6/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
|