fix(ui): make the shared three-part profile the canonical header
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { ButtonHTMLAttributes, ReactNode } from "react";
|
||||
import type { ButtonHTMLAttributes, ReactNode, Ref } from "react";
|
||||
|
||||
export interface AppHeaderProps {
|
||||
brand: ReactNode;
|
||||
@@ -74,10 +74,11 @@ export function HeaderNavigation<T extends string>({ label, value, items, onChan
|
||||
|
||||
export interface HeaderProfileProps {
|
||||
children: ReactNode;
|
||||
ref?: Ref<HTMLDivElement>;
|
||||
}
|
||||
|
||||
export function HeaderProfile({ children }: HeaderProfileProps) {
|
||||
return <div className="nodedc-header__profile">{children}</div>;
|
||||
export function HeaderProfile({ children, ref }: HeaderProfileProps) {
|
||||
return <div ref={ref} className="nodedc-header__profile">{children}</div>;
|
||||
}
|
||||
|
||||
export interface HeaderProfileButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "className" | "style"> {}
|
||||
|
||||
@@ -16,7 +16,7 @@ export interface UserProfileMenuAction {
|
||||
|
||||
export interface UserProfileMenuProps {
|
||||
displayName: string;
|
||||
/** Canonical profile label, independent menu icon, then avatar. Owns HeaderProfile. */
|
||||
/** Header is canonical. "default" retains the legacy compact trigger outside headers. */
|
||||
variant?: "default" | "header";
|
||||
subtitle?: string;
|
||||
avatarUrl?: string;
|
||||
@@ -29,7 +29,7 @@ export interface UserProfileMenuProps {
|
||||
|
||||
export function UserProfileMenu({
|
||||
displayName,
|
||||
variant = "default",
|
||||
variant = "header",
|
||||
subtitle,
|
||||
avatarUrl,
|
||||
coverImageUrl,
|
||||
@@ -45,19 +45,22 @@ export function UserProfileMenu({
|
||||
offset={10}
|
||||
surfaceClassName="nodedc-user-profile-menu"
|
||||
trigger={({ open, toggle, setTriggerRef, setAnchorRef, surfaceId }) => variant === "header" ? (
|
||||
<HeaderProfile>
|
||||
<HeaderProfileButton aria-haspopup="menu" aria-expanded={open} aria-controls={surfaceId} onClick={toggle}>
|
||||
<HeaderProfile ref={setAnchorRef}>
|
||||
<HeaderProfileButton aria-haspopup="menu" aria-expanded={open} aria-controls={surfaceId} onClick={(event) => { setTriggerRef(event.currentTarget); toggle(); }}>
|
||||
{triggerLabel ?? "Профиль"}
|
||||
</HeaderProfileButton>
|
||||
<IconButton
|
||||
ref={(node) => { setTriggerRef(node); setAnchorRef(node); }}
|
||||
ref={setTriggerRef}
|
||||
label={`Меню пользователя ${label}`}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
aria-controls={surfaceId}
|
||||
onClick={toggle}
|
||||
onClick={(event) => { setTriggerRef(event.currentTarget); toggle(); }}
|
||||
><Icon name={triggerIcon ?? "inbox"} size={20} strokeWidth={1.7} /></IconButton>
|
||||
<HeaderAvatar label={label} imageUrl={avatarUrl} />
|
||||
<button type="button" className="nodedc-user-profile-menu__trigger" aria-label={`Профиль ${label}`} aria-haspopup="menu" aria-expanded={open} aria-controls={surfaceId}
|
||||
onClick={(event) => { setTriggerRef(event.currentTarget); toggle(); }}>
|
||||
<HeaderAvatar label={label} imageUrl={avatarUrl} />
|
||||
</button>
|
||||
</HeaderProfile>
|
||||
) : (
|
||||
<button
|
||||
|
||||
Reference in New Issue
Block a user