@samline/notify 0.2.6 → 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 -81
- package/dist/index.esm.js +0 -81
- package/dist/notify.umd.js +0 -81
- package/dist/styles.css +2 -53
- 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,18 +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="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
|
-
|
|
1033
1021
|
const POSITIONS = [
|
|
1034
1022
|
'top-left',
|
|
1035
1023
|
'top-center',
|
|
@@ -1062,8 +1050,6 @@ function createContainer(position, root, opts) {
|
|
|
1062
1050
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1063
1051
|
}
|
|
1064
1052
|
}
|
|
1065
|
-
// Aplica el filtro gooey a los toasters
|
|
1066
|
-
c.style.filter = 'url(#sileo-gooey)';
|
|
1067
1053
|
return c;
|
|
1068
1054
|
}
|
|
1069
1055
|
function renderToast(item) {
|
|
@@ -1073,43 +1059,6 @@ function renderToast(item) {
|
|
|
1073
1059
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1074
1060
|
el.style.opacity = '0';
|
|
1075
1061
|
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
|
|
1113
1062
|
const body = document.createElement('div');
|
|
1114
1063
|
body.style.display = 'flex';
|
|
1115
1064
|
body.style.flexDirection = 'column';
|
|
@@ -1117,28 +1066,18 @@ function renderToast(item) {
|
|
|
1117
1066
|
const header = document.createElement('div');
|
|
1118
1067
|
header.className = 'sileo-toast-header';
|
|
1119
1068
|
header.textContent = item.options.title || '';
|
|
1120
|
-
if (item.options.styles && item.options.styles.title) {
|
|
1121
|
-
header.className += ' ' + item.options.styles.title;
|
|
1122
|
-
}
|
|
1123
1069
|
body.appendChild(header);
|
|
1124
1070
|
if (item.options.description) {
|
|
1125
1071
|
const desc = document.createElement('div');
|
|
1126
1072
|
desc.className = 'sileo-toast-desc';
|
|
1127
1073
|
desc.textContent = item.options.description;
|
|
1128
|
-
if (item.options.styles && item.options.styles.description) {
|
|
1129
|
-
desc.className += ' ' + item.options.styles.description;
|
|
1130
|
-
}
|
|
1131
1074
|
body.appendChild(desc);
|
|
1132
1075
|
}
|
|
1133
|
-
el.appendChild(badge);
|
|
1134
1076
|
el.appendChild(body);
|
|
1135
1077
|
if (item.options.button) {
|
|
1136
1078
|
const btn = document.createElement('button');
|
|
1137
1079
|
btn.className = 'sileo-toast-btn';
|
|
1138
1080
|
btn.textContent = item.options.button.title;
|
|
1139
|
-
if (item.options.styles && item.options.styles.button) {
|
|
1140
|
-
btn.className += ' ' + item.options.styles.button;
|
|
1141
|
-
}
|
|
1142
1081
|
btn.addEventListener('click', (e) => {
|
|
1143
1082
|
e.stopPropagation();
|
|
1144
1083
|
try {
|
|
@@ -1157,16 +1096,6 @@ function renderToast(item) {
|
|
|
1157
1096
|
close.innerHTML = '×';
|
|
1158
1097
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1159
1098
|
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
|
-
}
|
|
1170
1099
|
if (typeof item.options.duration === 'number') {
|
|
1171
1100
|
if (item.options.duration > 0) {
|
|
1172
1101
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1176,16 +1105,6 @@ function renderToast(item) {
|
|
|
1176
1105
|
}
|
|
1177
1106
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1178
1107
|
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
|
-
}
|
|
1189
1108
|
positions.forEach((pos) => {
|
|
1190
1109
|
const c = createContainer(pos, root, opts);
|
|
1191
1110
|
root.appendChild(c);
|
package/dist/index.esm.js
CHANGED
|
@@ -1014,18 +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="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
|
-
|
|
1029
1017
|
const POSITIONS = [
|
|
1030
1018
|
'top-left',
|
|
1031
1019
|
'top-center',
|
|
@@ -1058,8 +1046,6 @@ function createContainer(position, root, opts) {
|
|
|
1058
1046
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1059
1047
|
}
|
|
1060
1048
|
}
|
|
1061
|
-
// Aplica el filtro gooey a los toasters
|
|
1062
|
-
c.style.filter = 'url(#sileo-gooey)';
|
|
1063
1049
|
return c;
|
|
1064
1050
|
}
|
|
1065
1051
|
function renderToast(item) {
|
|
@@ -1069,43 +1055,6 @@ function renderToast(item) {
|
|
|
1069
1055
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1070
1056
|
el.style.opacity = '0';
|
|
1071
1057
|
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
|
|
1109
1058
|
const body = document.createElement('div');
|
|
1110
1059
|
body.style.display = 'flex';
|
|
1111
1060
|
body.style.flexDirection = 'column';
|
|
@@ -1113,28 +1062,18 @@ function renderToast(item) {
|
|
|
1113
1062
|
const header = document.createElement('div');
|
|
1114
1063
|
header.className = 'sileo-toast-header';
|
|
1115
1064
|
header.textContent = item.options.title || '';
|
|
1116
|
-
if (item.options.styles && item.options.styles.title) {
|
|
1117
|
-
header.className += ' ' + item.options.styles.title;
|
|
1118
|
-
}
|
|
1119
1065
|
body.appendChild(header);
|
|
1120
1066
|
if (item.options.description) {
|
|
1121
1067
|
const desc = document.createElement('div');
|
|
1122
1068
|
desc.className = 'sileo-toast-desc';
|
|
1123
1069
|
desc.textContent = item.options.description;
|
|
1124
|
-
if (item.options.styles && item.options.styles.description) {
|
|
1125
|
-
desc.className += ' ' + item.options.styles.description;
|
|
1126
|
-
}
|
|
1127
1070
|
body.appendChild(desc);
|
|
1128
1071
|
}
|
|
1129
|
-
el.appendChild(badge);
|
|
1130
1072
|
el.appendChild(body);
|
|
1131
1073
|
if (item.options.button) {
|
|
1132
1074
|
const btn = document.createElement('button');
|
|
1133
1075
|
btn.className = 'sileo-toast-btn';
|
|
1134
1076
|
btn.textContent = item.options.button.title;
|
|
1135
|
-
if (item.options.styles && item.options.styles.button) {
|
|
1136
|
-
btn.className += ' ' + item.options.styles.button;
|
|
1137
|
-
}
|
|
1138
1077
|
btn.addEventListener('click', (e) => {
|
|
1139
1078
|
e.stopPropagation();
|
|
1140
1079
|
try {
|
|
@@ -1153,16 +1092,6 @@ function renderToast(item) {
|
|
|
1153
1092
|
close.innerHTML = '×';
|
|
1154
1093
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1155
1094
|
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
|
-
}
|
|
1166
1095
|
if (typeof item.options.duration === 'number') {
|
|
1167
1096
|
if (item.options.duration > 0) {
|
|
1168
1097
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1172,16 +1101,6 @@ function renderToast(item) {
|
|
|
1172
1101
|
}
|
|
1173
1102
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1174
1103
|
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
|
-
}
|
|
1185
1104
|
positions.forEach((pos) => {
|
|
1186
1105
|
const c = createContainer(pos, root, opts);
|
|
1187
1106
|
root.appendChild(c);
|
package/dist/notify.umd.js
CHANGED
|
@@ -1020,18 +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="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
|
-
|
|
1035
1023
|
const POSITIONS = [
|
|
1036
1024
|
'top-left',
|
|
1037
1025
|
'top-center',
|
|
@@ -1064,8 +1052,6 @@
|
|
|
1064
1052
|
c.style.marginLeft = `${opts.offset.left}px`;
|
|
1065
1053
|
}
|
|
1066
1054
|
}
|
|
1067
|
-
// Aplica el filtro gooey a los toasters
|
|
1068
|
-
c.style.filter = 'url(#sileo-gooey)';
|
|
1069
1055
|
return c;
|
|
1070
1056
|
}
|
|
1071
1057
|
function renderToast(item) {
|
|
@@ -1075,43 +1061,6 @@
|
|
|
1075
1061
|
el.setAttribute('data-type', item.options.type || 'info');
|
|
1076
1062
|
el.style.opacity = '0';
|
|
1077
1063
|
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
|
|
1115
1064
|
const body = document.createElement('div');
|
|
1116
1065
|
body.style.display = 'flex';
|
|
1117
1066
|
body.style.flexDirection = 'column';
|
|
@@ -1119,28 +1068,18 @@
|
|
|
1119
1068
|
const header = document.createElement('div');
|
|
1120
1069
|
header.className = 'sileo-toast-header';
|
|
1121
1070
|
header.textContent = item.options.title || '';
|
|
1122
|
-
if (item.options.styles && item.options.styles.title) {
|
|
1123
|
-
header.className += ' ' + item.options.styles.title;
|
|
1124
|
-
}
|
|
1125
1071
|
body.appendChild(header);
|
|
1126
1072
|
if (item.options.description) {
|
|
1127
1073
|
const desc = document.createElement('div');
|
|
1128
1074
|
desc.className = 'sileo-toast-desc';
|
|
1129
1075
|
desc.textContent = item.options.description;
|
|
1130
|
-
if (item.options.styles && item.options.styles.description) {
|
|
1131
|
-
desc.className += ' ' + item.options.styles.description;
|
|
1132
|
-
}
|
|
1133
1076
|
body.appendChild(desc);
|
|
1134
1077
|
}
|
|
1135
|
-
el.appendChild(badge);
|
|
1136
1078
|
el.appendChild(body);
|
|
1137
1079
|
if (item.options.button) {
|
|
1138
1080
|
const btn = document.createElement('button');
|
|
1139
1081
|
btn.className = 'sileo-toast-btn';
|
|
1140
1082
|
btn.textContent = item.options.button.title;
|
|
1141
|
-
if (item.options.styles && item.options.styles.button) {
|
|
1142
|
-
btn.className += ' ' + item.options.styles.button;
|
|
1143
|
-
}
|
|
1144
1083
|
btn.addEventListener('click', (e) => {
|
|
1145
1084
|
e.stopPropagation();
|
|
1146
1085
|
try {
|
|
@@ -1159,16 +1098,6 @@
|
|
|
1159
1098
|
close.innerHTML = '×';
|
|
1160
1099
|
close.addEventListener('click', () => sileo.dismiss(item.id));
|
|
1161
1100
|
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
|
-
}
|
|
1172
1101
|
if (typeof item.options.duration === 'number') {
|
|
1173
1102
|
if (item.options.duration > 0) {
|
|
1174
1103
|
setTimeout(() => sileo.dismiss(item.id), item.options.duration);
|
|
@@ -1178,16 +1107,6 @@
|
|
|
1178
1107
|
}
|
|
1179
1108
|
function initToasters(root = document.body, positions = ['top-right'], opts) {
|
|
1180
1109
|
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
|
-
}
|
|
1191
1110
|
positions.forEach((pos) => {
|
|
1192
1111
|
const c = createContainer(pos, root, opts);
|
|
1193
1112
|
root.appendChild(c);
|
package/dist/styles.css
CHANGED
|
@@ -43,20 +43,13 @@
|
|
|
43
43
|
background: var(--sileo-bg);
|
|
44
44
|
color: var(--sileo-foreground);
|
|
45
45
|
padding: 0.75rem 0.875rem;
|
|
46
|
-
border-radius:
|
|
47
|
-
|
|
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);
|
|
46
|
+
border-radius: 0.625rem;
|
|
47
|
+
box-shadow: 0 0.375rem 1.125rem rgba(2,6,23,0.6);
|
|
52
48
|
display: flex;
|
|
53
49
|
gap: 0.5rem;
|
|
54
50
|
align-items: center;
|
|
55
51
|
position: relative;
|
|
56
52
|
overflow: hidden;
|
|
57
|
-
/* Efecto gooey visual */
|
|
58
|
-
backdrop-filter: blur(6px) saturate(1.2);
|
|
59
|
-
filter: url(#sileo-gooey);
|
|
60
53
|
}
|
|
61
54
|
|
|
62
55
|
.sileo-toast[data-type="success"]{ border-left: 0.25rem solid var(--sileo-success); }
|
|
@@ -65,50 +58,6 @@
|
|
|
65
58
|
.sileo-toast[data-type="warning"]{ border-left: 0.25rem solid var(--sileo-warning); }
|
|
66
59
|
|
|
67
60
|
.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
|
-
}
|
|
112
61
|
.sileo-toast-desc{ font-size: 0.8125rem; opacity: 0.85; margin-top: 0.25rem; }
|
|
113
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; }
|
|
114
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
|