Home / File/ code-block-command.tsx — ui Source File

code-block-command.tsx — ui Source File

Architecture documentation for code-block-command.tsx, a tsx file in the ui codebase. 8 imports, 0 dependents.

File tsx ComponentRegistry UIPrimitives 8 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  baae3241_177a_8f9c_1fe0_1ee553f9d099["code-block-command.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3["lucide-react"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3
  48fee787_8a56_cd8d_3e04_332bb934da24["unist"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> 48fee787_8a56_cd8d_3e04_332bb934da24
  8c6845ea_e0db_55db_4a65_df2f64d9e581["use-config"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> 8c6845ea_e0db_55db_4a65_df2f64d9e581
  402113bd_a10d_0255_fccf_87fa40fd281a["copy-button"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> 402113bd_a10d_0255_fccf_87fa40fd281a
  699f76b5_9b45_8d21_7fd0_f3e642c5c848["tabs"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> 699f76b5_9b45_8d21_7fd0_f3e642c5c848
  aa2f3ec6_f291_3763_88ec_65a3f5ad5939["button"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> aa2f3ec6_f291_3763_88ec_65a3f5ad5939
  ff4adc50_4c10_539a_2d63_f3d4b2f1ec61["tabs"]
  baae3241_177a_8f9c_1fe0_1ee553f9d099 --> ff4adc50_4c10_539a_2d63_f3d4b2f1ec61
  style baae3241_177a_8f9c_1fe0_1ee553f9d099 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { CheckIcon, ClipboardIcon } from "lucide-react"

import { NpmCommands } from "@/types/unist"
import { useConfig } from "@/hooks/use-config"
import { copyToClipboardWithMeta } from "@/components/copy-button"
import { Tabs } from "@/registry/default/ui/tabs"
import { Button } from "@/registry/new-york/ui/button"
import { TabsContent, TabsList, TabsTrigger } from "@/registry/new-york/ui/tabs"

export function CodeBlockCommand({
  __npmCommand__,
  __yarnCommand__,
  __pnpmCommand__,
  __bunCommand__,
}: React.ComponentProps<"pre"> & NpmCommands) {
  const [config, setConfig] = useConfig()
  const [hasCopied, setHasCopied] = React.useState(false)

  React.useEffect(() => {
    if (hasCopied) {
      const timer = setTimeout(() => setHasCopied(false), 2000)
      return () => clearTimeout(timer)
    }
  }, [hasCopied])

  const packageManager = config.packageManager || "pnpm"
  const tabs = React.useMemo(() => {
    return {
      pnpm: __pnpmCommand__,
      npm: __npmCommand__,
      yarn: __yarnCommand__,
      bun: __bunCommand__,
    }
  }, [__npmCommand__, __pnpmCommand__, __yarnCommand__, __bunCommand__])

  const copyCommand = React.useCallback(() => {
    const command = tabs[packageManager]

    if (!command) {
      return
    }

    copyToClipboardWithMeta(command, {
      name: "copy_npm_command",
      properties: {
        command,
        pm: packageManager,
      },
    })
    setHasCopied(true)
  }, [packageManager, tabs])

  return (
    <div className="relative mt-6 max-h-[650px] overflow-x-auto rounded-xl bg-zinc-950 dark:bg-zinc-900">
      <Tabs
        value={packageManager}
        onValueChange={(value) => {
          setConfig({
            ...config,
            packageManager: value as "pnpm" | "npm" | "yarn" | "bun",
          })
        }}
      >
        <div className="flex items-center justify-between border-b border-zinc-800 bg-zinc-900 px-3 pt-2.5">
          <TabsList className="h-7 translate-y-[2px] gap-3 bg-transparent p-0 pl-1">
            {Object.entries(tabs).map(([key, value]) => {
              return (
                <TabsTrigger
                  key={key}
                  value={key}
                  className="rounded-none border-b border-transparent bg-transparent p-0 pb-1.5 font-mono text-zinc-400 data-[state=active]:border-b-zinc-50 data-[state=active]:bg-transparent data-[state=active]:text-zinc-50"
                >
                  {key}
                </TabsTrigger>
              )
            })}
          </TabsList>
        </div>
        <div className="overflow-x-auto">
          {Object.entries(tabs).map(([key, value]) => {
            return (
              <TabsContent key={key} value={key} className="mt-0">
                <pre className="px-4 py-5">
                  <code
                    className="relative font-mono text-sm leading-none"
                    data-language="bash"
                  >
                    {value}
                  </code>
                </pre>
              </TabsContent>
            )
          })}
        </div>
      </Tabs>
      <Button
        size="icon"
        variant="ghost"
        className="absolute right-2.5 top-2 z-10 h-6 w-6 text-zinc-50 hover:bg-zinc-700 hover:text-zinc-50 [&_svg]:h-3 [&_svg]:w-3"
        onClick={copyCommand}
      >
        <span className="sr-only">Copy</span>
        {hasCopied ? <CheckIcon /> : <ClipboardIcon />}
      </Button>
    </div>
  )
}

Subdomains

Functions

Dependencies

  • button
  • copy-button
  • lucide-react
  • react
  • tabs
  • tabs
  • unist
  • use-config

Frequently Asked Questions

What does code-block-command.tsx do?
code-block-command.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, UIPrimitives subdomain.
What functions are defined in code-block-command.tsx?
code-block-command.tsx defines 1 function(s): CodeBlockCommand.
What does code-block-command.tsx depend on?
code-block-command.tsx imports 8 module(s): button, copy-button, lucide-react, react, tabs, tabs, unist, use-config.
Where is code-block-command.tsx in the architecture?
code-block-command.tsx is located at deprecated/www/components/code-block-command.tsx (domain: ComponentRegistry, subdomain: UIPrimitives, directory: deprecated/www/components).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free