Home / File/ style-picker.tsx — ui Source File

style-picker.tsx — ui Source File

Architecture documentation for style-picker.tsx, a tsx file in the ui codebase. 5 imports, 0 dependents.

File tsx DesignEngine PreviewSystem 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  bb64b6d2_0ade_41bf_421f_caf6e6bf7d73["style-picker.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  bb64b6d2_0ade_41bf_421f_caf6e6bf7d73 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  f14cf7ca_f213_afc2_bc66_ebc0fb7d9834["config"]
  bb64b6d2_0ade_41bf_421f_caf6e6bf7d73 --> f14cf7ca_f213_afc2_bc66_ebc0fb7d9834
  000a4c85_90c9_57be_0014_4c8e8762dcff["lock-button"]
  bb64b6d2_0ade_41bf_421f_caf6e6bf7d73 --> 000a4c85_90c9_57be_0014_4c8e8762dcff
  c97cebd0_0d39_fa69_4337_d0c1787c0b11["picker"]
  bb64b6d2_0ade_41bf_421f_caf6e6bf7d73 --> c97cebd0_0d39_fa69_4337_d0c1787c0b11
  c27c6e95_5daf_4dd4_dc3a_add496837570["search-params"]
  bb64b6d2_0ade_41bf_421f_caf6e6bf7d73 --> c27c6e95_5daf_4dd4_dc3a_add496837570
  style bb64b6d2_0ade_41bf_421f_caf6e6bf7d73 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"

import { type Style, type StyleName } from "@/registry/config"
import { LockButton } from "@/app/(create)/components/lock-button"
import {
  Picker,
  PickerContent,
  PickerGroup,
  PickerRadioGroup,
  PickerRadioItem,
  PickerSeparator,
  PickerTrigger,
} from "@/app/(create)/components/picker"
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"

export function StylePicker({
  styles,
  isMobile,
  anchorRef,
}: {
  styles: readonly Style[]
  isMobile: boolean
  anchorRef: React.RefObject<HTMLDivElement | null>
}) {
  const [params, setParams] = useDesignSystemSearchParams()

  const currentStyle = styles.find((style) => style.name === params.style)

  return (
    <div className="group/picker relative">
      <Picker>
        <PickerTrigger>
          <div className="flex flex-col justify-start text-left">
            <div className="text-muted-foreground text-xs">Style</div>
            <div className="text-foreground text-sm font-medium">
              {currentStyle?.title}
            </div>
          </div>
          {currentStyle?.icon && (
            <div className="pointer-events-none absolute top-1/2 right-4 flex size-4 -translate-y-1/2 items-center justify-center select-none">
              {React.cloneElement(currentStyle.icon, {
                className: "size-4",
              })}
            </div>
          )}
        </PickerTrigger>
        <PickerContent
          anchor={isMobile ? anchorRef : undefined}
          side={isMobile ? "top" : "right"}
          align={isMobile ? "center" : "start"}
          className="md:w-64"
        >
          <PickerRadioGroup
            value={currentStyle?.name}
            onValueChange={(value) => {
              setParams({ style: value as StyleName })
            }}
          >
            <PickerGroup>
              {styles.map((style, index) => (
                <React.Fragment key={style.name}>
                  <PickerRadioItem value={style.name}>
                    <div className="flex items-start gap-2">
                      {style.icon && (
                        <div className="flex size-4 translate-y-0.5 items-center justify-center">
                          {React.cloneElement(style.icon, {
                            className: "size-4",
                          })}
                        </div>
                      )}
                      <div className="flex flex-col justify-start pointer-coarse:gap-1">
                        <div>{style.title}</div>
                        <div className="text-muted-foreground text-xs pointer-coarse:text-sm">
                          {style.description}
                        </div>
                      </div>
                    </div>
                  </PickerRadioItem>
                  {index < styles.length - 1 && (
                    <PickerSeparator className="opacity-50" />
                  )}
                </React.Fragment>
              ))}
            </PickerGroup>
          </PickerRadioGroup>
        </PickerContent>
      </Picker>
      <LockButton
        param="style"
        className="absolute top-1/2 right-10 -translate-y-1/2"
      />
    </div>
  )
}

Domain

Subdomains

Functions

Dependencies

  • config
  • lock-button
  • picker
  • react
  • search-params

Frequently Asked Questions

What does style-picker.tsx do?
style-picker.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 style-picker.tsx?
style-picker.tsx defines 1 function(s): StylePicker.
What does style-picker.tsx depend on?
style-picker.tsx imports 5 module(s): config, lock-button, picker, react, search-params.
Where is style-picker.tsx in the architecture?
style-picker.tsx is located at apps/v4/app/(create)/components/style-picker.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