From 9f0d43fe099a95ab1516ae951dcb60a89e76a5a5 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 3 Nov 2023 21:13:33 +0800 Subject: chore: delete useless codes --- docs/components/LogoContext/index.tsx | 169 ---------------------------------- 1 file changed, 169 deletions(-) delete mode 100644 docs/components/LogoContext/index.tsx (limited to 'docs/components/LogoContext/index.tsx') diff --git a/docs/components/LogoContext/index.tsx b/docs/components/LogoContext/index.tsx deleted file mode 100644 index 3f03740..0000000 --- a/docs/components/LogoContext/index.tsx +++ /dev/null @@ -1,169 +0,0 @@ -import { useEffect, useCallback, useState, useRef } from "react"; -import { useTheme } from "nextra-theme-docs"; -import Link from "next/link"; -import classNames from "classnames"; -import { VercelLogo } from "./icons"; -import { PRODUCT_MENU_ITEMS, PLATFORM_MENU_ITEMS } from "./items"; -import type { MenuItemProps } from "./types"; -import { MouseEvent } from "react"; -import { useTurboSite } from "../SiteSwitcher"; - -function MenuDivider({ children, ...other }: { children: string }) { - return ( -

- {children} -

- ); -} - -function MenuItem({ - children, - prefix, - className, - type, - href, - onClick, - closeMenu, - disabled, - ...other -}: MenuItemProps) { - const [copied, setCopied] = useState(false); - - const handleClick = () => { - if (onClick) { - onClick(); - } - if (type === "copy") { - setCopied(true); - } else { - closeMenu(); - } - }; - - useEffect(() => { - if (copied) { - const timeout = setTimeout(() => { - setCopied(false); - closeMenu(); - }, 2000); - return () => clearTimeout(timeout); - } - }, [copied, closeMenu]); - - const classes = classNames( - className, - "group flex items-center px-4 py-2 text-sm dark:hover:bg-gray-800 hover:bg-gray-200 w-full rounded-md" - ); - if (type === "internal") { - return ( - - {prefix} - {children} - - ); - } - if (type === "external") { - return ( - - {prefix} - {children} - - ); - } - - if (type === "copy") { - return ( - - ); - } -} - -export function LogoContext() { - const [open, setOpen] = useState(false); - const site = useTurboSite(); - const menu = useRef(null); - const { theme = "dark" } = useTheme(); - - const toggleMenu = (e: MouseEvent) => { - e.preventDefault(); - if (e.type === "contextmenu") { - setOpen((prev) => !prev); - } else { - setOpen(false); - window.open(`https://vercel.com`, "_blank"); - } - }; - - const onClickOutside: EventListener = useCallback( - (e) => { - if (menu.current && open && !menu.current.contains(e.target)) { - setOpen(false); - } - }, - [open] - ); - - useEffect(() => { - document.addEventListener("click", onClickOutside, true); - return () => { - document.removeEventListener("click", onClickOutside, true); - }; - }, [onClickOutside]); - - return ( -
- - {open && ( -
-
- Platform - {PLATFORM_MENU_ITEMS({ theme, site }).map((item) => ( - setOpen(false)} - {...item} - > - {item.children} - - ))} - Products - {PRODUCT_MENU_ITEMS({ theme, site }).map((item) => ( - setOpen(false)} - {...item} - > - {item.children} - - ))} -
-
- )} -
- ); -} -- cgit v1.2.3-70-g09d2