@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,346 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ncss - <ncss-preferences>: Darstellungs-Einstellungen für Besucher (siehe
|
|
3
|
+
* components/preferences.css für Markup). Light-DOM-Custom-Element.
|
|
4
|
+
*
|
|
5
|
+
* KEIN "Barrierefreiheits-Overlay": macht keine Seite barrierefrei und repariert nichts.
|
|
6
|
+
* Es lässt Besucher eine bereits barrierefreie Seite an persönliche Bedürfnisse anpassen.
|
|
7
|
+
* Betriebssystem-/Browser-Einstellungen sind der Default ("System") und werden nie
|
|
8
|
+
* stillschweigend überschrieben - jede Abweichung ist eine ausdrückliche Wahl.
|
|
9
|
+
*
|
|
10
|
+
* Schreibt dieselben <html>-Attribute wie js/preferences-early.js (Wirkung in colors.css
|
|
11
|
+
* und reset.css, keine Komponente muss davon wissen) und speichert in localStorage:
|
|
12
|
+
* "ncss-theme" (gemeinsam mit js/theme-toggle.js - EIN Mechanismus) und "ncss-prefs" (JSON).
|
|
13
|
+
*
|
|
14
|
+
* Attribute am Element:
|
|
15
|
+
* inline Bedienfeld direkt anzeigen statt Button + Popover
|
|
16
|
+
* settings="theme contrast motion text font spacing links focus" Auswahl/Reihenfolge
|
|
17
|
+
* ("font" nur mit components/preferences-fonts.css)
|
|
18
|
+
* data-label-<schlüssel>="…" jeden Text überschreiben (Schlüssel siehe TEXTS unten)
|
|
19
|
+
* Event (am document): ncss-preferences-change, detail { key, value, prefs }
|
|
20
|
+
*
|
|
21
|
+
* Bedienung: native Radiogruppen (fieldset/legend, Pfeiltasten) und Checkboxen (Leertaste),
|
|
22
|
+
* Änderungen wirken sofort (Live-Vorschau) und werden höflich angesagt (role="status").
|
|
23
|
+
* Popover: Esc/Klick daneben schließt, Fokus geht beim Öffnen auf das erste Feld und beim
|
|
24
|
+
* Schließen zurück auf den Button. Ohne Anchor Positioning rechnet das Script die Position.
|
|
25
|
+
*
|
|
26
|
+
* Abhängigkeiten: keine anderen ncss-Scripts. Ohne customElements wird nichts registriert -
|
|
27
|
+
* das Element bleibt verborgen (CSS :not(:defined)), es gelten die Systemeinstellungen.
|
|
28
|
+
*/
|
|
29
|
+
(function () {
|
|
30
|
+
"use strict";
|
|
31
|
+
|
|
32
|
+
if (!window.customElements || customElements.get("ncss-preferences")) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var root = document.documentElement;
|
|
37
|
+
var THEME_KEY = "ncss-theme";
|
|
38
|
+
var PREFS_KEY = "ncss-prefs";
|
|
39
|
+
var ALL = ["theme", "contrast", "motion", "text", "font", "spacing", "links", "focus"];
|
|
40
|
+
var TEXTS = {
|
|
41
|
+
de: {
|
|
42
|
+
button: "Darstellung", title: "Darstellung anpassen",
|
|
43
|
+
intro: "Passe die Darstellung an deine Bedürfnisse an. Solange du nichts änderst, gelten die Einstellungen deines Geräts.",
|
|
44
|
+
system: "System",
|
|
45
|
+
theme: "Farbschema", light: "Hell", dark: "Dunkel",
|
|
46
|
+
contrast: "Kontrast", normal: "Normal", more: "Erhöht",
|
|
47
|
+
motion: "Bewegung", reduce: "Reduziert", full: "Voll",
|
|
48
|
+
motionHint: "Dein Gerät wünscht reduzierte Bewegung - „Voll“ hebt das nur für diese Website auf.",
|
|
49
|
+
text: "Schriftgröße",
|
|
50
|
+
font: "Schrift", fontDefault: "Standard", hyperlegible: "Atkinson Hyperlegible", lexend: "Lexend", opendyslexic: "OpenDyslexic",
|
|
51
|
+
spacing: "Größere Text- und Zeilenabstände", links: "Links immer unterstreichen", focus: "Fokus-Rahmen verstärken",
|
|
52
|
+
reset: "Zurücksetzen", resetDone: "Alle Einstellungen zurückgesetzt, es gilt dein Gerät.",
|
|
53
|
+
on: "an", off: "aus", close: "Schließen"
|
|
54
|
+
},
|
|
55
|
+
en: {
|
|
56
|
+
button: "Display", title: "Adjust display",
|
|
57
|
+
intro: "Adapt the display to your needs. As long as you change nothing, your device settings apply.",
|
|
58
|
+
system: "System",
|
|
59
|
+
theme: "Colour scheme", light: "Light", dark: "Dark",
|
|
60
|
+
contrast: "Contrast", normal: "Normal", more: "Increased",
|
|
61
|
+
motion: "Motion", reduce: "Reduced", full: "Full",
|
|
62
|
+
motionHint: "Your device asks for reduced motion - “Full” overrides that for this website only.",
|
|
63
|
+
text: "Text size",
|
|
64
|
+
font: "Font", fontDefault: "Default", hyperlegible: "Atkinson Hyperlegible", lexend: "Lexend", opendyslexic: "OpenDyslexic",
|
|
65
|
+
spacing: "Larger text and line spacing", links: "Always underline links", focus: "Stronger focus outline",
|
|
66
|
+
reset: "Reset", resetDone: "All settings reset, your device settings apply.",
|
|
67
|
+
on: "on", off: "off", close: "Close"
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
// Radiogruppen: Schlüssel -> Optionen ("" = System/Standard)
|
|
71
|
+
var GROUPS = {
|
|
72
|
+
theme: ["", "light", "dark"],
|
|
73
|
+
contrast: ["", "normal", "more"],
|
|
74
|
+
motion: ["", "reduce", "full"],
|
|
75
|
+
text: ["", "115", "130"],
|
|
76
|
+
font: ["", "hyperlegible", "lexend", "opendyslexic"]
|
|
77
|
+
};
|
|
78
|
+
var SWITCHES = ["spacing", "links", "focus"];
|
|
79
|
+
var anchorSupport = window.CSS && CSS.supports("anchor-name: --a") && CSS.supports("position-area: bottom");
|
|
80
|
+
var popoverSupport = HTMLElement.prototype.hasOwnProperty("popover");
|
|
81
|
+
var counter = 0;
|
|
82
|
+
|
|
83
|
+
function read() {
|
|
84
|
+
var prefs = {};
|
|
85
|
+
try {
|
|
86
|
+
prefs = JSON.parse(localStorage.getItem(PREFS_KEY) || "{}") || {};
|
|
87
|
+
var theme = localStorage.getItem(THEME_KEY);
|
|
88
|
+
prefs.theme = theme === "light" || theme === "dark" ? theme : "";
|
|
89
|
+
} catch (e) {
|
|
90
|
+
prefs = { theme: root.getAttribute("data-theme") || "" };
|
|
91
|
+
}
|
|
92
|
+
return prefs;
|
|
93
|
+
}
|
|
94
|
+
function write(prefs) {
|
|
95
|
+
try {
|
|
96
|
+
if (prefs.theme) {
|
|
97
|
+
localStorage.setItem(THEME_KEY, prefs.theme);
|
|
98
|
+
} else {
|
|
99
|
+
localStorage.removeItem(THEME_KEY);
|
|
100
|
+
}
|
|
101
|
+
var rest = {};
|
|
102
|
+
["contrast", "motion", "text", "font", "spacing", "links", "focus"].forEach(function (k) {
|
|
103
|
+
if (prefs[k]) rest[k] = prefs[k];
|
|
104
|
+
});
|
|
105
|
+
if (Object.keys(rest).length) {
|
|
106
|
+
localStorage.setItem(PREFS_KEY, JSON.stringify(rest));
|
|
107
|
+
} else {
|
|
108
|
+
localStorage.removeItem(PREFS_KEY);
|
|
109
|
+
}
|
|
110
|
+
} catch (e) {
|
|
111
|
+
// Speichern gesperrt: Einstellung gilt trotzdem bis zum Neuladen.
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function attr(name, value) {
|
|
115
|
+
if (value === null || value === "" || value === false || value === undefined) {
|
|
116
|
+
root.removeAttribute(name);
|
|
117
|
+
} else {
|
|
118
|
+
root.setAttribute(name, value === true ? "" : value);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// Wendet ALLE Einstellungen an - dieselbe Zuordnung wie js/preferences-early.js.
|
|
122
|
+
function apply(prefs) {
|
|
123
|
+
attr("data-theme", prefs.theme || null);
|
|
124
|
+
attr("data-contrast", prefs.contrast || null);
|
|
125
|
+
attr("data-motion", prefs.motion || null);
|
|
126
|
+
attr("data-text-scale", prefs.text || null);
|
|
127
|
+
attr("data-ncss-font", prefs.font || null);
|
|
128
|
+
attr("data-text-spacing", prefs.spacing ? true : null);
|
|
129
|
+
attr("data-links", prefs.links ? "underline" : null);
|
|
130
|
+
attr("data-focus", prefs.focus ? "strong" : null);
|
|
131
|
+
var dark = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
132
|
+
root.setAttribute("data-theme-resolved", prefs.theme || (dark ? "dark" : "light"));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Die Schriftwahl hat nur Sinn, wenn components/preferences-fonts.css eingebunden ist
|
|
136
|
+
// (deklariert die @font-face-Regeln) - sonst wird die Gruppe gar nicht angeboten.
|
|
137
|
+
function fontsAvailable() {
|
|
138
|
+
if (!document.fonts || typeof document.fonts.forEach !== "function") return false;
|
|
139
|
+
var found = false;
|
|
140
|
+
document.fonts.forEach(function (face) {
|
|
141
|
+
if (/Lexend|Atkinson Hyperlegible Next|OpenDyslexic/.test(face.family)) found = true;
|
|
142
|
+
});
|
|
143
|
+
return found;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
customElements.define(
|
|
147
|
+
"ncss-preferences",
|
|
148
|
+
class extends HTMLElement {
|
|
149
|
+
connectedCallback() {
|
|
150
|
+
if (this._ready) {
|
|
151
|
+
document.addEventListener("ncss-preferences-change", this._onChange);
|
|
152
|
+
window.addEventListener("storage", this._onStorage);
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
this._ready = true;
|
|
156
|
+
var self = this;
|
|
157
|
+
var n = ++counter;
|
|
158
|
+
var lang = ((this.closest("[lang]") || root).getAttribute("lang") || "de").slice(0, 2) === "en" ? "en" : "de";
|
|
159
|
+
var t = function (key) {
|
|
160
|
+
return self.getAttribute("data-label-" + key.toLowerCase()) || TEXTS[lang][key];
|
|
161
|
+
};
|
|
162
|
+
var wanted = (this.getAttribute("settings") || ALL.join(" ")).split(/\s+/).filter(function (k) {
|
|
163
|
+
return ALL.indexOf(k) > -1;
|
|
164
|
+
});
|
|
165
|
+
var inline = this.hasAttribute("inline") || !popoverSupport;
|
|
166
|
+
var id = "ncss-prefs-" + n;
|
|
167
|
+
|
|
168
|
+
var panel = document.createElement(inline ? "section" : "div");
|
|
169
|
+
panel.className = "ncss-preferences-panel";
|
|
170
|
+
panel.id = id + "-panel";
|
|
171
|
+
panel.setAttribute("aria-labelledby", id + "-title");
|
|
172
|
+
if (!inline) {
|
|
173
|
+
panel.setAttribute("popover", "auto");
|
|
174
|
+
panel.setAttribute("role", "dialog");
|
|
175
|
+
}
|
|
176
|
+
var html = '<h2 class="ncss-preferences-title" id="' + id + '-title">' + t("title") + "</h2>" +
|
|
177
|
+
'<p class="ncss-preferences-intro">' + t("intro") + "</p>";
|
|
178
|
+
wanted.forEach(function (key) {
|
|
179
|
+
if (GROUPS[key]) {
|
|
180
|
+
html += '<fieldset class="ncss-preferences-group" data-key="' + key + '"><legend>' + t(key) + "</legend>" +
|
|
181
|
+
'<div class="ncss-preferences-options">';
|
|
182
|
+
GROUPS[key].forEach(function (value) {
|
|
183
|
+
var label = value === "" ? (key === "text" ? "100 %" : key === "font" ? t("fontDefault") : t("system")) :
|
|
184
|
+
key === "text" ? value + " %" : t(value);
|
|
185
|
+
// Schriftnamen in ihrer eigenen Schrift als Vorschau (components/preferences-fonts.css).
|
|
186
|
+
var preview = key === "font" && value ? ' data-font-preview="' + value + '"' : "";
|
|
187
|
+
html += '<label><input type="radio" name="' + id + "-" + key + '" value="' + value + '"><span' + preview + ">" + label + "</span></label>";
|
|
188
|
+
});
|
|
189
|
+
html += "</div>";
|
|
190
|
+
if (key === "motion") {
|
|
191
|
+
html += '<p class="ncss-preferences-hint" data-motion-hint hidden>' + t("motionHint") + "</p>";
|
|
192
|
+
}
|
|
193
|
+
html += "</fieldset>";
|
|
194
|
+
} else {
|
|
195
|
+
html += '<label class="ncss-preferences-switch"><input type="checkbox" role="switch" data-key="' + key + '"><span>' + t(key) + "</span></label>";
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
html += '<div class="ncss-preferences-actions"><button type="button" class="ncss-preferences-reset">' + t("reset") + "</button>" +
|
|
199
|
+
(inline ? "" : '<button type="button" class="ncss-preferences-close" popovertarget="' + panel.id + '" popovertargetaction="hide">' + t("close") + "</button>") +
|
|
200
|
+
'</div><p class="ncss-preferences-status" role="status"></p>';
|
|
201
|
+
panel.innerHTML = html;
|
|
202
|
+
|
|
203
|
+
if (!inline) {
|
|
204
|
+
var button = document.createElement("button");
|
|
205
|
+
button.type = "button";
|
|
206
|
+
button.className = "ncss-preferences-toggle";
|
|
207
|
+
button.setAttribute("popovertarget", panel.id);
|
|
208
|
+
button.innerHTML = '<span class="ncss-preferences-icon" aria-hidden="true"></span><span>' + t("button") + "</span>";
|
|
209
|
+
this.appendChild(button);
|
|
210
|
+
this._button = button;
|
|
211
|
+
if (anchorSupport) {
|
|
212
|
+
button.style.setProperty("anchor-name", "--" + id);
|
|
213
|
+
panel.style.setProperty("position-anchor", "--" + id);
|
|
214
|
+
}
|
|
215
|
+
panel.addEventListener("toggle", function (event) {
|
|
216
|
+
button.setAttribute("aria-expanded", event.newState === "open" ? "true" : "false");
|
|
217
|
+
if (event.newState === "open") {
|
|
218
|
+
self._place();
|
|
219
|
+
var first = panel.querySelector("input:checked, input");
|
|
220
|
+
if (first) first.focus();
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
button.setAttribute("aria-expanded", "false");
|
|
224
|
+
}
|
|
225
|
+
this.appendChild(panel);
|
|
226
|
+
this._panel = panel;
|
|
227
|
+
this._status = panel.querySelector(".ncss-preferences-status");
|
|
228
|
+
this._t = t;
|
|
229
|
+
|
|
230
|
+
panel.addEventListener("change", function (event) {
|
|
231
|
+
var input = event.target;
|
|
232
|
+
var group = input.closest("[data-key]");
|
|
233
|
+
var key = input.getAttribute("data-key") || (group && group.getAttribute("data-key"));
|
|
234
|
+
if (!key) return;
|
|
235
|
+
var prefs = read();
|
|
236
|
+
var value = input.type === "checkbox" ? input.checked : input.value;
|
|
237
|
+
prefs[key] = value;
|
|
238
|
+
self._commit(prefs, key, value);
|
|
239
|
+
// Schriftgröße/Abstände/Schrift lassen die Seite neu umbrechen - der Button (und
|
|
240
|
+
// damit das an ihm verankerte Popover) wandert dabei oft aus dem Bild. Zurückholen,
|
|
241
|
+
// damit Bedienfeld und Fokus sichtbar bleiben.
|
|
242
|
+
// Mehrfach nachfassen: Bereiche mit content-visibility:auto, Bilder und Webfonts
|
|
243
|
+
// messen sich erst in den folgenden Frames neu.
|
|
244
|
+
if (self._button && self._panel.matches(":popover-open")) {
|
|
245
|
+
[0, 150, 400, 800].forEach(function (ms) {
|
|
246
|
+
window.setTimeout(function () {
|
|
247
|
+
if (!self._panel.matches(":popover-open")) return;
|
|
248
|
+
self._button.scrollIntoView({ block: "nearest", inline: "nearest", behavior: "instant" });
|
|
249
|
+
self._place();
|
|
250
|
+
}, ms);
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
var name = input.type === "checkbox" ? t(key) + ": " + (value ? t("on") : t("off")) :
|
|
254
|
+
t(key) + ": " + input.nextElementSibling.textContent;
|
|
255
|
+
self._announce(name);
|
|
256
|
+
});
|
|
257
|
+
panel.querySelector(".ncss-preferences-reset").addEventListener("click", function () {
|
|
258
|
+
self._commit({}, "reset", null);
|
|
259
|
+
self._announce(t("resetDone"));
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
this._onChange = function () { self._sync(); };
|
|
263
|
+
this._onStorage = function (event) {
|
|
264
|
+
if (event.key === THEME_KEY || event.key === PREFS_KEY) {
|
|
265
|
+
apply(read());
|
|
266
|
+
self._sync();
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
document.addEventListener("ncss-preferences-change", this._onChange);
|
|
270
|
+
window.addEventListener("storage", this._onStorage);
|
|
271
|
+
this._sync();
|
|
272
|
+
// Schriftgruppe nur zeigen, wenn preferences-fonts.css geladen ist - per @import
|
|
273
|
+
// eingebundene Stylesheets sind beim Start evtl. noch nicht da, daher beim
|
|
274
|
+
// load-Event erneut prüfen.
|
|
275
|
+
var fontGroup = panel.querySelector('[data-key="font"]');
|
|
276
|
+
if (fontGroup) {
|
|
277
|
+
var check = function () { fontGroup.hidden = !fontsAvailable(); };
|
|
278
|
+
check();
|
|
279
|
+
if (document.readyState !== "complete") {
|
|
280
|
+
window.addEventListener("load", check, { once: true });
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
disconnectedCallback() {
|
|
286
|
+
document.removeEventListener("ncss-preferences-change", this._onChange);
|
|
287
|
+
window.removeEventListener("storage", this._onStorage);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
_commit(prefs, key, value) {
|
|
291
|
+
write(prefs);
|
|
292
|
+
apply(prefs);
|
|
293
|
+
document.dispatchEvent(new CustomEvent("ncss-preferences-change", {
|
|
294
|
+
detail: { key: key, value: value, prefs: read() }
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
_announce(text) {
|
|
299
|
+
var status = this._status;
|
|
300
|
+
status.textContent = "";
|
|
301
|
+
window.setTimeout(function () { status.textContent = text; }, 60);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Steuerelemente auf den gespeicherten Stand bringen (auch nach Änderung in einer
|
|
305
|
+
// zweiten Instanz oder einem anderen Tab).
|
|
306
|
+
_sync() {
|
|
307
|
+
var prefs = read();
|
|
308
|
+
var panel = this._panel;
|
|
309
|
+
Object.keys(GROUPS).forEach(function (key) {
|
|
310
|
+
var current = String(prefs[key] || "");
|
|
311
|
+
Array.prototype.forEach.call(panel.querySelectorAll('[data-key="' + key + '"] input'), function (input) {
|
|
312
|
+
input.checked = input.value === current;
|
|
313
|
+
});
|
|
314
|
+
});
|
|
315
|
+
SWITCHES.forEach(function (key) {
|
|
316
|
+
var input = panel.querySelector('input[data-key="' + key + '"]');
|
|
317
|
+
if (input) input.checked = !!prefs[key];
|
|
318
|
+
});
|
|
319
|
+
var hint = panel.querySelector("[data-motion-hint]");
|
|
320
|
+
if (hint) {
|
|
321
|
+
hint.hidden = !(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Ohne Anchor Positioning: unter den Button, rechtsbündig, im Viewport gehalten.
|
|
326
|
+
_place() {
|
|
327
|
+
if (anchorSupport || !this._button) return;
|
|
328
|
+
var panel = this._panel;
|
|
329
|
+
panel.setAttribute("data-ncss-preferences-fallback", "");
|
|
330
|
+
var gap = 8;
|
|
331
|
+
var b = this._button.getBoundingClientRect();
|
|
332
|
+
var p = panel.getBoundingClientRect();
|
|
333
|
+
var vw = document.documentElement.clientWidth;
|
|
334
|
+
var vh = window.innerHeight;
|
|
335
|
+
var left = Math.max(gap, Math.min(b.right - p.width, vw - p.width - gap));
|
|
336
|
+
var top = b.bottom + gap;
|
|
337
|
+
if (top + p.height > vh - gap) {
|
|
338
|
+
top = Math.max(gap, vh - p.height - gap);
|
|
339
|
+
}
|
|
340
|
+
panel.style.left = Math.round(left) + "px";
|
|
341
|
+
panel.style.top = Math.round(top) + "px";
|
|
342
|
+
panel.style.maxHeight = Math.round(vh - top - gap) + "px";
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
})();
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NativeCSS - opt-in Begleiter für helpers/reveal.css (Elemente mit data-ncss-reveal).
|
|
3
|
+
* Die scroll-gescrubbten Reveals brauchen KEIN JS - dieses Script ist nur für:
|
|
4
|
+
* - .ncss-reveal--once in Browsern OHNE CSS-Scroll-Trigger (timeline-trigger, aktuell
|
|
5
|
+
* nur Chromium): spielt die Animation einmal zeitbasiert ab, sobald das Element ins
|
|
6
|
+
* Bild kommt (IntersectionObserver). In Chromium tut es für --once NICHTS (das CSS
|
|
7
|
+
* erledigt es selbst, kein doppelter Mechanismus).
|
|
8
|
+
* - Browser ganz ohne animation-timeline: JEDES data-ncss-reveal-Element wird dort
|
|
9
|
+
* zum Einmal-Reveal (statt einfach statisch sichtbar zu bleiben).
|
|
10
|
+
* Ablauf: Klasse .ncss-reveal--js hält den Startzustand (pausiert), .is-revealed spielt
|
|
11
|
+
* ab. Event "ncss-reveal" (bubbelt) beim Start.
|
|
12
|
+
* Unter prefers-reduced-motion: nichts (das CSS zeigt alles ungeclippt).
|
|
13
|
+
*
|
|
14
|
+
* Benötigt: helpers/reveal.css.
|
|
15
|
+
* Einbindung: <script src="ncss/js/reveal.js" defer></script>
|
|
16
|
+
*/
|
|
17
|
+
(function () {
|
|
18
|
+
// Bewegung reduzieren? Systemeinstellung ODER ausdrückliche Wahl am <html>
|
|
19
|
+
// (data-motion="reduce"/"full", gesetzt von js/preferences.js) - "full" hebt ein
|
|
20
|
+
// System-"reduce" nur als bewusste Nutzerwahl auf, nie von selbst.
|
|
21
|
+
function ncssReducedMotion() {
|
|
22
|
+
var choice = document.documentElement.getAttribute("data-motion");
|
|
23
|
+
if (choice === "reduce") return true;
|
|
24
|
+
if (choice === "full") return false;
|
|
25
|
+
return !!(window.matchMedia && window.matchMedia("(prefers-reduced-motion: reduce)").matches);
|
|
26
|
+
}
|
|
27
|
+
if (
|
|
28
|
+
typeof IntersectionObserver === "undefined" ||
|
|
29
|
+
typeof CSS === "undefined" ||
|
|
30
|
+
!CSS.supports ||
|
|
31
|
+
ncssReducedMotion()
|
|
32
|
+
) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var hasTimeline = CSS.supports("animation-timeline", "view()");
|
|
37
|
+
var hasTrigger = CSS.supports("timeline-trigger", "--a view()");
|
|
38
|
+
|
|
39
|
+
var io = new IntersectionObserver(
|
|
40
|
+
function (entries) {
|
|
41
|
+
entries.forEach(function (entry) {
|
|
42
|
+
if (!entry.isIntersecting) return;
|
|
43
|
+
io.unobserve(entry.target);
|
|
44
|
+
entry.target.classList.add("is-revealed");
|
|
45
|
+
entry.target.dispatchEvent(new CustomEvent("ncss-reveal", { bubbles: true }));
|
|
46
|
+
});
|
|
47
|
+
},
|
|
48
|
+
{ rootMargin: "0px 0px -15% 0px" }
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
function init(el) {
|
|
52
|
+
var once = el.classList.contains("ncss-reveal--once");
|
|
53
|
+
if (!((once && !hasTrigger) || !hasTimeline)) return;
|
|
54
|
+
el.classList.add("ncss-reveal--js");
|
|
55
|
+
io.observe(el);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Dynamische Inhalte (htmx, fetch+innerHTML, REDAXO-Frontend-Editing): scan() ist
|
|
59
|
+
// idempotent - bereits verarbeitete Elemente merkt sich ein WeakSet, bewusst KEIN
|
|
60
|
+
// data-Attribut (per innerHTML kopiertes Markup trüge sonst eine veraltete Markierung
|
|
61
|
+
// mit). Läuft beim Laden und bei jedem "ncss-content-change"-Event (detail.root = neu
|
|
62
|
+
// eingefügtes Element, ohne Angabe das ganze Dokument), siehe js/content-observer.js.
|
|
63
|
+
var SELECTOR = "[data-ncss-reveal]";
|
|
64
|
+
var seen = new WeakSet();
|
|
65
|
+
function scan(root) {
|
|
66
|
+
if (!root || !root.querySelectorAll) return;
|
|
67
|
+
var list = Array.prototype.slice.call(root.querySelectorAll(SELECTOR));
|
|
68
|
+
if (root.matches && root.matches(SELECTOR)) list.unshift(root);
|
|
69
|
+
list.forEach(function (el) {
|
|
70
|
+
if (seen.has(el)) return;
|
|
71
|
+
seen.add(el);
|
|
72
|
+
init(el);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
scan(document);
|
|
76
|
+
document.addEventListener("ncss-content-change", function (event) {
|
|
77
|
+
scan((event.detail && event.detail.root) || document);
|
|
78
|
+
});
|
|
79
|
+
})();
|