@nextrap/nte-nav 1.2.0 → 2.0.1

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.
@@ -0,0 +1,65 @@
1
+ # @nextrap/nte-nav
2
+
3
+ Draft replacement for the navigation portion of `@nextrap/nte-nav`. Do not remove or change the legacy package and do not add navbar concerns here.
4
+
5
+ ## First reference
6
+
7
+ Read the demo files before changing the API:
8
+
9
+ - `demo/01-overview.md` explains the component model.
10
+ - `demo/02-horizontal.html` demonstrates links, icons and nested submenus.
11
+ - `demo/03-vertical.html` demonstrates the same markup under the vertical mixin.
12
+ - `demo/04-responsive-order.html` demonstrates responsive orientation and Flexbox order.
13
+ - `demo/05-variations.html` demonstrates sizes, visual variants and linked/non-linked parent items.
14
+ - `demo/main.scss` is the authoritative example for binding public mixins to semantic contexts.
15
+
16
+ ## Markup
17
+
18
+ ```html
19
+ <nte-nav aria-label="Hauptnavigation">
20
+ <nte-nav-item submenu-popover>
21
+ <svg slot="icon" aria-hidden="true"><!-- icon --></svg>
22
+ Leistungen
23
+ <nte-nav-item href="/leistungen/beratung">Beratung</nte-nav-item>
24
+ </nte-nav-item>
25
+ <nte-nav-item href="/ueber-uns" current="page">Über uns</nte-nav-item>
26
+ </nte-nav>
27
+ ```
28
+
29
+ - Consumers never author a `ul/li/ul` tree.
30
+ - Direct nested items are automatically assigned to the parent item's `submenu` slot by the label slot-change handler.
31
+ - Anchors and submenu controls stay inside each item's Shadow DOM.
32
+ - Horizontal submenus use manual declarative Popover: add `submenu-popover` to the parent `nte-nav-item`; it renders `popover="auto"` and `popovertarget="submenu"` internally.
33
+ - Vertical submenus must not use `submenu-popover`; they render native `details`/`summary` and stay inline.
34
+ - A parent item should normally omit `href`, making its complete visible label the disclosure control.
35
+ - An item with both `href` and children must keep link and disclosure as separate controls.
36
+ - Do not add `menu`, `menubar` or `menuitem` roles for ordinary site navigation.
37
+ - Horizontal orientation positions the Popover submenu with CSS Anchor Positioning; vertical orientation keeps it static and inline below its parent.
38
+ - Orientation mixins do not add/remove attributes. For nested responsive submenus, the integration must manually add/remove `submenu-popover` or choose one authored variant.
39
+ - Keep `nextrap_element({ slotVisibility: true })` and use `.slot-empty` for optional slots instead of component-authored icon state.
40
+
41
+ ## Styling
42
+
43
+ ```scss
44
+ @use '@nextrap/nte-nav' as nav;
45
+
46
+ .site-header nte-nav.style-default {
47
+ @include nav.default-style();
48
+ @include nav.responsive(48rem);
49
+ }
50
+ ```
51
+
52
+ - Keep Shadow DOM CSS functional only.
53
+ - Visual styling belongs in the exported mixins and reaches internal markup through parts.
54
+ - Orientation is a mixin/CSS-custom-property concern, not a component attribute.
55
+ - Examples do not explicitly add `style-default`; `SetDefaultStyleMixin` adds it.
56
+ - A non-default `style-*` variant must include its full visual baseline.
57
+ - Feature classes, if introduced, start with `with-*`.
58
+
59
+ ## Accessibility checks
60
+
61
+ - Give each `nte-nav` an `aria-label` when the page has multiple nav landmarks.
62
+ - Preserve native link behavior and forward `current` to the anchor's `aria-current`.
63
+ - Keep visible focus indicators on links and disclosure buttons.
64
+ - Test Tab, Shift+Tab, Enter, Space, touch input and reduced motion.
65
+ - Flex `order` changes only visual order; avoid it when that would make focus order confusing.
@@ -0,0 +1,155 @@
1
+ # NTE Nav 2 architecture
2
+
3
+ ## Native Popover only
4
+
5
+ Die horizontale Submenu-Variante basiert vollständig auf dem nativen HTML
6
+ Popover-Mechanismus.
7
+
8
+ Ein `nte-nav-item` mit `submenu-popover` rendert intern ausschließlich
9
+ deklaratives Popover-Markup:
10
+
11
+ ```html
12
+ <button popovertarget="submenu">...</button>
13
+ <div id="submenu" popover="auto">...</div>
14
+ ```
15
+
16
+ Die Popover-Logik muss vom Browser kommen. `nte-nav` / `nte-nav-item` dürfen
17
+ keine JavaScript-Popover-Logik implementieren:
18
+
19
+ - kein `showPopover()`;
20
+ - kein `hidePopover()`;
21
+ - keine JS-Synchronisierung zwischen CSS-Orientation und Popover;
22
+ - keine Resize-/Media-Query-Logik für Popover.
23
+
24
+ Popover wird manuell durch das öffentliche `submenu-popover` Attribut am
25
+ betroffenen `nte-nav-item` aktiviert oder durch Entfernen dieses Attributs
26
+ deaktiviert.
27
+
28
+ ## Vertikale Navigation
29
+
30
+ Die vertikale Variante darf kein Popover verwenden. Ein vertikales Submenu wird
31
+ korrekt gerendert, indem am betroffenen `nte-nav-item` **kein**
32
+ `submenu-popover` Attribut gesetzt wird.
33
+
34
+ Dann rendert `nte-nav-item` intern native Disclosure-Struktur:
35
+
36
+ ```html
37
+ <details id="details" part="details">
38
+ <summary id="disclosure" part="disclosure">...</summary>
39
+ <div id="submenu" part="submenu" role="list">...</div>
40
+ </details>
41
+ ```
42
+
43
+ Bei einem Elternpunkt mit eigenem `href` bleiben Link und Disclosure getrennt:
44
+
45
+ ```html
46
+ <a id="link" part="link" href="...">...</a>
47
+ <details id="details" part="details">
48
+ <summary id="toggle" part="toggle">...</summary>
49
+ <div id="submenu" part="submenu" role="list">...</div>
50
+ </details>
51
+ ```
52
+
53
+ Die vertikale Darstellung entsteht durch die `vertical()` SCSS-Variante. Sie
54
+ setzt die Navigationsrichtung auf Spalte und die Submenu-Position auf normalen
55
+ Dokumentfluss:
56
+
57
+ - `--nte-nav-flow: column`;
58
+ - `--nte-nav-submenu-position: static`;
59
+ - `--nte-nav-submenu-inline-size: 100%`;
60
+ - transparente Submenu-Fläche ohne Popover-Box, Border oder Shadow;
61
+ - optionaler Einzug über `--nte-nav-inline-submenu-indent`.
62
+
63
+ Das Submenu öffnet ausschließlich über den nativen `details[open]` Zustand. Die
64
+ CSS-Regel für `#details[open] #submenu` macht den Inhalt sichtbar und klappt die
65
+ Grid-Zeile von `0fr` auf `1fr` auf. Dadurch bleibt das Submenu inline unter dem
66
+ Elterneintrag und erweitert die Navigation vertikal, statt als Overlay aus dem
67
+ Layout herauszuspringen.
68
+
69
+ Wichtig: Für vertikale Navigation darf weder das öffentliche
70
+ `submenu-popover` Attribut noch intern `popover` oder `popovertarget` vorhanden
71
+ sein.
72
+
73
+ ## CSS-Block- und Mixin-Dokumentation
74
+
75
+ Vor jedem zusammengehörigen CSS-Block und vor jedem SCSS-Mixin muss ein kurzer
76
+ Kommentar stehen, der seinen Zweck beschreibt. Der Kommentar muss erklären,
77
+ welches Verhalten der Block beziehungsweise das Mixin steuert und — falls
78
+ relevant — in welchem Zustand oder für welche Variante es gilt.
79
+
80
+ Ein Block umfasst dabei alle direkt zusammengehörigen Regeln eines Elements,
81
+ Parts oder Zustands. Einzelne CSS-Regeln innerhalb eines solchen Blocks
82
+ benötigen keinen eigenen Kommentar. Reine technische Folge- oder Reset-Regeln
83
+ können mit dem Kommentar des übergeordneten Blocks gruppiert werden.
84
+
85
+ Die Regel gilt insbesondere für:
86
+
87
+ - `:host`- und Komponentenblöcke;
88
+ - `::part(...)`-Blöcke;
89
+ - `:has(...)`-, Zustands- und Selektorblöcke;
90
+ - responsive beziehungsweise über `tj-responsive` gesetzte Zustände;
91
+ - jedes öffentliche SCSS-Mixin unter `src/scss/`.
92
+
93
+ Kommentare dürfen nicht nur den Selektor wiederholen. Sie müssen den
94
+ funktionalen Zweck des jeweiligen Blocks dokumentieren. Neue oder geänderte
95
+ zweckorientierte CSS-Blöcke und Mixins ohne Zweckkommentar sind nicht zulässig.
96
+
97
+ ## Responsive Verhalten
98
+
99
+ Responsive Änderungen werden nicht über CSS-Media-Queries in SCSS umgesetzt.
100
+ Breakpoint-abhängige Zustände müssen über `tj-responsive` beziehungsweise
101
+ `@trunkjs/responsive`-Klassen und Attribute gesteuert werden. Das gilt sowohl
102
+ für die Umschaltung zwischen horizontaler und vertikaler Navigation als auch
103
+ für responsive Sichtbarkeit, Reihenfolge und Layout-Eigenschaften.
104
+
105
+ SCSS-Varianten dürfen ausschließlich die jeweils gesetzten Zustände stylen;
106
+ eine eigene `@media`-Regel oder eine parallele Breakpoint-Logik innerhalb von
107
+ `nte-nav` ist nicht zulässig.
108
+
109
+ ## Styling und Style-Varianten
110
+
111
+ Das Shadow DOM enthält ausschließlich betriebsnotwendige Layout-, Disclosure-
112
+ und Popover-Regeln. Visuelle Defaults und Varianten werden außerhalb des Shadow
113
+ DOM über die öffentlichen Parts gestylt.
114
+
115
+ Die Default-Baseline wird im Mixin `default-style()` definiert. Neue visuelle
116
+ Varianten müssen dieses Mixin erweitern und unter `src/scss/styles/` angelegt
117
+ werden. Beispiel:
118
+
119
+ ```scss
120
+ @use '../default-style' as default;
121
+
122
+ @mixin bordered-style() {
123
+ @include default.default-style();
124
+
125
+ & nte-nav-item::part(link),
126
+ & nte-nav-item::part(disclosure) {
127
+ border: var(--nt-border-width) solid var(--nt-border);
128
+ }
129
+ }
130
+ ```
131
+
132
+ Die Variante wird über eine eigene `style-*`-Klasse am Custom Element aktiviert
133
+ und muss die vollständige Default-Baseline über das Default-Mixin erben:
134
+
135
+ ```scss
136
+ nte-nav.style-bordered {
137
+ @include nav.bordered-style();
138
+ }
139
+ ```
140
+
141
+ Dabei gelten folgende Regeln:
142
+
143
+ - Visuelles Styling immer über `::part(...)`, niemals durch zusätzliche
144
+ visuelle Regeln im Shadow DOM.
145
+ - Globale Werte aus `@nextrap/style-base` über `--nt-*` Tokens beziehen.
146
+ - Komponentenvariablen nur für betriebsnotwendiges Verhalten verwenden, etwa
147
+ Orientierung, Submenu-Positionierung und Animation.
148
+ - Eine Style-Variante wird als eigenes Mixin unter `src/scss/styles/` angelegt
149
+ und in `index.scss` exportiert.
150
+ - Pro `nte-nav` darf nur eine `style-*`-Klasse gesetzt sein.
151
+ - Feature-Änderungen, die mit anderen Styles kombinierbar sein sollen, werden
152
+ als `with-*` Modifier und nicht als neue `style-*`-Variante umgesetzt.
153
+ - Das Default-Mixin setzt für die Hauptnavigation keine Hintergrundfarbe. Das
154
+ horizontale Dropdown erhält seine Hintergrundfarbe separat über
155
+ `::part(submenu)`.