UNPKG

@anoki/fse-ui

Version:

FSE UI components library

3 lines (2 loc) 2.08 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./components/ui/ShareButton/ShareButton.css');const n=require("./index.cjs237.js");;/* empty css */require("./index.cjs.js");const x=require("./index.cjs239.js"),c=require("react"),m=require("./index.cjs225.js"),d=require("./index.cjs214.js"),p=require("./index.cjs232.js"),j=require("./index.cjs194.js"),h=require("./index.cjs210.js"),w=require("./index.cjs234.js"),$=require("./index.cjs18.js"),R=[{name:"Facebook",Icon:n.jsxRuntimeExports.jsx(d.Meta,{}),link:e=>`https://www.facebook.com/sharer/sharer.php?u=${e}`},{name:"X",Icon:n.jsxRuntimeExports.jsx(p.Twitter,{}),link:(e,t)=>`https://twitter.com/intent/tweet?url=${e}&text=${t}`},{name:"Email",Icon:n.jsxRuntimeExports.jsx(j.Email,{}),link:(e,t)=>`mailto:?subject=${t}&body=${e}`},{name:"Linkedin",Icon:n.jsxRuntimeExports.jsx(h.Linkedin,{}),link:(e,t)=>`https://www.linkedin.com/shareArticle?mini=true&url=${e}&title=${t}`},{name:"Whatsapp",Icon:n.jsxRuntimeExports.jsx(w.Whatsapp,{}),link:(e,t)=>`https://wa.me/?text=${`Dai un'occhiata a ${t}! ${e}`}`}],f=({textLabel:e,titleShared:t=""})=>{const[s,a]=c.useState(!1),l=()=>{a(!s)},u=()=>{a(!1)},i=c.useRef(null);return c.useEffect(()=>{function o(r){i.current&&!i.current.contains(r.target)&&u()}return document.addEventListener("mousedown",o),()=>{document.removeEventListener("mousedown",o)}},[u]),n.jsxRuntimeExports.jsxs("div",{className:x.clsx("social-dropdown-container",{open:s}),ref:i,children:[n.jsxRuntimeExports.jsx($.ActionIconText,{classNameComponent:"toggle-button",textLabel:e,icon:n.jsxRuntimeExports.jsx(m.ShareLink,{}),handleAction:l,classNameText:"fw-bold fs-7"}),n.jsxRuntimeExports.jsx("div",{className:"social-links",children:R.map((o,r)=>n.jsxRuntimeExports.jsxs("button",{className:"social-item",onClick:()=>window.open(`${o.link(encodeURIComponent(window.location.href),encodeURIComponent(t))}`),rel:"noopener noreferrer",children:[o.Icon,o.name]},`socialIcon-${r}`))})]})};exports.ShareButton=f; //# sourceMappingURL=index.cjs125.js.map