Home / File/ color-format-selector.tsx — ui Source File

color-format-selector.tsx — ui Source File

Architecture documentation for color-format-selector.tsx, a tsx file in the ui codebase. 6 imports, 0 dependents.

File tsx Internationalization RTLLayout 6 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  e950130f_aa57_3b99_c944_ccb5f1c8dcd1["color-format-selector.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  e950130f_aa57_3b99_c944_ccb5f1c8dcd1 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  5281a958_99ee_42f0_65d8_3fb6d850517a["colors"]
  e950130f_aa57_3b99_c944_ccb5f1c8dcd1 --> 5281a958_99ee_42f0_65d8_3fb6d850517a
  79081a1f_55a3_945a_fb8c_d53d6d3eab81["utils"]
  e950130f_aa57_3b99_c944_ccb5f1c8dcd1 --> 79081a1f_55a3_945a_fb8c_d53d6d3eab81
  a5ebc15d_0ba5_30f8_7c37_f009f0a1b271["use-colors"]
  e950130f_aa57_3b99_c944_ccb5f1c8dcd1 --> a5ebc15d_0ba5_30f8_7c37_f009f0a1b271
  c2fa7225_1ddd_1cbc_8810_ee5e42af14d6["select"]
  e950130f_aa57_3b99_c944_ccb5f1c8dcd1 --> c2fa7225_1ddd_1cbc_8810_ee5e42af14d6
  334339cf_a0db_b417_9d88_14840f1e3173["skeleton"]
  e950130f_aa57_3b99_c944_ccb5f1c8dcd1 --> 334339cf_a0db_b417_9d88_14840f1e3173
  style e950130f_aa57_3b99_c944_ccb5f1c8dcd1 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"

import { getColorFormat, type Color } from "@/lib/colors"
import { cn } from "@/lib/utils"
import { useColors } from "@/hooks/use-colors"
import {
  Select,
  SelectContent,
  SelectItem,
  SelectTrigger,
} from "@/registry/new-york-v4/ui/select"
import { Skeleton } from "@/registry/new-york-v4/ui/skeleton"

export function ColorFormatSelector({
  color,
  className,
  ...props
}: Omit<React.ComponentProps<typeof SelectTrigger>, "color"> & {
  color: Color
}) {
  const { format, setFormat, isLoading } = useColors()
  const formats = React.useMemo(() => getColorFormat(color), [color])

  if (isLoading) {
    return <ColorFormatSelectorSkeleton />
  }

  return (
    <Select value={format} onValueChange={setFormat}>
      <SelectTrigger
        size="sm"
        className={cn(
          "bg-secondary text-secondary-foreground border-secondary shadow-none",
          className
        )}
        {...props}
      >
        <span className="font-medium">Format: </span>
        <span className="text-muted-foreground font-mono">{format}</span>
      </SelectTrigger>
      <SelectContent align="end" position="popper" className="rounded-xl">
        {Object.entries(formats).map(([format, value]) => (
          <SelectItem
            key={format}
            value={format}
            className="gap-2 rounded-lg [&>span]:flex [&>span]:items-center [&>span]:gap-2"
          >
            <span className="font-medium">{format}</span>
            <span className="text-muted-foreground font-mono text-xs">
              {value}
            </span>
          </SelectItem>
        ))}
      </SelectContent>
    </Select>
  )
}

export function ColorFormatSelectorSkeleton({
  className,
  ...props
}: React.ComponentProps<typeof Skeleton>) {
  return (
    <Skeleton
      className={cn("h-8 w-[132px] gap-1.5 rounded-md", className)}
      {...props}
    />
  )
}

Subdomains

Dependencies

  • colors
  • react
  • select
  • skeleton
  • use-colors
  • utils

Frequently Asked Questions

What does color-format-selector.tsx do?
color-format-selector.tsx is a source file in the ui codebase, written in tsx. It belongs to the Internationalization domain, RTLLayout subdomain.
What functions are defined in color-format-selector.tsx?
color-format-selector.tsx defines 2 function(s): ColorFormatSelector, ColorFormatSelectorSkeleton.
What does color-format-selector.tsx depend on?
color-format-selector.tsx imports 6 module(s): colors, react, select, skeleton, use-colors, utils.
Where is color-format-selector.tsx in the architecture?
color-format-selector.tsx is located at apps/v4/components/color-format-selector.tsx (domain: Internationalization, subdomain: RTLLayout, directory: apps/v4/components).

Analyze Your Own Codebase

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

Try Supermodel Free