Home / File/ share-button.tsx — ui Source File

share-button.tsx — ui Source File

Architecture documentation for share-button.tsx, a tsx file in the ui codebase. 7 imports, 0 dependents.

File tsx DesignEngine PreviewSystem 7 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  d023f415_7e1f_62eb_4467_212cc0c246f8["share-button.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  d023f415_7e1f_62eb_4467_212cc0c246f8 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  81821566_3643_c91a_1397_57950c94b526["core-free-icons"]
  d023f415_7e1f_62eb_4467_212cc0c246f8 --> 81821566_3643_c91a_1397_57950c94b526
  614a3ef5_2f09_8b4c_c7b8_666db5a9ce32["react"]
  d023f415_7e1f_62eb_4467_212cc0c246f8 --> 614a3ef5_2f09_8b4c_c7b8_666db5a9ce32
  402113bd_a10d_0255_fccf_87fa40fd281a["copy-button"]
  d023f415_7e1f_62eb_4467_212cc0c246f8 --> 402113bd_a10d_0255_fccf_87fa40fd281a
  57e86e45_ac6e_7278_be08_9092724e8401["button"]
  d023f415_7e1f_62eb_4467_212cc0c246f8 --> 57e86e45_ac6e_7278_be08_9092724e8401
  a2518e24_160d_3f8f_bb12_2206d8e84ab8["tooltip"]
  d023f415_7e1f_62eb_4467_212cc0c246f8 --> a2518e24_160d_3f8f_bb12_2206d8e84ab8
  c27c6e95_5daf_4dd4_dc3a_add496837570["search-params"]
  d023f415_7e1f_62eb_4467_212cc0c246f8 --> c27c6e95_5daf_4dd4_dc3a_add496837570
  style d023f415_7e1f_62eb_4467_212cc0c246f8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"
import { Share03Icon, Tick02Icon } from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"

import { copyToClipboardWithMeta } from "@/components/copy-button"
import { Button } from "@/registry/new-york-v4/ui/button"
import {
  Tooltip,
  TooltipContent,
  TooltipTrigger,
} from "@/registry/new-york-v4/ui/tooltip"
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"

export function ShareButton() {
  const [params] = useDesignSystemSearchParams()
  const [hasCopied, setHasCopied] = React.useState(false)

  const shareUrl = React.useMemo(() => {
    const origin = process.env.NEXT_PUBLIC_APP_URL || "http://localhost:3000"
    return `${origin}/create?base=${params.base}&style=${params.style}&baseColor=${params.baseColor}&theme=${params.theme}&iconLibrary=${params.iconLibrary}&font=${params.font}&menuAccent=${params.menuAccent}&menuColor=${params.menuColor}&radius=${params.radius}&item=${params.item}`
  }, [
    params.base,
    params.style,
    params.baseColor,
    params.theme,
    params.iconLibrary,
    params.font,
    params.menuAccent,
    params.menuColor,
    params.radius,
    params.item,
  ])

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

  const handleCopy = React.useCallback(() => {
    copyToClipboardWithMeta(shareUrl, {
      name: "copy_create_share_url",
      properties: {
        url: shareUrl,
      },
    })
    setHasCopied(true)
  }, [shareUrl])

  return (
    <Tooltip>
      <TooltipTrigger asChild>
        <Button
          size="sm"
          variant="outline"
          className="rounded-lg shadow-none lg:w-8 xl:w-fit"
          onClick={handleCopy}
        >
          {hasCopied ? (
            <HugeiconsIcon icon={Tick02Icon} strokeWidth={2} />
          ) : (
            <HugeiconsIcon icon={Share03Icon} strokeWidth={2} />
          )}
          <span className="lg:hidden xl:block">Share</span>
        </Button>
      </TooltipTrigger>
      <TooltipContent>Copy Link</TooltipContent>
    </Tooltip>
  )
}

Domain

Subdomains

Functions

Dependencies

  • button
  • copy-button
  • core-free-icons
  • react
  • react
  • search-params
  • tooltip

Frequently Asked Questions

What does share-button.tsx do?
share-button.tsx is a source file in the ui codebase, written in tsx. It belongs to the DesignEngine domain, PreviewSystem subdomain.
What functions are defined in share-button.tsx?
share-button.tsx defines 1 function(s): ShareButton.
What does share-button.tsx depend on?
share-button.tsx imports 7 module(s): button, copy-button, core-free-icons, react, react, search-params, tooltip.
Where is share-button.tsx in the architecture?
share-button.tsx is located at apps/v4/app/(create)/components/share-button.tsx (domain: DesignEngine, subdomain: PreviewSystem, directory: apps/v4/app/(create)/components).

Analyze Your Own Codebase

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

Try Supermodel Free