frontend: one header menu for the links, user, settings and alerts popovers
Part of the unification order in the UI sweep issue (step c). The four header menus each kept their own open state, dismiss hook and a copy of the popover CSS, and the copies had drifted (offset, padding, fade-in). A shared HeaderMenu now owns the state, the dismiss rules and the popover look; each menu supplies its button and its rows. The settings popover moves 0.15em lower and the settings and alerts popovers gain the fade-in.
This commit is contained in:
parent
25965341e0
commit
6f73bf0c55
9 changed files with 310 additions and 365 deletions
68
frontend/packages/shared/src/header-menu/HeaderMenu.css
Normal file
68
frontend/packages/shared/src/header-menu/HeaderMenu.css
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
@import "../icon-button/IconButton.css";
|
||||
/* <HeaderMenu> — the one popover every header menu (links, user, settings,
|
||||
alerts) opens. Right-anchored: each trigger sits at the end of a header's
|
||||
icon cluster, so a left anchor would push it off-screen. */
|
||||
.header-menu {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
.header-menu-popover {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.4em);
|
||||
right: 0;
|
||||
z-index: var(--z-popover);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 12em;
|
||||
padding: 0.4em;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-elev);
|
||||
box-shadow: var(--shadow-pop);
|
||||
animation: header-menu-enter 140ms ease;
|
||||
}
|
||||
/* A long list, such as the firing alerts: wide, and it scrolls. */
|
||||
.header-menu-wide {
|
||||
gap: 0.4em;
|
||||
width: min(26em, calc(100vw - 2em));
|
||||
max-height: 70vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
/* Mount-triggered, not a state transition: the popover only exists in the DOM
|
||||
while open, so a keyframe on entry is the right tool. */
|
||||
@keyframes header-menu-enter {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-0.25em) scale(0.98);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.header-menu-popover {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
:root[data-motion="reduce"] .header-menu-popover {
|
||||
animation: none;
|
||||
}
|
||||
:root[data-motion="allow"] .header-menu-popover {
|
||||
animation: header-menu-enter 140ms ease;
|
||||
}
|
||||
/* A row that is a link or a button. */
|
||||
.header-menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
min-height: 2.75em;
|
||||
padding: 0.4em 0.6em;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--fg);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.header-menu-item:hover {
|
||||
background: var(--bg);
|
||||
}
|
||||
82
frontend/packages/shared/src/header-menu/HeaderMenu.tsx
Normal file
82
frontend/packages/shared/src/header-menu/HeaderMenu.tsx
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
// <HeaderMenu> — a header icon button that opens a popover. The links, user,
|
||||
// settings and alerts menus all take this shape, so the open state, the
|
||||
// dismiss rules and the popover's look live here once: a menu supplies its
|
||||
// trigger and its rows and nothing else.
|
||||
//
|
||||
// A press outside or Escape closes it, and Escape puts the focus back on the
|
||||
// button. `children` is a function of `close` for rows that shut the menu when
|
||||
// picked (a link, a log-out), or plain content for rows that stay open.
|
||||
//
|
||||
// Styles live in `./HeaderMenu.css`, which each menu's own stylesheet
|
||||
// `@import`s: the dashboard's JS bundle loads `.css` imports as text, so a
|
||||
// component that imported it would not style there.
|
||||
import type { ComponentChildren } from "preact";
|
||||
import { useRef, useState } from "preact/hooks";
|
||||
import { IconButton } from "../icon-button/IconButton.js";
|
||||
import { useDismiss } from "../use-dismiss.js";
|
||||
|
||||
export interface HeaderMenuProps {
|
||||
/** The button's accessible name; also the popover's, unless `popoverLabel` is set. */
|
||||
label: string;
|
||||
/** What the button shows: an icon, or the avatar's initial. */
|
||||
trigger: ComponentChildren;
|
||||
popoverLabel?: string;
|
||||
/** For the button: the user menu's avatar colour comes through these. */
|
||||
triggerClass?: string;
|
||||
triggerStyle?: Record<string, string>;
|
||||
/** A class on the root, for a menu's own selectors. */
|
||||
class?: string;
|
||||
/** A class on the popover, such as `header-menu-wide` for a long list. */
|
||||
popoverClass?: string;
|
||||
children: ComponentChildren | ((close: () => void) => ComponentChildren);
|
||||
}
|
||||
|
||||
export function HeaderMenu({
|
||||
label,
|
||||
trigger,
|
||||
popoverLabel,
|
||||
triggerClass,
|
||||
triggerStyle,
|
||||
class: rootClass,
|
||||
popoverClass,
|
||||
children,
|
||||
}: HeaderMenuProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const close = () => setOpen(false);
|
||||
|
||||
useDismiss({
|
||||
open,
|
||||
onDismiss: close,
|
||||
inside: [rootRef],
|
||||
focusOnEscape: () => rootRef.current?.querySelector("button") ?? null,
|
||||
});
|
||||
|
||||
return (
|
||||
<div
|
||||
class={["header-menu", rootClass].filter(Boolean).join(" ")}
|
||||
ref={rootRef}
|
||||
>
|
||||
<IconButton
|
||||
class={triggerClass}
|
||||
style={triggerStyle}
|
||||
label={label}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
expanded={open}
|
||||
>
|
||||
{trigger}
|
||||
</IconButton>
|
||||
{open ? (
|
||||
<div
|
||||
class={["header-menu-popover", popoverClass]
|
||||
.filter(Boolean)
|
||||
.join(" ")}
|
||||
role="group"
|
||||
aria-label={popoverLabel ?? label}
|
||||
>
|
||||
{typeof children === "function" ? children(close) : children}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
creates a new `.jg-node` DOM node when its `key` (the node id) is
|
||||
genuinely new, so this only plays once per node, the first time it
|
||||
appears in a fetched snapshot. Same shape as Shell.css's
|
||||
`shell-page-enter` / the links menu's `links-menu-popover-enter` —
|
||||
`shell-page-enter` / the header menu's `header-menu-enter` —
|
||||
see either for the three-rule motion-guard this mirrors. */
|
||||
.jg-node {
|
||||
margin: 0;
|
||||
|
|
|
|||
|
|
@ -1,63 +1,5 @@
|
|||
@import "../icon-button/IconButton.css";
|
||||
/* <LinksMenu> (@hive/shared) — a header icon button (the shared `IconButton`)
|
||||
and its popover. No `margin-left: auto` here: the mounting page's header owns
|
||||
pushing the action group to the right edge (the swarm UI's
|
||||
`.shell-header-actions`, the dashboard's `.dashboard-chrome-actions`). */
|
||||
.links-menu {
|
||||
position: relative;
|
||||
}
|
||||
.links-menu-popover {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.4em);
|
||||
right: 0;
|
||||
z-index: var(--z-popover);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 10em;
|
||||
padding: 0.4em;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-elev);
|
||||
box-shadow: var(--shadow-pop);
|
||||
animation: links-menu-popover-enter 140ms ease;
|
||||
}
|
||||
/* Mount-triggered, not a state transition — the popover only exists in
|
||||
the DOM while open (`{open ? <div> : null}`), so a keyframe animation
|
||||
on entry is the right tool, same shape as `.shell-body`'s own
|
||||
`shell-page-enter` (Shell.css) — that's the precedent every popover
|
||||
in this issue's "menus should animate" ask follows. */
|
||||
@keyframes links-menu-popover-enter {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-0.25em) scale(0.98);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.links-menu-popover {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
:root[data-motion="reduce"] .links-menu-popover {
|
||||
animation: none;
|
||||
}
|
||||
:root[data-motion="allow"] .links-menu-popover {
|
||||
animation: links-menu-popover-enter 140ms ease;
|
||||
}
|
||||
.links-menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
min-height: 2.75em;
|
||||
padding: 0.4em 0.6em;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--fg);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.links-menu-item:hover {
|
||||
background: var(--bg);
|
||||
}
|
||||
/* <LinksMenu> (@hive/shared) — a `HeaderMenu` of links; the popover and the
|
||||
link row are `HeaderMenu.css`'s. No `margin-left: auto` here: the mounting
|
||||
page's header owns pushing the action group to the right edge (the swarm
|
||||
UI's `.shell-header-actions`, the dashboard's `.dashboard-chrome-actions`). */
|
||||
@import "../header-menu/HeaderMenu.css";
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@
|
|||
// imports or `@import`s itself: the dashboard's JS bundle loads `.css`
|
||||
// imports as text, so a component that imported it would not style there
|
||||
// (the same split as `UserMenu`).
|
||||
import { useRef, useState } from "preact/hooks";
|
||||
import { IconButton } from "../icon-button/IconButton.js";
|
||||
import { HeaderMenu } from "../header-menu/HeaderMenu.js";
|
||||
import { LinkIcon } from "../icons.js";
|
||||
import { useDismiss } from "../use-dismiss.js";
|
||||
import { linkAttrs, type MenuLink } from "./links.js";
|
||||
|
||||
export type { MenuLink };
|
||||
|
|
@ -26,44 +24,24 @@ export function LinksMenu({
|
|||
/** The button's accessible name. */
|
||||
label?: string;
|
||||
}) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
// A press outside or Escape closes it; Escape puts the focus back on the button.
|
||||
useDismiss({
|
||||
open,
|
||||
onDismiss: () => setOpen(false),
|
||||
inside: [rootRef],
|
||||
focusOnEscape: () => rootRef.current?.querySelector("button") ?? null,
|
||||
});
|
||||
|
||||
if (links.length === 0) return null;
|
||||
|
||||
return (
|
||||
<div class="links-menu" ref={rootRef}>
|
||||
<IconButton
|
||||
label={label}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
expanded={open}
|
||||
>
|
||||
<LinkIcon />
|
||||
</IconButton>
|
||||
{open ? (
|
||||
<div class="links-menu-popover" role="group" aria-label={label}>
|
||||
{links.map((link) => (
|
||||
<a
|
||||
key={link.url}
|
||||
class="links-menu-item"
|
||||
href={link.url}
|
||||
{...linkAttrs(link)}
|
||||
onClick={() => setOpen(false)}
|
||||
>
|
||||
{link.icon ? <span aria-hidden="true">{link.icon}</span> : null}
|
||||
{link.label}
|
||||
</a>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<HeaderMenu label={label} trigger={<LinkIcon />}>
|
||||
{(close) =>
|
||||
links.map((link) => (
|
||||
<a
|
||||
key={link.url}
|
||||
class="header-menu-item"
|
||||
href={link.url}
|
||||
{...linkAttrs(link)}
|
||||
onClick={close}
|
||||
>
|
||||
{link.icon ? <span aria-hidden="true">{link.icon}</span> : null}
|
||||
{link.label}
|
||||
</a>
|
||||
))
|
||||
}
|
||||
</HeaderMenu>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,31 +1,5 @@
|
|||
@import "../icon-button/IconButton.css";
|
||||
/* <SettingsMenu> popover — matches `@hive/shared`'s `Dropdown`
|
||||
(`../dropdown/Dropdown.css`, `.ui-dropdown`) values exactly
|
||||
(background/border/radius/shadow): the values are reused, not the
|
||||
component, because this popover holds `<select>` rows, not `Dropdown`'s
|
||||
command-dispatch `<button>`s. Right-anchored — this trigger lives at
|
||||
the end of a header's icon-trigger cluster in every page that mounts
|
||||
it, so a left anchor would push it off-screen. */
|
||||
.settings-menu-anchor {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
}
|
||||
.settings-menu-popover {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.25em);
|
||||
right: 0;
|
||||
left: auto;
|
||||
z-index: var(--z-popover);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.15em;
|
||||
min-width: 12em;
|
||||
padding: 0.5em;
|
||||
background: var(--bg-elev);
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
box-shadow: var(--shadow-pop);
|
||||
}
|
||||
@import "../header-menu/HeaderMenu.css";
|
||||
/* <SettingsMenu> — the theme and motion rows inside a `HeaderMenu` popover. */
|
||||
.settings-menu-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@
|
|||
// once, high in its tree, with the SAME key strings passed to this
|
||||
// component, so the two stay in sync without this component owning any
|
||||
// page-specific naming decision.
|
||||
import { useRef, useState } from "preact/hooks";
|
||||
import type { ComponentChildren } from "preact";
|
||||
import { IconButton } from "../icon-button/IconButton.js";
|
||||
import { HeaderMenu } from "../header-menu/HeaderMenu.js";
|
||||
import { GearIcon } from "../icons.js";
|
||||
import { useDismiss } from "../use-dismiss.js";
|
||||
import { useThemeOverride } from "./theme-apply.js";
|
||||
import { AUTO_THEME, THEMES } from "./themes.js";
|
||||
import { useMotionOverride, type MotionOverride } from "./motion-apply.js";
|
||||
|
|
@ -61,63 +59,40 @@ export function SettingsMenu({
|
|||
motionKey,
|
||||
children,
|
||||
}: SettingsMenuProps) {
|
||||
const [open, setOpen] = useState(false);
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
const [theme, setTheme] = useThemeOverride(themeKey);
|
||||
const [motion, setMotion] = useMotionOverride(motionKey);
|
||||
|
||||
// A press outside or Escape closes it; Escape puts the focus back on the button.
|
||||
useDismiss({
|
||||
open,
|
||||
onDismiss: () => setOpen(false),
|
||||
inside: [rootRef],
|
||||
focusOnEscape: () => rootRef.current?.querySelector("button") ?? null,
|
||||
});
|
||||
|
||||
return (
|
||||
<div class="settings-menu-anchor" ref={rootRef}>
|
||||
<IconButton
|
||||
label="settings"
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
expanded={open}
|
||||
>
|
||||
<GearIcon />
|
||||
</IconButton>
|
||||
{open ? (
|
||||
<div class="settings-menu-popover" role="group" aria-label="settings">
|
||||
<label class="settings-menu-row">
|
||||
<span>theme</span>
|
||||
<select
|
||||
value={theme}
|
||||
onChange={(e) => setTheme((e.target as HTMLSelectElement).value)}
|
||||
>
|
||||
{THEME_OPTIONS.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label class="settings-menu-row">
|
||||
<span>motion</span>
|
||||
<select
|
||||
value={motion}
|
||||
onChange={(e) =>
|
||||
setMotion(
|
||||
(e.target as HTMLSelectElement).value as MotionOverride,
|
||||
)
|
||||
}
|
||||
>
|
||||
{MOTION_OPTIONS.map((o) => (
|
||||
<option key={o} value={o}>
|
||||
{o}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{children}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<HeaderMenu label="settings" trigger={<GearIcon />}>
|
||||
<label class="settings-menu-row">
|
||||
<span>theme</span>
|
||||
<select
|
||||
value={theme}
|
||||
onChange={(e) => setTheme((e.target as HTMLSelectElement).value)}
|
||||
>
|
||||
{THEME_OPTIONS.map((o) => (
|
||||
<option key={o.id} value={o.id}>
|
||||
{o.label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<label class="settings-menu-row">
|
||||
<span>motion</span>
|
||||
<select
|
||||
value={motion}
|
||||
onChange={(e) =>
|
||||
setMotion((e.target as HTMLSelectElement).value as MotionOverride)
|
||||
}
|
||||
>
|
||||
{MOTION_OPTIONS.map((o) => (
|
||||
<option key={o} value={o}>
|
||||
{o}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
{children}
|
||||
</HeaderMenu>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +1,7 @@
|
|||
@import "../icon-button/IconButton.css";
|
||||
/* <UserMenu> (@hive/shared) — same header icon-button + popover chrome as
|
||||
`LinksMenu`/`SettingsMenu`, except the trigger is a round, accent-
|
||||
coloured initials avatar rather than a glyph-on-transparent button —
|
||||
this is the "who is this" affordance, the other two are quiet chrome.
|
||||
Kept as its own stylesheet for the same reason `SettingsMenu.css`
|
||||
gives: three small, independently-evolving popovers that happen to
|
||||
look alike today, not one component with three skins. */
|
||||
.user-menu {
|
||||
position: relative;
|
||||
}
|
||||
@import "../header-menu/HeaderMenu.css";
|
||||
/* <UserMenu> (@hive/shared) — a `HeaderMenu` whose trigger is a round, accent-
|
||||
coloured initials avatar rather than a glyph on a transparent button: this is
|
||||
the "who is this" affordance, the other menus are quiet chrome. */
|
||||
/* The round shape and the open outline are the shared icon button's; the fill is
|
||||
the accent inline on the element. */
|
||||
.ui-icon-button.user-menu-button {
|
||||
|
|
@ -20,45 +13,6 @@
|
|||
.ui-icon-button.user-menu-button[aria-expanded="true"] {
|
||||
outline: 1px solid var(--fg);
|
||||
}
|
||||
.user-menu-popover {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.4em);
|
||||
right: 0;
|
||||
z-index: var(--z-popover);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-width: 12em;
|
||||
padding: 0.4em;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: var(--radius-md);
|
||||
background: var(--bg-elev);
|
||||
box-shadow: var(--shadow-pop);
|
||||
animation: user-menu-popover-enter 140ms ease;
|
||||
}
|
||||
/* Mount-triggered, same shape as `LinksMenu.css`'s own version — see
|
||||
its comment for why a keyframe (not a transition) is the right tool
|
||||
here. */
|
||||
@keyframes user-menu-popover-enter {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-0.25em) scale(0.98);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: none;
|
||||
}
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.user-menu-popover {
|
||||
animation: none;
|
||||
}
|
||||
}
|
||||
:root[data-motion="reduce"] .user-menu-popover {
|
||||
animation: none;
|
||||
}
|
||||
:root[data-motion="allow"] .user-menu-popover {
|
||||
animation: user-menu-popover-enter 140ms ease;
|
||||
}
|
||||
.user-menu-name {
|
||||
padding: 0.4em 0.6em 0.5em;
|
||||
border-bottom: 1px solid var(--border);
|
||||
|
|
@ -69,16 +23,3 @@
|
|||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.user-menu-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 2.75em;
|
||||
padding: 0.4em 0.6em;
|
||||
border-radius: var(--radius-sm);
|
||||
color: var(--fg);
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.user-menu-item:hover {
|
||||
background: var(--bg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,9 +15,8 @@
|
|||
// Styles live in `@hive/shared/user-menu.css`, which the mounting page
|
||||
// imports or `@import`s itself: the dashboard's JS bundle loads `.css`
|
||||
// imports as text, so a component that imported it would not style there.
|
||||
import { useDismiss } from "../use-dismiss.js";
|
||||
import { useEffect, useRef, useState } from "preact/hooks";
|
||||
import { IconButton } from "../icon-button/IconButton.js";
|
||||
import { useEffect, useState } from "preact/hooks";
|
||||
import { HeaderMenu } from "../header-menu/HeaderMenu.js";
|
||||
import {
|
||||
accountLinks,
|
||||
initialOf,
|
||||
|
|
@ -42,8 +41,6 @@ export function UserMenu({
|
|||
onLogout?: () => void;
|
||||
}) {
|
||||
const [who, setWho] = useState<WhoAmI | null>(null);
|
||||
const [open, setOpen] = useState(false);
|
||||
const rootRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
|
|
@ -62,56 +59,46 @@ export function UserMenu({
|
|||
};
|
||||
}, [whoamiUrl]);
|
||||
|
||||
// A press outside or Escape closes it; Escape puts the focus back on the button.
|
||||
useDismiss({
|
||||
open,
|
||||
onDismiss: () => setOpen(false),
|
||||
inside: [rootRef],
|
||||
focusOnEscape: () => rootRef.current?.querySelector("button") ?? null,
|
||||
});
|
||||
|
||||
const label = labelOf(who);
|
||||
const links = accountLinks(autheliaUrl);
|
||||
|
||||
return (
|
||||
<div class="user-menu" ref={rootRef}>
|
||||
<IconButton
|
||||
class="user-menu-button"
|
||||
style={{ background: pickAccent(label ?? "operator") }}
|
||||
label={label ? `signed in as ${label}` : "account"}
|
||||
onClick={() => setOpen((v) => !v)}
|
||||
expanded={open}
|
||||
>
|
||||
{initialOf(label)}
|
||||
</IconButton>
|
||||
{open ? (
|
||||
<div class="user-menu-popover" role="group" aria-label="account">
|
||||
<HeaderMenu
|
||||
class="user-menu"
|
||||
triggerClass="user-menu-button"
|
||||
triggerStyle={{ background: pickAccent(label ?? "operator") }}
|
||||
label={label ? `signed in as ${label}` : "account"}
|
||||
popoverLabel="account"
|
||||
trigger={initialOf(label)}
|
||||
>
|
||||
{(close) => (
|
||||
<>
|
||||
{label ? <div class="user-menu-name">{label}</div> : null}
|
||||
{links ? (
|
||||
<>
|
||||
<a
|
||||
class="user-menu-item"
|
||||
class="header-menu-item"
|
||||
href={links.settings}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
onClick={() => setOpen(false)}
|
||||
onClick={close}
|
||||
>
|
||||
authelia settings
|
||||
</a>
|
||||
<a
|
||||
class="user-menu-item"
|
||||
class="header-menu-item"
|
||||
href={links.logout}
|
||||
onClick={() => {
|
||||
onLogout?.();
|
||||
setOpen(false);
|
||||
close();
|
||||
}}
|
||||
>
|
||||
log out
|
||||
</a>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</HeaderMenu>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue