UNPKG

@payfit/unity-components

Version:

74 lines (73 loc) • 2.87 kB
import { Actionable as e } from "../../actionable/Actionable.js"; import { Avatar as t } from "../../avatar/Avatar.js"; import { AvatarFallback as n } from "../../avatar/parts/AvatarFallback.js"; import { AvatarImage as r } from "../../avatar/parts/AvatarImage.js"; import { cloneElement as i, isValidElement as a, useId as o, useState as s } from "react"; import { uyMerge as c } from "@payfit/unity-themes"; import { jsx as l, jsxs as u } from "react/jsx-runtime"; import { Trans as d, useTranslation as f } from "react-i18next"; import { Icon as p } from "@payfit/unity-icons"; //#region src/core/components/app-profile-menu-button/parts/AppProfileAvatar.tsx var m = ({ avatar: e, avatarPair: o, avatarSize: s, avatarVariant: c, isPairAvatarVisible: d, labelId: f, title: p }) => /* @__PURE__ */ u(t, { "aria-labelledby": f, size: s, variant: c, children: [ /* @__PURE__ */ l(r, { src: e, alt: p ?? "" }), /* @__PURE__ */ l(n, { variant: "initials", delayMs: 100, children: p }), o && a(o) && i(o, { isHidden: !d }) ] }), h = ({ avatar: t, avatarPair: n, avatarSize: r, avatarVariant: i, labelId: a, title: h, uploadAvatarCallback: g, uploadAvatarDescription: _, uploadAvatarLabel: v }) => { let [y, b] = s(!1), [x, S] = s(!1), C = o(), { t: w } = f("unity"), T = !(y || x); return /* @__PURE__ */ u(e, { "aria-describedby": C, "aria-label": v ?? w((e) => e.unity.component.appMenu.footer.profileButton.avatar.change), className: c("uy:group/avatar uy:cursor-pointer uy:relative uy:leading-[0] uy:rounded-75 uy:focus-visible:outline-none uy:focus-visible:ring-2 uy:focus-visible:ring-utility-focus-ring uy:focus-visible:ring-offset-2"), onBlur: () => { S(!1); }, onFocus: () => { S(!0); }, onHoverEnd: () => { b(!1); }, onHoverStart: () => { b(!0); }, onPress: g, children: [/* @__PURE__ */ l(m, { avatar: t, avatarPair: n, avatarSize: r, avatarVariant: i, isPairAvatarVisible: T, labelId: a, title: h }), /* @__PURE__ */ u("div", { className: "uy:flex uy:pointer-events-none uy:opacity-0 uy:group-hover/avatar:opacity-90 uy:group-data-[focus-visible=true]/avatar:opacity-90 uy:group-focus-visible/avatar:opacity-90 uy:bg-utility-backdrop uy:rounded-75 uy:absolute uy:inset-0 uy:transition-all uy:duration-200 uy:items-center uy:justify-center", children: [/* @__PURE__ */ l(p, { alt: w((e) => e.unity.component.appMenu.footer.profileButton.avatar.camera), color: "content.inverted", size: 24, src: "CameraOutlined" }), /* @__PURE__ */ l("span", { className: "uy:sr-only", id: C, children: _ ?? /* @__PURE__ */ l(d, { ns: "unity", i18nKey: (e) => e.unity.component.appMenu.footer.profileButton.avatar.changeDescription }) })] })] }); }; //#endregion export { m as AppProfileAvatar, h as InteractiveAppProfileAvatar };