diff --git a/README.md b/README.md index 3ef5c04..0903030 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,22 @@ Eigene Icons können in Authentik hochgeladen werden, sonst nimmt das Portal sei - `data-auto="false"`: nicht automatisch einfügen, sondern selbst `` platzieren. - Die Leiste ist 44 px hoch und setzt `--hi-topbar-height` auf ``. Layouts mit `height: 100vh` sollten `calc(100vh - var(--hi-topbar-height, 0px))` verwenden. - Die Leiste nutzt Shadow DOM, CSS-Konflikte mit dem Tool sind also ausgeschlossen. +- **Eigene Knöpfe** (z.B. Speichern, Filter, Hilfe) erscheinen rechts vor dem Avatar, wenn sie als Kind mit `slot="aktionen"` in `` stehen. Die Leiste ist dunkelviolett, Text erbt Weiß; das Styling der Knöpfe bleibt beim Tool. + + ```html + + + + + ``` + + ```js + // oder in die automatisch eingefügte Leiste hängen (nach DOMContentLoaded, in React z.B. im useEffect) + const btn = document.createElement('button'); + btn.slot = 'aktionen'; + btn.textContent = 'Speichern'; + document.querySelector('hi-topbar')?.append(btn); + ``` **Content-Security-Policy des Tools erweitern** (sonst blockiert der Browser die Leiste): diff --git a/topbar/src/topbar.ts b/topbar/src/topbar.ts index de17494..46ba7cf 100644 --- a/topbar/src/topbar.ts +++ b/topbar/src/topbar.ts @@ -9,6 +9,9 @@ * Die Höhe steht als CSS-Variable --hi-topbar-height bereit, z.B. für * Layouts mit height: calc(100vh - var(--hi-topbar-height, 0px)). * + * Eigene Knöpfe des Tools erscheinen rechts vor dem Avatar, wenn sie als Kind + * mit slot="aktionen" in stehen. + * * Voraussetzung in der CSP des Tools: script-src, connect-src und img-src * müssen https://portal.handy-insel.de erlauben. */ @@ -58,6 +61,7 @@ a { color: inherit; text-decoration: none; } .app-name { opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; } .sep { width: 1px; height: 18px; background: rgba(255,255,255,.3); margin: 0 4px; } .spacer { flex: 1; } +::slotted(*) { flex: none; margin: 0 2px; } .avatar { width: 30px; height: 30px; border-radius: 50%; background: #fff; color: #2d1b69; font-size: 12px; font-weight: 700; display: grid; place-items: center; } .panel { position: absolute; top: ${HEIGHT + 6}px; background: var(--p-bg); color: var(--p-text); border-radius: 12px; @@ -211,6 +215,7 @@ class HiTopbar extends HTMLElement { Handy-Insel ${appName ? `${esc(appName)}` : ''} + ${ user ? ``