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/icons.tsx | 228 ---------------------------------- docs/components/LogoContext/index.tsx | 169 ------------------------- docs/components/LogoContext/items.tsx | 91 -------------- docs/components/LogoContext/types.ts | 25 ---- 4 files changed, 513 deletions(-) delete mode 100644 docs/components/LogoContext/icons.tsx delete mode 100644 docs/components/LogoContext/index.tsx delete mode 100644 docs/components/LogoContext/items.tsx delete mode 100644 docs/components/LogoContext/types.ts (limited to 'docs/components/LogoContext') diff --git a/docs/components/LogoContext/icons.tsx b/docs/components/LogoContext/icons.tsx deleted file mode 100644 index dabefc2..0000000 --- a/docs/components/LogoContext/icons.tsx +++ /dev/null @@ -1,228 +0,0 @@ -import classNames from "classnames"; - -export const VercelLogo = ({ className }: { className?: string }) => ( - - - -); - -export const TurborepoLogo = ({ className }: { className?: string }) => ( - - - - - - - - - - -); - -export const TurbopackLogo = ({ className }: { className?: string }) => ( - - - - - - - - - - - - - - - - - - - - -); - -export const NextJSLogo = ({ className }: { className?: string }) => ( - - - - - - - - - - - - - - - - - - - - -); - -export const DesignSystemLogo = ({ className }: { className?: string }) => ( - - - - - - -); - -export const IconType = ({ className }: { className?: string }) => ( - - - - - -); 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} - - ))} -
-
- )} -
- ); -} diff --git a/docs/components/LogoContext/items.tsx b/docs/components/LogoContext/items.tsx deleted file mode 100644 index 3d15c01..0000000 --- a/docs/components/LogoContext/items.tsx +++ /dev/null @@ -1,91 +0,0 @@ -import { - VercelLogo, - TurborepoLogo, - TurbopackLogo, - IconType, - NextJSLogo, - DesignSystemLogo, -} from "./icons"; -import type { ContextItem, ContextList } from "./types"; -import copy from "copy-to-clipboard"; - -export const PLATFORM_MENU_ITEMS = ({ - theme, -}: ContextList): Array => [ - { - name: "copy-logo", - "aria-label": "Copy Logo as SVG to Clipboard", - children: "Copy Logo as SVG", - prefix: , - type: "copy", - onClick: () => { - copy( - ` - - ` - ); - }, - }, - { - name: "copy-wordmark", - "aria-label": "Copy Wordmark as SVG to Clipboard", - children: "Copy Wordmark as SVG", - prefix: , - type: "copy", - onClick: () => { - copy( - // NOTE: We include `xmlns` as this is required when the SVG isn't inlined. - `` - ); - }, - }, - { - name: "brand-guidelines", - "aria-label": "Open Brand Guidelines in New Tab", - children: "Brand Guidelines", - prefix: , - type: "external", - href: "https://vercel.com/design/brands", - }, -]; - -export const PRODUCT_MENU_ITEMS = ({ - site, -}: ContextList): Array => [ - { - name: "next-js", - "aria-label": "Open Next.js Home in New Tab", - children: "Next.js", - prefix: , - type: "external", - href: "https://nextjs.org", - }, - { - name: "HydroRollAI", - "aria-label": "Open Turborepo Home in New Tab", - disabled: site === "AI", - children: "HydroRollAI", - prefix: , - type: "internal", - href: "/AI", - }, - { - name: "HydroRollTRPG", - "aria-label": "Open Turbopack Home in New Tab", - disabled: site === "TRPG", - children: "HydroRollTRPG", - prefix: , - type: "internal", - href: "/TRPG", - }, -]; diff --git a/docs/components/LogoContext/types.ts b/docs/components/LogoContext/types.ts deleted file mode 100644 index ff7f644..0000000 --- a/docs/components/LogoContext/types.ts +++ /dev/null @@ -1,25 +0,0 @@ -import type { ReactNode } from "react"; -import { TurboSite } from "../SiteSwitcher"; - -type MenuItemType = "internal" | "external" | "copy"; - -export interface MenuItemProps extends ContextItem { - closeMenu?: () => void; - className?: string; -} - -export interface ContextList { - theme: string; - site: TurboSite; -} - -export interface ContextItem { - name: string; - "aria-label": string; - disabled?: boolean; - type: MenuItemType; - children: ReactNode; - prefix: ReactNode; - href?: string; - onClick?: () => void; -} -- cgit v1.2.3-70-g09d2