random-button.tsx — ui Source File
Architecture documentation for random-button.tsx, a tsx file in the ui codebase. 12 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 931e1cb0_2628_a62b_0d12_e2b8414505dc["random-button.tsx"] 1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2 79511111_e2db_7710_6e07_29cc266a5518["script"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 79511111_e2db_7710_6e07_29cc266a5518 81821566_3643_c91a_1397_57950c94b526["core-free-icons"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 81821566_3643_c91a_1397_57950c94b526 614a3ef5_2f09_8b4c_c7b8_666db5a9ce32["react"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 614a3ef5_2f09_8b4c_c7b8_666db5a9ce32 f14cf7ca_f213_afc2_bc66_ebc0fb7d9834["config"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> f14cf7ca_f213_afc2_bc66_ebc0fb7d9834 57e86e45_ac6e_7278_be08_9092724e8401["button"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 57e86e45_ac6e_7278_be08_9092724e8401 eef72ee8_5107_2380_708f_cd0adbb65f49["kbd"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> eef72ee8_5107_2380_708f_cd0adbb65f49 a2518e24_160d_3f8f_bb12_2206d8e84ab8["tooltip"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> a2518e24_160d_3f8f_bb12_2206d8e84ab8 945c5b0b_1466_ac64_38f6_c99e3a1d57de["use-locks"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 945c5b0b_1466_ac64_38f6_c99e3a1d57de 3d93decf_c957_3d20_9f5e_e6c328cd39c2["fonts"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 3d93decf_c957_3d20_9f5e_e6c328cd39c2 2ce097df_ee70_94a2_94e3_86e09ad579ca["randomize-biases"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> 2ce097df_ee70_94a2_94e3_86e09ad579ca c27c6e95_5daf_4dd4_dc3a_add496837570["search-params"] 931e1cb0_2628_a62b_0d12_e2b8414505dc --> c27c6e95_5daf_4dd4_dc3a_add496837570 style 931e1cb0_2628_a62b_0d12_e2b8414505dc fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
"use client"
import * as React from "react"
import Script from "next/script"
import { DiceFaces05Icon } from "@hugeicons/core-free-icons"
import { HugeiconsIcon } from "@hugeicons/react"
import {
BASE_COLORS,
getThemesForBaseColor,
iconLibraries,
MENU_ACCENTS,
MENU_COLORS,
RADII,
STYLES,
} from "@/registry/config"
import { Button } from "@/registry/new-york-v4/ui/button"
import { Kbd } from "@/registry/new-york-v4/ui/kbd"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/registry/new-york-v4/ui/tooltip"
import { useLocks } from "@/app/(create)/hooks/use-locks"
import { FONTS } from "@/app/(create)/lib/fonts"
import {
applyBias,
RANDOMIZE_BIASES,
type RandomizeContext,
} from "@/app/(create)/lib/randomize-biases"
import { useDesignSystemSearchParams } from "@/app/(create)/lib/search-params"
export const RANDOMIZE_FORWARD_TYPE = "randomize-forward"
function randomItem<T>(array: readonly T[]): T {
return array[Math.floor(Math.random() * array.length)]
}
export function RandomButton() {
const { locks } = useLocks()
const [params, setParams] = useDesignSystemSearchParams()
const handleRandomize = React.useCallback(() => {
// Use current value if locked, otherwise randomize.
const baseColor = locks.has("baseColor")
? params.baseColor
: randomItem(BASE_COLORS).name
const selectedStyle = locks.has("style")
? params.style
: randomItem(STYLES).name
// Build context for bias application.
const context: RandomizeContext = {
style: selectedStyle,
baseColor,
}
const availableThemes = getThemesForBaseColor(baseColor)
const availableFonts = applyBias(FONTS, context, RANDOMIZE_BIASES.fonts)
const availableRadii = applyBias(RADII, context, RANDOMIZE_BIASES.radius)
// ... (122 more lines)
Domain
Subdomains
Dependencies
- button
- config
- core-free-icons
- fonts
- kbd
- randomize-biases
- react
- react
- script
- search-params
- tooltip
- use-locks
Source
Frequently Asked Questions
What does random-button.tsx do?
random-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 random-button.tsx?
random-button.tsx defines 3 function(s): RandomButton, RandomizeScript, randomItem.
What does random-button.tsx depend on?
random-button.tsx imports 12 module(s): button, config, core-free-icons, fonts, kbd, randomize-biases, react, react, and 4 more.
Where is random-button.tsx in the architecture?
random-button.tsx is located at apps/v4/app/(create)/components/random-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