UNPKG

@anoki/fse-ui

Version:

FSE UI components library

165 lines (164 loc) • 6.45 kB
import { j as r } from "./index.es237.js"; import { useCopyToClipboardCurrentPage as U } from "./index.es308.js"; import { fromISODateToDateFormatted as a } from "./index.es307.js"; import { getFullNameInitials as $ } from "./index.es309.js"; import { splitInTwo as E } from "./index.es255.js"; import { clsx as s } from "./index.es239.js"; import { useMemo as t } from "react"; import { ActionIconText as S } from "./index.es18.js"; import { AuthorBlock as F } from "./index.es26.js"; import { Row as M } from "./index.es116.js"; import './components/ui/HeroContentCard/HeroContentCard.css';/* empty css */ import { ShareButton as R } from "./index.es125.js"; import { CopyLink as H } from "./index.es181.js"; import { Col as O } from "./index.es61.js"; import { CardCategory as V } from "./index.es36.js"; import { Tags as q } from "./index.es147.js"; const se = ({ data: e = {}, ImageComponent: x = "img", imageProps: f = {}, variant: l = "service", publishedLabel: T = "Pubblicato", readingTimeLabel: j = "Tempo di lettura", readingMinuteLabel: C = "min", tagsLabelTitle: w = "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: d } = U(), k = t(() => e != null && e.updatedBy ? $( e.updatedBy.name ?? "", e.updatedBy.surname ?? "" ) : "-", [e.updatedBy]), [A, 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]), D = t(() => { const i = e.readingTime ?? 0; return Math.ceil(Number(i) / 60) || 0; }, [e]), L = () => { if (!e.previewImageUrl) return null; if (l === "event") { const i = (g) => "eventCardTitle" in g || "eventTitle" in g; 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: w, 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( x, { 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.gradientColor }, children: A }), c && /* @__PURE__ */ r.jsx("span", { style: { color: e.gradientColor }, 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: k }, publishedLabel: T, publishedDate: a(e.updatedAt ?? "", "it") ?? "-", readingTimeLabel: j, readingTimeValue: D, readingMinuteLabel: C } ), /* @__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: d ? y : N, icon: /* @__PURE__ */ r.jsx(H, {}), handleAction: B, classNameText: "fw-bold" } ) }) ] }) ] }), L() ] }); return o ? /* @__PURE__ */ r.jsx("div", { className: "hero-content-card-container-preview", children: p }) : p; }; export { se as HeroContentCard }; //# sourceMappingURL=index.es99.js.map