UNPKG

@prokodo/ui

Version:

UI components for production-grade Next.js + Headless CMS (Strapi, Contentful, Headless WordPress) websites by prokodo – built for Core Web Vitals & SEO.

56 lines (55 loc) 1.45 kB
var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); import { jsx } from "react/jsx-runtime"; import { create } from "../../helpers/bem.js"; import styles from "./Avatar.module.scss.js"; import { Image } from "../image/Image.js"; import { Icon, getIconSize } from "../icon/Icon.js"; import { Link } from "../link/Link.js"; const bem = create(styles, "Avatar"); function AvatarView({ className, variant = "primary", size = "sm", image, redirect, ...rest }) { const rootClass = bem( void 0, { [variant]: true, [`has-size-${size}`]: true }, className ); const inner = /* @__PURE__ */ jsx("div", { ...rest, className: rootClass, tabIndex: -1, children: image ? /* @__PURE__ */ jsx( Image, { ...image, className: bem("image", void 0, image.className), tabIndex: 0 } ) : /* @__PURE__ */ jsx( Icon, { className: bem("icon", { [variant]: true }), name: "UserIcon", size: getIconSize(size) * 2, color: !["inherit", "white"].includes(variant) ? "white" : void 0 } ) }); return redirect ? /* @__PURE__ */ jsx( Link, { ...redirect, className: bem( "link", { [variant]: true, [`has-size-${size}`]: true }, redirect.className ), children: inner } ) : inner; } __name(AvatarView, "AvatarView"); export { AvatarView };