Home / File/ chart-copy-button.tsx — ui Source File

chart-copy-button.tsx — ui Source File

Architecture documentation for chart-copy-button.tsx, a tsx file in the ui codebase. 6 imports, 0 dependents.

File tsx ComponentRegistry ChartRegistry 6 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  f012c134_46ba_0dd6_64de_f7b8aca19656["chart-copy-button.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  f012c134_46ba_0dd6_64de_f7b8aca19656 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3["lucide-react"]
  f012c134_46ba_0dd6_64de_f7b8aca19656 --> d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3
  a9903b11_2f1d_8437_2ec7_acd8ba077fa8["events"]
  f012c134_46ba_0dd6_64de_f7b8aca19656 --> a9903b11_2f1d_8437_2ec7_acd8ba077fa8
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  f012c134_46ba_0dd6_64de_f7b8aca19656 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  aa2f3ec6_f291_3763_88ec_65a3f5ad5939["button"]
  f012c134_46ba_0dd6_64de_f7b8aca19656 --> aa2f3ec6_f291_3763_88ec_65a3f5ad5939
  4ad968a1_2bd7_248c_f5ed_f80d5b5f7417["tooltip"]
  f012c134_46ba_0dd6_64de_f7b8aca19656 --> 4ad968a1_2bd7_248c_f5ed_f80d5b5f7417
  style f012c134_46ba_0dd6_64de_f7b8aca19656 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

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

import { Event, trackEvent } from "@/lib/events"
import { cn } from "@/lib/utils"
import { Button, ButtonProps } from "@/registry/new-york/ui/button"
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/registry/new-york/ui/tooltip"

export function ChartCopyButton({
  event,
  name,
  code,
  className,
  ...props
}: {
  event: Event["name"]
  name: string
  code: string
} & ButtonProps) {
  const [hasCopied, setHasCopied] = React.useState(false)

  React.useEffect(() => {
    setTimeout(() => {
      setHasCopied(false)
    }, 2000)
  }, [hasCopied])

  return (
    <Tooltip>
      <TooltipTrigger asChild>
        <Button
          size="icon"
          variant="outline"
          className={cn(
            "[&_svg]-h-3.5 h-7 w-7 rounded-[6px] [&_svg]:w-3.5",
            className
          )}
          onClick={() => {
            navigator.clipboard.writeText(code)
            trackEvent({
              name: event,
              properties: {
                name,
              },
            })
            setHasCopied(true)
          }}
          {...props}
        >
          <span className="sr-only">Copy</span>
          {hasCopied ? <CheckIcon /> : <ClipboardIcon />}
        </Button>
      </TooltipTrigger>
      <TooltipContent className="bg-black text-white">Copy code</TooltipContent>
    </Tooltip>
  )
}

Subdomains

Functions

Dependencies

  • button
  • events
  • lucide-react
  • react
  • tooltip
  • utils

Frequently Asked Questions

What does chart-copy-button.tsx do?
chart-copy-button.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, ChartRegistry subdomain.
What functions are defined in chart-copy-button.tsx?
chart-copy-button.tsx defines 1 function(s): ChartCopyButton.
What does chart-copy-button.tsx depend on?
chart-copy-button.tsx imports 6 module(s): button, events, lucide-react, react, tooltip, utils.
Where is chart-copy-button.tsx in the architecture?
chart-copy-button.tsx is located at deprecated/www/components/chart-copy-button.tsx (domain: ComponentRegistry, subdomain: ChartRegistry, directory: deprecated/www/components).

Analyze Your Own Codebase

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

Try Supermodel Free