fix(ui): compose canonical three-part profile header
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { Dropdown } from "./Dropdown.js";
|
||||
import { HeaderAvatar } from "./AppHeader.js";
|
||||
import { HeaderAvatar, HeaderProfile, HeaderProfileButton } from "./AppHeader.js";
|
||||
import { IconButton } from "./Button.js";
|
||||
import { Icon, type IconName } from "./Icon.js";
|
||||
|
||||
export interface UserProfileMenuAction {
|
||||
@@ -15,6 +16,8 @@ export interface UserProfileMenuAction {
|
||||
|
||||
export interface UserProfileMenuProps {
|
||||
displayName: string;
|
||||
/** Canonical profile label, independent menu icon, then avatar. Owns HeaderProfile. */
|
||||
variant?: "default" | "header";
|
||||
subtitle?: string;
|
||||
avatarUrl?: string;
|
||||
coverImageUrl?: string;
|
||||
@@ -26,6 +29,7 @@ export interface UserProfileMenuProps {
|
||||
|
||||
export function UserProfileMenu({
|
||||
displayName,
|
||||
variant = "default",
|
||||
subtitle,
|
||||
avatarUrl,
|
||||
coverImageUrl,
|
||||
@@ -40,7 +44,22 @@ export function UserProfileMenu({
|
||||
width={296}
|
||||
offset={10}
|
||||
surfaceClassName="nodedc-user-profile-menu"
|
||||
trigger={({ open, toggle, setTriggerRef, surfaceId }) => (
|
||||
trigger={({ open, toggle, setTriggerRef, setAnchorRef, surfaceId }) => variant === "header" ? (
|
||||
<HeaderProfile>
|
||||
<HeaderProfileButton aria-haspopup="menu" aria-expanded={open} aria-controls={surfaceId} onClick={toggle}>
|
||||
{triggerLabel ?? "Профиль"}
|
||||
</HeaderProfileButton>
|
||||
<IconButton
|
||||
ref={(node) => { setTriggerRef(node); setAnchorRef(node); }}
|
||||
label={`Меню пользователя ${label}`}
|
||||
aria-haspopup="menu"
|
||||
aria-expanded={open}
|
||||
aria-controls={surfaceId}
|
||||
onClick={toggle}
|
||||
><Icon name={triggerIcon ?? "inbox"} size={20} strokeWidth={1.7} /></IconButton>
|
||||
<HeaderAvatar label={label} imageUrl={avatarUrl} />
|
||||
</HeaderProfile>
|
||||
) : (
|
||||
<button
|
||||
ref={setTriggerRef}
|
||||
type="button"
|
||||
|
||||
Reference in New Issue
Block a user