diff --git a/app/lib/transformNpmCommand.ts b/app/lib/transformNpmCommand.ts new file mode 100644 index 00000000..0f9657ac --- /dev/null +++ b/app/lib/transformNpmCommand.ts @@ -0,0 +1,21 @@ +export type PackageManager = "npm" | "yarn" | "pnpm" | "bun"; + +export function transformNpmCommand( + prefix: string, + cmd: string, + packageManagerTarget: "yarn" | "bun" | "pnpm" | "npm", +) { + if (prefix === "npm") { + if (cmd.split(" ")[0] === "install" && packageManagerTarget === "yarn") { + return `${packageManagerTarget} ${cmd.replace("install", "add")}`; + } + return `${packageManagerTarget} ${cmd}`; + } + switch (packageManagerTarget) { + case "bun": + return `bunx ${cmd}`; + case "pnpm": + return `pnpm dlx ${cmd}`; + } + return `${prefix} ${cmd}`; +} diff --git a/app/routes/docs.$lang.$ref.tsx b/app/routes/docs.$lang.$ref.tsx index d5e63890..8d5c908d 100644 --- a/app/routes/docs.$lang.$ref.tsx +++ b/app/routes/docs.$lang.$ref.tsx @@ -268,7 +268,7 @@ function VersionSelect() { -
+
{branches.map((branch) => { return ( @@ -390,7 +390,7 @@ function ColorSchemeToggle() { replace action="/_actions/color-scheme" method="post" - className="flex flex-col gap-px" + className="flex w-40 flex-col gap-px" > -
+
Docs Blog Showcase diff --git a/app/styles/resources.css b/app/styles/resources.css index 936ff927..56a2d8a5 100644 --- a/app/styles/resources.css +++ b/app/styles/resources.css @@ -45,7 +45,7 @@ } &:hover [data-code-block-copy], - & [data-code-block-copy]:focus { + & [data-code-block-copy]:focus-within { @apply opacity-100; } diff --git a/app/ui/details-menu.tsx b/app/ui/details-menu.tsx index a5c012ec..eac4d956 100644 --- a/app/ui/details-menu.tsx +++ b/app/ui/details-menu.tsx @@ -1,5 +1,6 @@ import { forwardRef, useState, useRef, useEffect } from "react"; import { useLocation, useNavigation } from "@remix-run/react"; +import cx from "clsx"; /** * An enhanced `
` component that's intended to be used as a menu (a bit @@ -77,10 +78,15 @@ export const DetailsMenu = forwardRef< }); DetailsMenu.displayName = "DetailsMenu"; -export function DetailsPopup({ children }: { children: React.ReactNode }) { +type DetailsPopupProps = { + children: React.ReactNode; + className?: string; +}; + +export function DetailsPopup({ children, className }: DetailsPopupProps) { return ( -
-
+
+
{children}
diff --git a/app/ui/header.tsx b/app/ui/header.tsx index 664ddd31..0417e6e0 100644 --- a/app/ui/header.tsx +++ b/app/ui/header.tsx @@ -65,7 +65,7 @@ function HeaderMenuMobile({ className = "" }: { className: string }) { -
+ ); +} + +type CopyCodeBlockProps = { + copied: boolean; + onCopy: (packageManager: PackageManager) => void; +}; + +function CopyCodeBlock({ copied, onCopy }: CopyCodeBlockProps) { + const detailsRef = useRef(null); + return ( + + - {/* had to put these here instead of as a mask so we could add an opacity */} - - {copied ? ( - - ) : ( - - )} - - Copy code to clipboard - -
+ + + {copied ? ( + + ) : ( + + )} + + Copy code to clipboard + + +
+ +
+ {(["npm", "yarn", "pnpm", "bun"] as const).map((packageManager) => ( + + ))} +
+
+
+ ); }