@skerbis/nativecss 0.0.0-stage → 1.2.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/CHANGELOG.md +61 -0
- package/LICENSE +28 -0
- package/README.md +145 -2
- package/dist/base.css +225 -0
- package/dist/browser-fixes.css +32 -0
- package/dist/colors.css +288 -0
- package/dist/components/accordion-split.css +269 -0
- package/dist/components/alert.css +179 -0
- package/dist/components/app-shell.css +266 -0
- package/dist/components/audio-player.css +697 -0
- package/dist/components/audio.css +35 -0
- package/dist/components/aurora.css +132 -0
- package/dist/components/avatar.css +102 -0
- package/dist/components/back-to-top.css +120 -0
- package/dist/components/backdrop.css +94 -0
- package/dist/components/badge.css +95 -0
- package/dist/components/breadcrumb.css +58 -0
- package/dist/components/card.css +721 -0
- package/dist/components/code-block.css +234 -0
- package/dist/components/combobox.css +103 -0
- package/dist/components/command-palette.css +351 -0
- package/dist/components/comments.css +243 -0
- package/dist/components/compare.css +218 -0
- package/dist/components/count-up.css +140 -0
- package/dist/components/countdown.css +74 -0
- package/dist/components/cover.css +45 -0
- package/dist/components/curtain.css +116 -0
- package/dist/components/dialog-close.css +44 -0
- package/dist/components/disclosure.css +37 -0
- package/dist/components/downloads.css +47 -0
- package/dist/components/dropdown.css +260 -0
- package/dist/components/dropzone.css +181 -0
- package/dist/components/effects.css +236 -0
- package/dist/components/empty-state.css +74 -0
- package/dist/components/events.css +165 -0
- package/dist/components/expand-panels.css +220 -0
- package/dist/components/filter.css +179 -0
- package/dist/components/floating-label.css +69 -0
- package/dist/components/footer.css +56 -0
- package/dist/components/hero.css +139 -0
- package/dist/components/hovercard.css +146 -0
- package/dist/components/input-group.css +67 -0
- package/dist/components/kbd.css +44 -0
- package/dist/components/leaders.css +99 -0
- package/dist/components/lightbox.css +165 -0
- package/dist/components/lists.css +221 -0
- package/dist/components/livesearch.css +106 -0
- package/dist/components/map.css +245 -0
- package/dist/components/marginnote.css +109 -0
- package/dist/components/marquee.css +119 -0
- package/dist/components/modal.css +385 -0
- package/dist/components/morph.css +317 -0
- package/dist/components/nav-drilldown.css +190 -0
- package/dist/components/nav-priority.css +157 -0
- package/dist/components/nav.css +600 -0
- package/dist/components/notification.css +290 -0
- package/dist/components/off-canvas.css +107 -0
- package/dist/components/overlay.css +122 -0
- package/dist/components/pagination.css +139 -0
- package/dist/components/pill-group.css +143 -0
- package/dist/components/placeholder.css +28 -0
- package/dist/components/preferences-fonts.css +65 -0
- package/dist/components/preferences.css +283 -0
- package/dist/components/pricing.css +220 -0
- package/dist/components/rating.css +121 -0
- package/dist/components/reveal-pin.css +165 -0
- package/dist/components/roadmap.css +173 -0
- package/dist/components/scroll-frames.css +97 -0
- package/dist/components/scroll-horizontal.css +141 -0
- package/dist/components/scroll-progress.css +63 -0
- package/dist/components/scroll-stack.css +363 -0
- package/dist/components/scroll-video.css +172 -0
- package/dist/components/scrolly.css +190 -0
- package/dist/components/search.css +52 -0
- package/dist/components/segmented.css +209 -0
- package/dist/components/select.css +186 -0
- package/dist/components/slideshow.css +441 -0
- package/dist/components/sortable.css +186 -0
- package/dist/components/sparkline.css +50 -0
- package/dist/components/spinner.css +50 -0
- package/dist/components/split.css +85 -0
- package/dist/components/spotlight.css +111 -0
- package/dist/components/stat.css +82 -0
- package/dist/components/stepper.css +217 -0
- package/dist/components/subnav.css +151 -0
- package/dist/components/table-sort.css +111 -0
- package/dist/components/tabs.css +304 -0
- package/dist/components/tag.css +130 -0
- package/dist/components/testimonial.css +188 -0
- package/dist/components/text-reveal.css +141 -0
- package/dist/components/theme-toggle.css +62 -0
- package/dist/components/tile.css +53 -0
- package/dist/components/timeline.css +211 -0
- package/dist/components/toolbar.css +139 -0
- package/dist/components/tooltip.css +89 -0
- package/dist/components/topbar.css +92 -0
- package/dist/components/video-bg.css +176 -0
- package/dist/components/video-card.css +145 -0
- package/dist/components/video-float.css +142 -0
- package/dist/components/video-player.css +1116 -0
- package/dist/components/video-text.css +91 -0
- package/dist/components/video.css +65 -0
- package/dist/fonts/README.md +29 -0
- package/dist/fonts/atkinson-hyperlegible-next/OFL.txt +93 -0
- package/dist/fonts/atkinson-hyperlegible-next/atkinson-hyperlegible-next.woff2 +0 -0
- package/dist/fonts/lexend/OFL.txt +93 -0
- package/dist/fonts/lexend/lexend.woff2 +0 -0
- package/dist/fonts/opendyslexic/OFL.txt +94 -0
- package/dist/fonts/opendyslexic/OpenDyslexic-Bold.woff2 +0 -0
- package/dist/fonts/opendyslexic/OpenDyslexic-Regular.woff2 +0 -0
- package/dist/helpers/a11y.css +71 -0
- package/dist/helpers/animations.css +206 -0
- package/dist/helpers/elevation.css +87 -0
- package/dist/helpers/float.css +135 -0
- package/dist/helpers/forms.css +503 -0
- package/dist/helpers/icons.css +130 -0
- package/dist/helpers/layout.css +549 -0
- package/dist/helpers/media.css +77 -0
- package/dist/helpers/reveal.css +172 -0
- package/dist/helpers/scroll-shadow.css +129 -0
- package/dist/helpers/scroll.css +163 -0
- package/dist/helpers/surfaces.css +87 -0
- package/dist/helpers/tables.css +85 -0
- package/dist/helpers/typography.css +347 -0
- package/dist/helpers/visibility.css +134 -0
- package/dist/integrations/fontawesome-font-display-fix.css +67 -0
- package/dist/integrations/webawesome-bridge.css +195 -0
- package/dist/js/audio-player.js +942 -0
- package/dist/js/backdrop.js +119 -0
- package/dist/js/code-block.js +238 -0
- package/dist/js/combobox.js +382 -0
- package/dist/js/command-fallback.js +35 -0
- package/dist/js/command-palette.js +477 -0
- package/dist/js/compare.js +73 -0
- package/dist/js/content-observer.js +82 -0
- package/dist/js/count-up.js +150 -0
- package/dist/js/countdown.js +185 -0
- package/dist/js/dialog-light-dismiss.js +123 -0
- package/dist/js/dismiss.js +144 -0
- package/dist/js/downloads.js +181 -0
- package/dist/js/dropdown.js +300 -0
- package/dist/js/dropzone.js +304 -0
- package/dist/js/events.js +501 -0
- package/dist/js/filter.js +177 -0
- package/dist/js/hero-video-motion.js +37 -0
- package/dist/js/hide-on-scroll-fallback.js +102 -0
- package/dist/js/hovercard.js +228 -0
- package/dist/js/icon.js +166 -0
- package/dist/js/ics.js +290 -0
- package/dist/js/lightbox.js +144 -0
- package/dist/js/livesearch.js +253 -0
- package/dist/js/map.js +625 -0
- package/dist/js/marquee.js +108 -0
- package/dist/js/modal-router.js +298 -0
- package/dist/js/nav-drilldown.js +250 -0
- package/dist/js/nav-priority.js +221 -0
- package/dist/js/nav.js +242 -0
- package/dist/js/ncss-container.js +117 -0
- package/dist/js/notification.js +372 -0
- package/dist/js/page-transitions-quiet.js +44 -0
- package/dist/js/preferences-early.js +51 -0
- package/dist/js/preferences.js +346 -0
- package/dist/js/reveal.js +79 -0
- package/dist/js/scroll-frames.js +284 -0
- package/dist/js/scroll-horizontal.js +121 -0
- package/dist/js/scroll-stack-fallback.js +250 -0
- package/dist/js/scroll-video.js +332 -0
- package/dist/js/scrolly.js +109 -0
- package/dist/js/slideshow.js +416 -0
- package/dist/js/sortable.js +530 -0
- package/dist/js/sparkline.js +199 -0
- package/dist/js/spotlight.js +104 -0
- package/dist/js/subnav.js +163 -0
- package/dist/js/table-sort.js +312 -0
- package/dist/js/tabs.js +243 -0
- package/dist/js/text-reveal.js +108 -0
- package/dist/js/theme-toggle-early.js +28 -0
- package/dist/js/theme-toggle.js +135 -0
- package/dist/js/toolbar.js +130 -0
- package/dist/js/tooltip.js +214 -0
- package/dist/js/video-bg.js +193 -0
- package/dist/js/video-card.js +80 -0
- package/dist/js/video-float.js +119 -0
- package/dist/js/video-player.js +1267 -0
- package/dist/js/view-transitions.js +118 -0
- package/dist/js/wa-close-on-scroll.js +56 -0
- package/dist/ncss.css +165 -0
- package/dist/page-transitions.css +150 -0
- package/dist/reset.css +196 -0
- package/dist/theme.css +112 -0
- package/dist/tokens.css +238 -0
- package/package.json +52 -4
|
@@ -0,0 +1,372 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ncss - Benachrichtigungen / Toasts: <ncss-toast-region> (Light-DOM-Custom-Element ohne
|
|
3
|
+
* Shadow Root) + kleine Script-API (siehe components/notification.css für Markup/Optik).
|
|
4
|
+
*
|
|
5
|
+
* API (global, ohne Modul-System nutzbar):
|
|
6
|
+
* ncss.notify("Gespeichert");
|
|
7
|
+
* ncss.notify("Upload fehlgeschlagen", { status: "danger" });
|
|
8
|
+
* var n = ncss.notify({ title: "Kopiert", message: "Link in der Zwischenablage",
|
|
9
|
+
* status: "success", position: "bottom-center", stack: true });
|
|
10
|
+
* n.close(); // { element, close() }
|
|
11
|
+
* ncss.notifyCloseAll();
|
|
12
|
+
* Alternativ ohne direkte Abhängigkeit vom globalen Objekt:
|
|
13
|
+
* document.dispatchEvent(new CustomEvent("ncss-notify", { detail: { message: "..." } }));
|
|
14
|
+
* Deklarativ: <button type="button" data-ncss-notify="Gespeichert" data-status="success"
|
|
15
|
+
* data-title="..." data-timeout="8000" data-position="top-center" data-stack>
|
|
16
|
+
*
|
|
17
|
+
* Optionen: message (Text - wird als TEXT eingefügt, nie als HTML; für eigenes Markup
|
|
18
|
+
* einen DOM-Knoten übergeben), title, status (brand | success | warning | danger),
|
|
19
|
+
* timeout (ms, 0 = bleibt stehen; Default 5000, bei danger 0 - eine Fehlermeldung soll
|
|
20
|
+
* nicht verschwinden, bevor sie gelesen ist), position (top-start | top-center | top-end |
|
|
21
|
+
* bottom-start | bottom-center | bottom-end, Default bottom-end), stack (Sonner-Stapel für
|
|
22
|
+
* die Region dieser Position), closeLabel.
|
|
23
|
+
*
|
|
24
|
+
* Verhalten:
|
|
25
|
+
* - Region = aria-live="polite" (existiert, bevor die erste Meldung eingefügt wird -
|
|
26
|
+
* sonst sagen Screenreader sie nicht an); danger/warning zusätzlich role="alert".
|
|
27
|
+
* - Timer pausieren für ALLE Meldungen der Region, solange Zeiger oder Fokus darin sind
|
|
28
|
+
* und solange der Tab im Hintergrund ist - Restzeit läuft danach weiter, kein Neustart.
|
|
29
|
+
* - Region ist popover="manual" (Top Layer): Meldungen erscheinen auch über einem
|
|
30
|
+
* offenen modalen <dialog>.
|
|
31
|
+
* - Meldungen, die schon im Markup stehen (serverseitig), bekommen beim Start Schließen-
|
|
32
|
+
* Button und Timer (data-timeout, Default 5000; data-timeout="0" = stehen lassen).
|
|
33
|
+
* Events (bubbeln, an der Meldung): ncss-notification-close
|
|
34
|
+
*
|
|
35
|
+
* Abhängigkeiten: keine anderen ncss-Scripts. Ohne customElements wird nichts registriert
|
|
36
|
+
* (ncss.notify fehlt dann, Markup-Meldungen bleiben statisch sichtbar).
|
|
37
|
+
*/
|
|
38
|
+
(function () {
|
|
39
|
+
"use strict";
|
|
40
|
+
|
|
41
|
+
if (!window.customElements || customElements.get("ncss-toast-region")) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var TEXTS = {
|
|
46
|
+
de: { close: "Meldung schließen" },
|
|
47
|
+
en: { close: "Dismiss notification" }
|
|
48
|
+
};
|
|
49
|
+
var lang = (document.documentElement.getAttribute("lang") || "de").slice(0, 2) === "en" ? "en" : "de";
|
|
50
|
+
var POSITIONS = ["top-start", "top-center", "top-end", "bottom-start", "bottom-center", "bottom-end"];
|
|
51
|
+
var hasPopover = HTMLElement.prototype.hasOwnProperty("popover");
|
|
52
|
+
|
|
53
|
+
function isBottom(region) {
|
|
54
|
+
return (region.getAttribute("position") || "top-end").indexOf("bottom") === 0;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// --- eine Meldung -----------------------------------------------------------------------
|
|
58
|
+
function enhance(msg, timeout, closeLabel) {
|
|
59
|
+
if (msg._ncssClose) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
if (!msg.querySelector(".ncss-notification-close")) {
|
|
63
|
+
var btn = document.createElement("button");
|
|
64
|
+
btn.type = "button";
|
|
65
|
+
btn.className = "ncss-notification-close";
|
|
66
|
+
btn.setAttribute("aria-label", closeLabel || TEXTS[lang].close);
|
|
67
|
+
msg.appendChild(btn);
|
|
68
|
+
}
|
|
69
|
+
if (!msg.querySelector(".ncss-notification-body")) {
|
|
70
|
+
// Markup-Meldung ohne Body-Wrapper: Inhalt einpacken, damit das Grid (Punkt | Text |
|
|
71
|
+
// Schließen) stimmt.
|
|
72
|
+
var body = document.createElement("div");
|
|
73
|
+
body.className = "ncss-notification-body";
|
|
74
|
+
Array.prototype.slice.call(msg.childNodes).forEach(function (node) {
|
|
75
|
+
if (!(node.nodeType === 1 && node.classList.contains("ncss-notification-close"))) {
|
|
76
|
+
body.appendChild(node);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
msg.insertBefore(body, msg.firstChild);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
var timer = 0;
|
|
83
|
+
var started = 0;
|
|
84
|
+
msg._ncssRemaining = timeout;
|
|
85
|
+
msg._ncssStart = function () {
|
|
86
|
+
if (!msg._ncssRemaining || msg._ncssClosed) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
clearTimeout(timer);
|
|
90
|
+
started = Date.now();
|
|
91
|
+
timer = setTimeout(function () { msg._ncssClose(); }, msg._ncssRemaining);
|
|
92
|
+
};
|
|
93
|
+
msg._ncssPause = function () {
|
|
94
|
+
if (!timer) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
clearTimeout(timer);
|
|
98
|
+
timer = 0;
|
|
99
|
+
msg._ncssRemaining = Math.max(500, msg._ncssRemaining - (Date.now() - started));
|
|
100
|
+
};
|
|
101
|
+
msg._ncssClose = function () {
|
|
102
|
+
if (msg._ncssClosed) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
msg._ncssClosed = true;
|
|
106
|
+
clearTimeout(timer);
|
|
107
|
+
var region = msg.parentElement;
|
|
108
|
+
// Fokus lag im Schließen-Button: nicht ins Leere fallen lassen
|
|
109
|
+
var hadFocus = msg.contains(document.activeElement);
|
|
110
|
+
msg.dispatchEvent(new CustomEvent("ncss-notification-close", { bubbles: true }));
|
|
111
|
+
msg.classList.add("ncss-notification--leaving");
|
|
112
|
+
var done = function () {
|
|
113
|
+
if (msg.isConnected) {
|
|
114
|
+
msg.remove();
|
|
115
|
+
}
|
|
116
|
+
if (hadFocus && region) {
|
|
117
|
+
var next = region.querySelector(".ncss-notification:not(.ncss-notification--leaving) .ncss-notification-close");
|
|
118
|
+
if (next) {
|
|
119
|
+
next.focus();
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
var dur = parseFloat(getComputedStyle(msg).transitionDuration) || 0;
|
|
124
|
+
setTimeout(done, Math.min(dur * 1000, 600) + 30);
|
|
125
|
+
if (region && region._ncssLayout) {
|
|
126
|
+
region._ncssLayout();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
msg.addEventListener("click", function (event) {
|
|
130
|
+
if (event.target.closest(".ncss-notification-close")) {
|
|
131
|
+
msg._ncssClose();
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// --- Region ---------------------------------------------------------------------------
|
|
137
|
+
customElements.define(
|
|
138
|
+
"ncss-toast-region",
|
|
139
|
+
class extends HTMLElement {
|
|
140
|
+
connectedCallback() {
|
|
141
|
+
if (this._ready) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
this._ready = true;
|
|
145
|
+
var self = this;
|
|
146
|
+
this._paused = false;
|
|
147
|
+
if (!this.hasAttribute("aria-live")) {
|
|
148
|
+
this.setAttribute("aria-live", "polite");
|
|
149
|
+
}
|
|
150
|
+
this.setAttribute("aria-relevant", "additions");
|
|
151
|
+
if (!this.hasAttribute("aria-label")) {
|
|
152
|
+
this.setAttribute("aria-label", lang === "en" ? "Notifications" : "Benachrichtigungen");
|
|
153
|
+
}
|
|
154
|
+
this.setAttribute("role", "region");
|
|
155
|
+
if (hasPopover && !this.hasAttribute("popover")) {
|
|
156
|
+
this.setAttribute("popover", "manual");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
this._ncssLayout = this._layout.bind(this);
|
|
160
|
+
this._mo = new MutationObserver(function () {
|
|
161
|
+
self._sync();
|
|
162
|
+
});
|
|
163
|
+
this._mo.observe(this, { childList: true });
|
|
164
|
+
|
|
165
|
+
var pause = function () {
|
|
166
|
+
if (self._paused) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
self._paused = true;
|
|
170
|
+
self._messages().forEach(function (m) { m._ncssPause(); });
|
|
171
|
+
};
|
|
172
|
+
var resume = function () {
|
|
173
|
+
if (self.matches(":hover") || self.contains(document.activeElement) || document.hidden) {
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
self._paused = false;
|
|
177
|
+
self._messages().forEach(function (m) { m._ncssStart(); });
|
|
178
|
+
};
|
|
179
|
+
this.addEventListener("pointerenter", pause);
|
|
180
|
+
this.addEventListener("pointerleave", function () { setTimeout(resume, 0); });
|
|
181
|
+
this.addEventListener("focusin", pause);
|
|
182
|
+
this.addEventListener("focusout", function () { setTimeout(resume, 0); });
|
|
183
|
+
this._onVisibility = function () {
|
|
184
|
+
if (document.hidden) {
|
|
185
|
+
pause();
|
|
186
|
+
} else {
|
|
187
|
+
resume();
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
document.addEventListener("visibilitychange", this._onVisibility);
|
|
191
|
+
this._onResize = this._layout.bind(this);
|
|
192
|
+
window.addEventListener("resize", this._onResize);
|
|
193
|
+
|
|
194
|
+
// Schon im Markup stehende Meldungen
|
|
195
|
+
this._messages().forEach(function (m) {
|
|
196
|
+
var t = parseInt(m.getAttribute("data-timeout"), 10);
|
|
197
|
+
enhance(m, isNaN(t) ? 5000 : t);
|
|
198
|
+
m._ncssStart();
|
|
199
|
+
});
|
|
200
|
+
this._sync();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
disconnectedCallback() {
|
|
204
|
+
if (this._mo) {
|
|
205
|
+
this._mo.disconnect();
|
|
206
|
+
}
|
|
207
|
+
document.removeEventListener("visibilitychange", this._onVisibility);
|
|
208
|
+
window.removeEventListener("resize", this._onResize);
|
|
209
|
+
this._ready = false;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/* Meldung einfügen (neueste an der Kante der Region: oben bei top-, unten bei
|
|
213
|
+
bottom-Positionen) und Timer starten. */
|
|
214
|
+
add(msg) {
|
|
215
|
+
if (isBottom(this)) {
|
|
216
|
+
this.appendChild(msg);
|
|
217
|
+
} else {
|
|
218
|
+
this.insertBefore(msg, this.firstChild);
|
|
219
|
+
}
|
|
220
|
+
if (!this._paused) {
|
|
221
|
+
msg._ncssStart();
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
_messages() {
|
|
226
|
+
return Array.prototype.filter.call(this.children, function (el) {
|
|
227
|
+
return el.classList.contains("ncss-notification") && !el.classList.contains("ncss-notification--leaving");
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
_sync() {
|
|
232
|
+
var hasChildren = this.querySelector(".ncss-notification") !== null;
|
|
233
|
+
if (hasPopover && this.popover) {
|
|
234
|
+
var open = this.matches(":popover-open");
|
|
235
|
+
if (hasChildren && !open) {
|
|
236
|
+
this.showPopover();
|
|
237
|
+
} else if (!hasChildren && open) {
|
|
238
|
+
this.hidePopover();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
this._layout();
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// Nur für [stack]: Reihenfolge (0 = neueste) + Abstand im aufgefächerten Zustand.
|
|
245
|
+
_layout() {
|
|
246
|
+
if (!this.hasAttribute("stack")) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
var live = this._messages();
|
|
250
|
+
if (isBottom(this)) {
|
|
251
|
+
live.reverse();
|
|
252
|
+
}
|
|
253
|
+
var gap = parseFloat(getComputedStyle(this).rowGap) || 8;
|
|
254
|
+
var offset = 0;
|
|
255
|
+
var self = this;
|
|
256
|
+
live.forEach(function (m, i) {
|
|
257
|
+
var natural = m.scrollHeight + (m.offsetHeight - m.clientHeight);
|
|
258
|
+
m.style.setProperty("--ncss-toast-index", i);
|
|
259
|
+
m.style.setProperty("--ncss-toast-offset", offset + "px");
|
|
260
|
+
m.toggleAttribute("data-ncss-toast-front", i === 0);
|
|
261
|
+
if (i === 0) {
|
|
262
|
+
self.style.setProperty("--ncss-toast-front-height", natural + "px");
|
|
263
|
+
}
|
|
264
|
+
offset += natural + gap;
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
// --- API --------------------------------------------------------------------------------
|
|
271
|
+
function region(position, stack) {
|
|
272
|
+
var pos = POSITIONS.indexOf(position) !== -1 ? position : "bottom-end";
|
|
273
|
+
var el = document.querySelector('ncss-toast-region[position="' + pos + '"]');
|
|
274
|
+
if (!el) {
|
|
275
|
+
el = document.createElement("ncss-toast-region");
|
|
276
|
+
el.setAttribute("position", pos);
|
|
277
|
+
document.body.appendChild(el);
|
|
278
|
+
}
|
|
279
|
+
if (stack) {
|
|
280
|
+
el.setAttribute("stack", "");
|
|
281
|
+
}
|
|
282
|
+
return el;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
function notify(message, options) {
|
|
286
|
+
var o = {};
|
|
287
|
+
var src = (message && typeof message === "object" && !(message instanceof Node)) ? message : { message: message };
|
|
288
|
+
Object.keys(src).forEach(function (k) { o[k] = src[k]; });
|
|
289
|
+
if (typeof options === "string") {
|
|
290
|
+
o.status = options;
|
|
291
|
+
} else if (options) {
|
|
292
|
+
Object.keys(options).forEach(function (k) { o[k] = options[k]; });
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
var reg = region(o.position, o.stack);
|
|
296
|
+
var fresh = !reg._ncssUsed;
|
|
297
|
+
reg._ncssUsed = true;
|
|
298
|
+
|
|
299
|
+
var msg = document.createElement("div");
|
|
300
|
+
msg.className = "ncss-notification" + (o.status ? " ncss-notification--" + o.status : "");
|
|
301
|
+
if (o.status === "danger" || o.status === "warning") {
|
|
302
|
+
msg.setAttribute("role", "alert");
|
|
303
|
+
}
|
|
304
|
+
var body = document.createElement("div");
|
|
305
|
+
body.className = "ncss-notification-body";
|
|
306
|
+
if (o.title) {
|
|
307
|
+
var title = document.createElement("p");
|
|
308
|
+
title.className = "ncss-notification-title";
|
|
309
|
+
title.textContent = o.title;
|
|
310
|
+
body.appendChild(title);
|
|
311
|
+
}
|
|
312
|
+
if (o.message instanceof Node) {
|
|
313
|
+
body.appendChild(o.message);
|
|
314
|
+
} else if (o.message != null && o.message !== "") {
|
|
315
|
+
var text = document.createElement("p");
|
|
316
|
+
text.textContent = String(o.message);
|
|
317
|
+
if (!o.title) {
|
|
318
|
+
text.className = "ncss-notification-title";
|
|
319
|
+
}
|
|
320
|
+
body.appendChild(text);
|
|
321
|
+
}
|
|
322
|
+
msg.appendChild(body);
|
|
323
|
+
var timeout = o.timeout != null ? Number(o.timeout) : (o.status === "danger" ? 0 : 5000);
|
|
324
|
+
enhance(msg, timeout, o.closeLabel);
|
|
325
|
+
|
|
326
|
+
// Über einem modalen Dialog: Region einmal neu in den Top Layer heben (zuletzt
|
|
327
|
+
// geöffnetes Element liegt oben).
|
|
328
|
+
if (hasPopover && reg.matches(":popover-open") && document.querySelector("dialog:modal")) {
|
|
329
|
+
reg.hidePopover();
|
|
330
|
+
reg.showPopover();
|
|
331
|
+
}
|
|
332
|
+
// Frisch erzeugte Live-Region: einen Moment warten, sonst wird die erste Meldung
|
|
333
|
+
// nicht angesagt.
|
|
334
|
+
if (fresh && !reg.children.length) {
|
|
335
|
+
setTimeout(function () { reg.add(msg); }, 60);
|
|
336
|
+
} else {
|
|
337
|
+
reg.add(msg);
|
|
338
|
+
}
|
|
339
|
+
return { element: msg, close: function () { msg._ncssClose(); } };
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
window.ncss = window.ncss || {};
|
|
343
|
+
window.ncss.notify = notify;
|
|
344
|
+
window.ncss.notifyCloseAll = function () {
|
|
345
|
+
document.querySelectorAll("ncss-toast-region > .ncss-notification").forEach(function (m) {
|
|
346
|
+
if (m._ncssClose) {
|
|
347
|
+
m._ncssClose();
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
document.addEventListener("ncss-notify", function (event) {
|
|
353
|
+
if (event.detail) {
|
|
354
|
+
notify(event.detail);
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
document.addEventListener("click", function (event) {
|
|
359
|
+
var btn = event.target.closest && event.target.closest("[data-ncss-notify]");
|
|
360
|
+
if (!btn) {
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
notify({
|
|
364
|
+
message: btn.getAttribute("data-ncss-notify"),
|
|
365
|
+
title: btn.getAttribute("data-title") || undefined,
|
|
366
|
+
status: btn.getAttribute("data-status") || undefined,
|
|
367
|
+
timeout: btn.hasAttribute("data-timeout") ? Number(btn.getAttribute("data-timeout")) : undefined,
|
|
368
|
+
position: btn.getAttribute("data-position") || undefined,
|
|
369
|
+
stack: btn.hasAttribute("data-stack")
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
})();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ncss - Optionaler Begleiter zu page-transitions.css: unterdrückt eine bekannte, laut
|
|
3
|
+
* Spec/Implementierung ERWARTETE (aber ungefangene) Promise-Ablehnung, die bei jeder
|
|
4
|
+
* rein deklarativen Cross-Document View Transition auftreten KANN, sobald der Browser
|
|
5
|
+
* eine bereits gestartete Transition überspringt (typischer Auslöser: eine weitere
|
|
6
|
+
* Navigation - z.B. ein schneller Vorwärts-/Zurück-Klick - kommt dazwischen) - sichtbar
|
|
7
|
+
* in der Konsole als "Unhandled Promise Rejection: AbortError: Skipping view transition
|
|
8
|
+
* because skipTransition() was called". Betrifft NICHT ncss' Code oder eine echte
|
|
9
|
+
* Fehlfunktion - die Navigation selbst läuft normal weiter, nur die intern vom Browser
|
|
10
|
+
* verwaltete `ready`-Promise der übersprungenen Transition lehnt ab, wie von der Spec
|
|
11
|
+
* vorgesehen (ViewTransition.ready: "will reject if the transition cannot begin").
|
|
12
|
+
*
|
|
13
|
+
* Eine rein CSS-basierte Seite (`@view-transition { navigation: auto }`, siehe
|
|
14
|
+
* page-transitions.css) bekommt dafür OHNE dieses Skript gar keine Referenz auf die
|
|
15
|
+
* Transition - kann also auch gar nicht selbst `.catch()` darauf aufrufen. Der native
|
|
16
|
+
* `pageswap`-Event (feuert auf dem VERLASSENEN Dokument kurz vor der Navigation) legt
|
|
17
|
+
* über `PageSwapEvent.viewTransition` genau diese Referenz offen, extra für diesen
|
|
18
|
+
* Zweck vorgesehen. Dieses Skript ändert am Übergang selbst NICHTS (keine eigene
|
|
19
|
+
* Steuerung, kein eigener `skipTransition()`-Aufruf) - hängt nur einen leeren
|
|
20
|
+
* `.catch()` an, unterdrückt dadurch die Konsolen-Meldung für den erwarteten,
|
|
21
|
+
* harmlosen Fall.
|
|
22
|
+
*
|
|
23
|
+
* Bestätigt betroffen (Recherche August 2026): WebKit/Safari bei Zurück-/Vorwärts-
|
|
24
|
+
* Navigation während eine Transition läuft, offener Bug bugs.webkit.org #289078.
|
|
25
|
+
* Dieselbe Klasse Problem wird aktuell auch in der CSSWG selbst diskutiert
|
|
26
|
+
* (github.com/w3c/csswg-drafts Issue 13726, "noisy unhandled rejections in transition
|
|
27
|
+
* navigations") - kein ncss-spezifisches Problem, betrifft jede Seite mit Cross-
|
|
28
|
+
* Document View Transitions, ob deklarativ per CSS oder per JS ausgelöst.
|
|
29
|
+
*
|
|
30
|
+
* Einbindung (zusätzlich zu page-transitions.css, komplett optional - nur bei Bedarf,
|
|
31
|
+
* page-transitions.css selbst bleibt bewusst reines CSS ohne JS-Abhängigkeit):
|
|
32
|
+
* <script src="js/page-transitions-quiet.js" defer></script>
|
|
33
|
+
*/
|
|
34
|
+
(function () {
|
|
35
|
+
"use strict";
|
|
36
|
+
|
|
37
|
+
if (typeof PageSwapEvent === "undefined") return;
|
|
38
|
+
|
|
39
|
+
window.addEventListener("pageswap", function (event) {
|
|
40
|
+
if (event.viewTransition) {
|
|
41
|
+
event.viewTransition.ready.catch(function () {});
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
})();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ncss - Darstellungs-Einstellungen, früher Teil: setzt gespeicherte Besucher-Einstellungen
|
|
3
|
+
* (<ncss-preferences>, js/preferences.js) als Attribute am <html>, BEVOR die Seite gezeichnet
|
|
4
|
+
* wird - kein Aufblitzen in falscher Schriftgröße/Farbe beim Laden.
|
|
5
|
+
*
|
|
6
|
+
* Synchron im <head>, VOR den Stylesheets, ohne defer/async (eigene Datei statt Inline-
|
|
7
|
+
* Snippet, damit eine strenge CSP ohne 'unsafe-inline' funktioniert):
|
|
8
|
+
* <script src="dist/js/preferences-early.js"></script>
|
|
9
|
+
* <link rel="stylesheet" href="dist/ncss.css">
|
|
10
|
+
* Ersetzt js/theme-toggle-early.js (liest denselben Schlüssel "ncss-theme" - beide Dateien
|
|
11
|
+
* zusammen schaden nicht, eine reicht).
|
|
12
|
+
*
|
|
13
|
+
* Gesetzte Attribute (Wirkung in colors.css/reset.css, ohne Wahl gilt das System):
|
|
14
|
+
* data-theme="light|dark" Farbschema (+ data-theme-resolved, wie theme-toggle)
|
|
15
|
+
* data-contrast="more|normal" Kontrast (normal = System-"more" bewusst zurücknehmen)
|
|
16
|
+
* data-motion="reduce|full" Bewegung (full = System-"reduce" bewusst aufheben)
|
|
17
|
+
* data-text-scale="115|130" Schriftgröße
|
|
18
|
+
* data-ncss-font="hyperlegible|lexend|opendyslexic" Lese-Schrift
|
|
19
|
+
* (Wirkung in components/preferences-fonts.css)
|
|
20
|
+
* data-text-spacing Textabstände nach WCAG 1.4.12
|
|
21
|
+
* data-links="underline" Links immer unterstreichen
|
|
22
|
+
* data-focus="strong" verstärkter Fokus-Rahmen
|
|
23
|
+
*/
|
|
24
|
+
(function (root) {
|
|
25
|
+
"use strict";
|
|
26
|
+
var prefs = {};
|
|
27
|
+
try {
|
|
28
|
+
var theme = localStorage.getItem("ncss-theme");
|
|
29
|
+
if (theme === "light" || theme === "dark") {
|
|
30
|
+
root.setAttribute("data-theme", theme);
|
|
31
|
+
}
|
|
32
|
+
prefs = JSON.parse(localStorage.getItem("ncss-prefs") || "{}") || {};
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// localStorage gesperrt oder kaputter Wert - dann gilt das System.
|
|
35
|
+
}
|
|
36
|
+
var allowed = {
|
|
37
|
+
contrast: ["more", "normal"],
|
|
38
|
+
motion: ["reduce", "full"],
|
|
39
|
+
text: ["115", "130"],
|
|
40
|
+
font: ["hyperlegible", "lexend", "opendyslexic"]
|
|
41
|
+
};
|
|
42
|
+
if (allowed.contrast.indexOf(prefs.contrast) > -1) root.setAttribute("data-contrast", prefs.contrast);
|
|
43
|
+
if (allowed.motion.indexOf(prefs.motion) > -1) root.setAttribute("data-motion", prefs.motion);
|
|
44
|
+
if (allowed.text.indexOf(String(prefs.text)) > -1) root.setAttribute("data-text-scale", String(prefs.text));
|
|
45
|
+
if (allowed.font.indexOf(prefs.font) > -1) root.setAttribute("data-ncss-font", prefs.font);
|
|
46
|
+
if (prefs.spacing === true) root.setAttribute("data-text-spacing", "");
|
|
47
|
+
if (prefs.links === true) root.setAttribute("data-links", "underline");
|
|
48
|
+
if (prefs.focus === true) root.setAttribute("data-focus", "strong");
|
|
49
|
+
var dark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
50
|
+
root.setAttribute("data-theme-resolved", root.getAttribute("data-theme") || (dark ? "dark" : "light"));
|
|
51
|
+
})(document.documentElement);
|