@anoki/fse-ui
Version:
FSE UI components library
91 lines (90 loc) • 2.71 kB
JavaScript
import { j as o } from "./index.es244.js";
import './components/ui/ShareButton/ShareButton.css';/* empty css */
import "./index.es.js";
import { clsx as l } from "./index.es246.js";
import { useState as p, useRef as u, useEffect as d } from "react";
import { ShareLink as f } from "./index.es207.js";
import { Meta as h } from "./index.es219.js";
import { Twitter as w } from "./index.es218.js";
import { Email as x } from "./index.es216.js";
import { Linkedin as k } from "./index.es217.js";
import { Whatsapp as j } from "./index.es220.js";
import { ActionIconText as $ } from "./index.es67.js";
const I = [
{
name: "Facebook",
Icon: /* @__PURE__ */ o.jsx(h, {}),
link: (e) => `https://www.facebook.com/sharer/sharer.php?u=${e}`
},
{
name: "X",
Icon: /* @__PURE__ */ o.jsx(w, {}),
link: (e, t) => `https://twitter.com/intent/tweet?url=${e}&text=${t}`
},
{
name: "Email",
Icon: /* @__PURE__ */ o.jsx(x, {}),
link: (e, t) => `mailto:?subject=${t}&body=${e}`
},
{
name: "Linkedin",
Icon: /* @__PURE__ */ o.jsx(k, {}),
link: (e, t) => `https://www.linkedin.com/shareArticle?mini=true&url=${e}&title=${t}`
},
{
name: "Whatsapp",
Icon: /* @__PURE__ */ o.jsx(j, {}),
link: (e, t) => `https://wa.me/?text=${`Dai un'occhiata a ${t}! ${e}`}`
}
], U = ({ textLabel: e, titleShared: t = "" }) => {
const [r, m] = p(!1), c = () => {
m(!r);
}, a = () => {
m(!1);
}, s = u(null);
return d(() => {
function n(i) {
s.current && !s.current.contains(i.target) && a();
}
return document.addEventListener("mousedown", n), () => {
document.removeEventListener("mousedown", n);
};
}, [a]), /* @__PURE__ */ o.jsxs(
"div",
{
className: l("social-dropdown-container", { open: r }),
ref: s,
children: [
/* @__PURE__ */ o.jsx(
$,
{
classNameComponent: "toggle-button",
textLabel: e,
icon: /* @__PURE__ */ o.jsx(f, {}),
handleAction: c,
classNameText: "fw-bold fs-7"
}
),
/* @__PURE__ */ o.jsx("div", { className: "social-links", children: I.map((n, i) => /* @__PURE__ */ o.jsxs(
"button",
{
className: "social-item",
onClick: () => window.open(
`${n.link(encodeURIComponent(window.location.href), encodeURIComponent(t))}`
),
rel: "noopener noreferrer",
children: [
n.Icon,
n.name
]
},
`socialIcon-${i}`
)) })
]
}
);
};
export {
U as ShareButton
};
//# sourceMappingURL=index.es123.js.map