Home / File/ collapsible-file-tree.tsx — ui Source File

collapsible-file-tree.tsx — ui Source File

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

File tsx DocumentationAtlas ContentSourcing 5 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  135b1153_6803_5d87_378e_b2086abc2a92["collapsible-file-tree.tsx"]
  4b1d2128_46d9_46f0_b915_b6e1925b7876["button"]
  135b1153_6803_5d87_378e_b2086abc2a92 --> 4b1d2128_46d9_46f0_b915_b6e1925b7876
  a3f5dc6c_2f22_a06c_c4d4_d84a4ed2818e["card"]
  135b1153_6803_5d87_378e_b2086abc2a92 --> a3f5dc6c_2f22_a06c_c4d4_d84a4ed2818e
  a519b2f3_5e0e_a053_b4d5_e1f3786d0de2["collapsible"]
  135b1153_6803_5d87_378e_b2086abc2a92 --> a519b2f3_5e0e_a053_b4d5_e1f3786d0de2
  265ffe32_cc1a_1864_69fc_d161d6592a97["tabs"]
  135b1153_6803_5d87_378e_b2086abc2a92 --> 265ffe32_cc1a_1864_69fc_d161d6592a97
  d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3["lucide-react"]
  135b1153_6803_5d87_378e_b2086abc2a92 --> d39cd1e4_1b2d_9aa2_1d29_fd0b4bfb61c3
  style 135b1153_6803_5d87_378e_b2086abc2a92 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { Button } from "@/examples/radix/ui/button"
import { Card, CardContent, CardHeader } from "@/examples/radix/ui/card"
import {
  Collapsible,
  CollapsibleContent,
  CollapsibleTrigger,
} from "@/examples/radix/ui/collapsible"
import { Tabs, TabsList, TabsTrigger } from "@/examples/radix/ui/tabs"
import { ChevronRightIcon, FileIcon, FolderIcon } from "lucide-react"

type FileTreeItem = { name: string } | { name: string; items: FileTreeItem[] }

export function CollapsibleFileTree() {
  const fileTree: FileTreeItem[] = [
    {
      name: "components",
      items: [
        {
          name: "ui",
          items: [
            { name: "button.tsx" },
            { name: "card.tsx" },
            { name: "dialog.tsx" },
            { name: "input.tsx" },
            { name: "select.tsx" },
            { name: "table.tsx" },
          ],
        },
        { name: "login-form.tsx" },
        { name: "register-form.tsx" },
      ],
    },
    {
      name: "lib",
      items: [{ name: "utils.ts" }, { name: "cn.ts" }, { name: "api.ts" }],
    },
    {
      name: "hooks",
      items: [
        { name: "use-media-query.ts" },
        { name: "use-debounce.ts" },
        { name: "use-local-storage.ts" },
      ],
    },
    {
      name: "types",
      items: [{ name: "index.d.ts" }, { name: "api.d.ts" }],
    },
    {
      name: "public",
      items: [
        { name: "favicon.ico" },
        { name: "logo.svg" },
        { name: "images" },
      ],
    },
    { name: "app.tsx" },
    { name: "layout.tsx" },
    { name: "globals.css" },
    { name: "package.json" },
    { name: "tsconfig.json" },
    { name: "README.md" },
    { name: ".gitignore" },
  ]

  const renderItem = (fileItem: FileTreeItem) => {
    if ("items" in fileItem) {
      return (
        <Collapsible key={fileItem.name}>
          <CollapsibleTrigger asChild>
            <Button
              variant="ghost"
              size="sm"
              className="group hover:bg-accent hover:text-accent-foreground w-full justify-start transition-none"
            >
              <ChevronRightIcon className="transition-transform group-data-[state=open]:rotate-90" />
              <FolderIcon />
              {fileItem.name}
            </Button>
          </CollapsibleTrigger>
          <CollapsibleContent className="style-lyra:ml-4 mt-1 ml-5">
            <div className="flex flex-col gap-1">
              {fileItem.items.map((child) => renderItem(child))}
            </div>
          </CollapsibleContent>
        </Collapsible>
      )
    }
    return (
      <Button
        key={fileItem.name}
        variant="link"
        size="sm"
        className="text-foreground w-full justify-start gap-2"
      >
        <FileIcon />
        <span>{fileItem.name}</span>
      </Button>
    )
  }

  return (
    <Card className="mx-auto w-full max-w-[16rem] gap-2" size="sm">
      <CardHeader>
        <Tabs defaultValue="explorer">
          <TabsList className="w-full">
            <TabsTrigger value="explorer">Explorer</TabsTrigger>
            <TabsTrigger value="settings">Outline</TabsTrigger>
          </TabsList>
        </Tabs>
      </CardHeader>
      <CardContent>
        <div className="flex flex-col gap-1">
          {fileTree.map((item) => renderItem(item))}
        </div>
      </CardContent>
    </Card>
  )
}

Subdomains

Types

Dependencies

  • button
  • card
  • collapsible
  • lucide-react
  • tabs

Frequently Asked Questions

What does collapsible-file-tree.tsx do?
collapsible-file-tree.tsx is a source file in the ui codebase, written in tsx. It belongs to the DocumentationAtlas domain, ContentSourcing subdomain.
What functions are defined in collapsible-file-tree.tsx?
collapsible-file-tree.tsx defines 1 function(s): CollapsibleFileTree.
What does collapsible-file-tree.tsx depend on?
collapsible-file-tree.tsx imports 5 module(s): button, card, collapsible, lucide-react, tabs.
Where is collapsible-file-tree.tsx in the architecture?
collapsible-file-tree.tsx is located at apps/v4/examples/radix/collapsible-file-tree.tsx (domain: DocumentationAtlas, subdomain: ContentSourcing, directory: apps/v4/examples/radix).

Analyze Your Own Codebase

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

Try Supermodel Free