UNPKG

@anoki/fse-ui

Version:

FSE UI components library

165 lines (164 loc) • 6.47 kB
import { j as r } from "./index.es278.js"; import { useCopyToClipboardCurrentPage as a } from "./index.es350.js"; import { fromISODateToDateFormatted as d } from "./index.es349.js"; import { getFullNameInitials as $ } from "./index.es351.js"; import { splitInTwo as E } from "./index.es296.js"; import { clsx as s } from "./index.es280.js"; import { useMemo as t } from "react"; import { ActionIconText as S } from "./index.es9.js"; import { AuthorBlock as F } from "./index.es25.js"; import { Row as M } from "./index.es219.js"; import './components/ui/HeroContentCard/HeroContentCard.css';/* empty css */ import { ShareButton as R } from "./index.es232.js"; import { CopyLink as H } from "./index.es93.js"; import { Col as O } from "./index.es82.js"; import { CardCategory as V } from "./index.es42.js"; import { Tags as q } from "./index.es258.js"; const se = ({ data: e = {}, ImageComponent: g = "img", imageProps: f = {}, variant: l = "service", publishedLabel: T = "Pubblicato", readingTimeLabel: j = "Tempo di lettura", readingMinuteLabel: w = "min", tagsLabelTitle: C = "Argomenti trattati", shareLabel: I = "Condividi", copyLinkLabel: N = "Copia link", copiedTextLabel: y = "Link copiato", isPreview: o = !1, modeAuthenticated: m = !1, eventCardDescriptionTitle: b, tags: n }) => { var u, v, h; const { copyToClipboard: B, isCopied: k } = a(), A = t(() => e != null && e.updatedBy ? $( e.updatedBy.name ?? "", e.updatedBy.surname ?? "" ) : "-", [e.updatedBy]), [D, c] = t(() => !e.previewImageTitle || e.previewImageTitle.trim() === "" ? [null, null] : e.previewImageTitle.trim().split(/\s+/).length >= 4 ? E(e.previewImageTitle.toUpperCase()) : [e.previewImageTitle.toUpperCase(), null], [e.previewImageTitle]), L = t(() => { const i = e.readingTime ?? 0; return Math.ceil(Number(i) / 60) || 0; }, [e]), U = () => { if (!e.previewImageUrl) return null; if (l === "event") { const i = (x) => "eventCardTitle" in x || "eventTitle" in x; return /* @__PURE__ */ r.jsxs( "div", { className: s( l === "event" && "is-event", o ? "hero-event-preview" : "hero-event-container", m ? "margin-authenticated ratio-authenticated" : "" ), children: [ /* @__PURE__ */ r.jsx( "img", { className: "hero-event-background", src: e.previewImageUrl, alt: `Evento ${e.name}` } ), /* @__PURE__ */ r.jsxs("div", { className: "hero-event-content", children: [ /* @__PURE__ */ r.jsx( "img", { className: "hero-event-main-image", src: e.previewImageUrl, alt: `Evento ${e.name}` } ), /* @__PURE__ */ r.jsxs( O, { justifyContent: "space-between", className: "hero-event-card-container", children: [ /* @__PURE__ */ r.jsx("div", { children: i(e) && (e.eventCardTitle || e.eventCardDescription) && /* @__PURE__ */ r.jsx( V, { title: i(e) ? e.eventCardTitle ?? "-" : "-", className: "w-full", description: i(e) ? b ?? "-" : "-", description2: i(e) ? e.eventCardDescription ?? "-" : "-", classNameTitle: "text-slate-20 fs-5 md-fs-custom-2", classNameDescriptionTitle: "text-slate-28 fw-bold fs-6 md-fs-custom" } ) }), n && (n == null ? void 0 : n.length) > 0 && /* @__PURE__ */ r.jsx(q, { title: C, items: n ?? [] }) ] } ) ] }) ] } ); } return /* @__PURE__ */ r.jsxs( "div", { className: s( o ? "hero-service-detail-image" : "hero-fullscreen-image-container", m ? "margin-authenticated" : "" ), children: [ /* @__PURE__ */ r.jsx( g, { alt: `Service ${e.name} image`, src: e.previewImageUrl, style: { aspectRatio: 21 / 9 }, ...f } ), (e == null ? void 0 : e.previewImageTitle) && (e == null ? void 0 : e.previewImageTitle.trim()) !== "" && /* @__PURE__ */ r.jsxs( "p", { className: s( "short-title", e != null && e.previewImageTextAlign ? e == null ? void 0 : e.previewImageTextAlign : "" ), children: [ /* @__PURE__ */ r.jsx("span", { style: { color: e.previewImageTextColor }, children: D }), c && /* @__PURE__ */ r.jsx("span", { style: { color: e.previewImageTextColor }, children: c }) ] } ) ] } ); }, p = /* @__PURE__ */ r.jsxs(r.Fragment, { children: [ /* @__PURE__ */ r.jsxs("div", { className: "hero-action-author", children: [ /* @__PURE__ */ r.jsx( F, { authorName: (u = e == null ? void 0 : e.updatedBy) != null && u.name ? `${(v = e == null ? void 0 : e.updatedBy) == null ? void 0 : v.name} ${(h = e == null ? void 0 : e.updatedBy) == null ? void 0 : h.surname}` : "-", avatar: { initials: A }, publishedLabel: T, publishedDate: d(e.updatedAt ?? "", "it") ?? "-", readingTimeLabel: j, readingTimeValue: L, readingMinuteLabel: w } ), /* @__PURE__ */ r.jsxs(M, { gap: "x8", className: "hero-action-link", children: [ /* @__PURE__ */ r.jsx(R, { textLabel: I, titleShared: e.name }), /* @__PURE__ */ r.jsx("div", { className: "share-divider", children: /* @__PURE__ */ r.jsx( S, { textLabel: k ? y : N, icon: /* @__PURE__ */ r.jsx(H, {}), handleAction: B, classNameText: "fw-bold" } ) }) ] }) ] }), U() ] }); return o ? /* @__PURE__ */ r.jsx("div", { className: "hero-content-card-container-preview", children: p }) : p; }; export { se as HeroContentCard }; //# sourceMappingURL=index.es167.js.map