diff --git a/src/components/CustomRoadmap/EmbedRoadmapModal.tsx b/src/components/CustomRoadmap/EmbedRoadmapModal.tsx new file mode 100644 index 000000000..8e3085e2c --- /dev/null +++ b/src/components/CustomRoadmap/EmbedRoadmapModal.tsx @@ -0,0 +1,81 @@ +import { useStore } from '@nanostores/react'; +import { Check, Copy } from 'lucide-react'; + +import { Modal } from '../Modal'; +import { useToast } from '../../hooks/use-toast'; +import { useCopyText } from '../../hooks/use-copy-text'; +import { currentRoadmap, isCurrentRoadmapPersonal } from '../../stores/roadmap'; +import { cn } from '../../lib/classname.ts'; + +type ShareRoadmapModalProps = { + onClose: () => void; +}; + +export function EmbedRoadmapModal(props: ShareRoadmapModalProps) { + const { onClose } = props; + + const toast = useToast(); + const $currentRoadmap = useStore(currentRoadmap); + const $isCurrentRoadmapPersonal = useStore(isCurrentRoadmapPersonal); + const roadmapId = $currentRoadmap?._id!; + + const { copyText, isCopied } = useCopyText(); + + const isDev = import.meta.env.DEV; + const baseUrl = isDev ? 'http://localhost:3000' : 'https://roadmap.sh'; + + const embedHtml = ``; + + return ( + + + + Embed Roadmap + + + + + + Copy the following HTML code and paste it into your website. + + { + e.currentTarget.select(); + copyText(embedHtml); + }} + className="w-full resize-none rounded-md border bg-gray-50 p-2 text-sm" + /> + + + + { + copyText(embedHtml); + }} + > + {isCopied ? ( + <> + + Copied + > + ) : ( + <> + + Copy Link + > + )} + + + + ); +} diff --git a/src/components/ShareRoadmapButton.tsx b/src/components/ShareRoadmapButton.tsx index 0a086cb41..2b339a8f6 100644 --- a/src/components/ShareRoadmapButton.tsx +++ b/src/components/ShareRoadmapButton.tsx @@ -1,6 +1,6 @@ import { Check, - Code, + Code, Code2, Copy, Facebook, Linkedin, @@ -12,6 +12,7 @@ import { useOutsideClick } from '../hooks/use-outside-click.ts'; import { useCopyText } from '../hooks/use-copy-text.ts'; import { cn } from '../lib/classname.ts'; import { TwitterIcon } from './ReactIcons/TwitterIcon.tsx'; +import { EmbedRoadmapModal } from './CustomRoadmap/EmbedRoadmapModal.tsx'; type ShareRoadmapButtonProps = { roadmapId?: string; @@ -25,6 +26,8 @@ export function ShareRoadmapButton(props: ShareRoadmapButtonProps) { const { isCopied, copyText } = useCopyText(); + const [isEmbedModalOpen, setIsEmbedModalOpen] = useState(false); + const containerRef = useRef(null); const [isDropdownOpen, setIsDropdownOpen] = useState(false); @@ -42,6 +45,13 @@ export function ShareRoadmapButton(props: ShareRoadmapButtonProps) { return ( + {isEmbedModalOpen && ( + { + setIsEmbedModalOpen(false); + }} + /> + )} setIsDropdownOpen(!isDropdownOpen)} className={cn( @@ -85,15 +95,15 @@ export function ShareRoadmapButton(props: ShareRoadmapButtonProps) { {allowEmbed && roadmapId && ( { - copyText(embedHtml); setIsDropdownOpen(false); + setIsEmbedModalOpen(true); }} className="flex w-full items-center gap-2 rounded-sm px-2 py-2 text-sm text-slate-100 hover:bg-slate-700" > - + - Copy Embed Code + Embed Roadmap )}
+ Copy the following HTML code and paste it into your website. +