import React from "react"; import toast from "react-hot-toast"; import styled from "styled-components"; import { Modal, ModalProps } from "src/components/Modal"; import { Button } from "src/components/Button"; import { BiErrorAlt } from "react-icons/bi"; import { compress } from "compress-json"; import useConfig from "src/hooks/store/useConfig"; import { Input } from "src/components/Input"; import { baseURL } from "src/constants/data"; const StyledWarning = styled.p``; const StyledErrorWrapper = styled.div` display: flex; flex-direction: column; align-items: center; justify-content: center; color: ${({ theme }) => theme.TEXT_DANGER}; font-weight: 600; `; const StyledFlex = styled.div` display: flex; gap: 12px; `; const StyledContainer = styled.div` display: flex; flex-direction: column; gap: 16px; padding: 12px 0; border-top: 1px solid ${({ theme }) => theme.BACKGROUND_MODIFIER_ACCENT}; font-size: 12px; line-height: 16px; font-weight: 600; text-transform: uppercase; color: ${({ theme }) => theme.INTERACTIVE_NORMAL}; &:first-of-type { padding-top: 0; border: none; } `; export const ShareModal: React.FC = ({ visible, setVisible }) => { const json = useConfig((state) => state.json); const [encodedJson, setEncodedJson] = React.useState(""); const embedText = ``; const shareURL = `${baseURL}/editor?json=${encodedJson}`; React.useEffect(() => { if (visible) { const jsonEncode = compress(JSON.parse(json)); const jsonString = JSON.stringify(jsonEncode); setEncodedJson(encodeURIComponent(jsonString)); } }, [json, visible]); const handleShare = (value: string) => { navigator.clipboard.writeText(value); toast.success(`Link copied to clipboard.`); setVisible(false); }; return ( Create a Share Link {encodedJson.length > 5000 ? ( Link size exceeds 5000 characters, unable to generate link for file of this size! ) : ( <> Share Link Embed into your website )} ); };