text
stringlengths
21
253k
id
stringlengths
25
123
metadata
dict
__index_level_0__
int64
0
181
"use client" import { DotsHorizontalIcon } from "@radix-ui/react-icons" import { Row } from "@tanstack/react-table" import { Button } from "@/registry/new-york/ui/button" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/registry/new-york/ui/dropdown-menu" import { labels } from "../data/data" import { taskSchema } from "../data/schema" interface DataTableRowActionsProps<TData> { row: Row<TData> } export function DataTableRowActions<TData>({ row, }: DataTableRowActionsProps<TData>) { const task = taskSchema.parse(row.original) return ( <DropdownMenu> <DropdownMenuTrigger asChild> <Button variant="ghost" className="flex h-8 w-8 p-0 data-[state=open]:bg-muted" > <DotsHorizontalIcon className="h-4 w-4" /> <span className="sr-only">Open menu</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end" className="w-[160px]"> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Make a copy</DropdownMenuItem> <DropdownMenuItem>Favorite</DropdownMenuItem> <DropdownMenuSeparator /> <DropdownMenuSub> <DropdownMenuSubTrigger>Labels</DropdownMenuSubTrigger> <DropdownMenuSubContent> <DropdownMenuRadioGroup value={task.label}> {labels.map((label) => ( <DropdownMenuRadioItem key={label.value} value={label.value}> {label.label} </DropdownMenuRadioItem> ))} </DropdownMenuRadioGroup> </DropdownMenuSubContent> </DropdownMenuSub> <DropdownMenuSeparator /> <DropdownMenuItem> Delete <DropdownMenuShortcut></DropdownMenuShortcut> </DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> ) }
shadcn-ui/ui/apps/www/app/(app)/examples/tasks/components/data-table-row-actions.tsx
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/tasks/components/data-table-row-actions.tsx", "repo_id": "shadcn-ui/ui", "token_count": 898 }
70
"use client" import * as React from "react" import { useConfig } from "@/hooks/use-config" import { ThemeWrapper } from "@/components/theme-wrapper" import CardsDefault from "@/registry/default/example/cards" import { Skeleton } from "@/registry/default/ui/skeleton" import CardsNewYork from "@/registry/new-york/example/cards" export function ThemesTabs() { const [mounted, setMounted] = React.useState(false) const [config] = useConfig() React.useEffect(() => { setMounted(true) }, []) return ( <div className="space-y-8"> {!mounted ? ( <div className="md:grids-col-2 grid md:gap-4 lg:grid-cols-10 xl:gap-6"> <div className="space-y-4 lg:col-span-4 xl:col-span-6 xl:space-y-6"> <Skeleton className="h-[218px] w-full" /> <div className="grid gap-1 sm:grid-cols-[260px_1fr] md:hidden"> <Skeleton className="h-[218px] w-full" /> <div className="pt-3 sm:pl-2 sm:pt-0 xl:pl-4"> <Skeleton className="h-[218px] w-full" /> </div> <div className="pt-3 sm:col-span-2 xl:pt-4"> <Skeleton className="h-[218px] w-full" /> </div> </div> <div className="grid gap-6 md:grid-cols-2 lg:grid-cols-1 xl:grid-cols-2"> <div className="space-y-4 xl:space-y-6"> <Skeleton className="h-[218px] w-full" /> <Skeleton className="h-[218px] w-full" /> <Skeleton className="h-[218px] w-full" /> </div> <div className="space-y-4 xl:space-y-6"> <Skeleton className="h-[218px] w-full" /> <Skeleton className="h-[218px] w-full" /> <div className="hidden xl:block"> <Skeleton className="h-[218px] w-full" /> </div> </div> </div> </div> <div className="space-y-4 lg:col-span-6 xl:col-span-4 xl:space-y-6"> <div className="hidden gap-1 sm:grid-cols-[260px_1fr] md:grid"> <Skeleton className="h-[218px] w-full" /> <div className="pt-3 sm:pl-2 sm:pt-0 xl:pl-4"> <Skeleton className="h-[218px] w-full" /> </div> <div className="pt-3 sm:col-span-2 xl:pt-4"> <Skeleton className="h-[218px] w-full" /> </div> </div> <div className="hidden md:block"> <Skeleton className="h-[218px] w-full" /> </div> <Skeleton className="h-[218px] w-full" /> </div> </div> ) : ( <ThemeWrapper> {config.style === "new-york" && <CardsNewYork />} {config.style === "default" && <CardsDefault />} </ThemeWrapper> )} </div> ) }
shadcn-ui/ui/apps/www/app/(app)/themes/tabs.tsx
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/themes/tabs.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1514 }
71
"use client" import { cn } from "@/lib/utils" import { BlockCopyButton } from "@/components/block-copy-button" import { ChartCodeViewer } from "@/components/chart-code-viewer" import { Separator } from "@/registry/new-york/ui/separator" import { Block } from "@/registry/schema" import "@/styles/mdx.css" import { AreaChart, BarChartBig, Hexagon, LineChart, MousePointer2, PieChart, Radar, } from "lucide-react" export function ChartToolbar({ chart, className, children, }: { chart: Block } & React.ComponentProps<"div">) { return ( <div className={cn("flex items-center gap-2", className)}> <div className="flex items-center gap-1.5 pl-1 text-[13px] text-muted-foreground [&>svg]:h-[0.9rem] [&>svg]:w-[0.9rem]"> <ChartTitle chart={chart} /> </div> <div className="ml-auto flex items-center gap-2 [&>form]:flex"> <BlockCopyButton event="copy_chart_code" name={chart.name} code={chart.code} className="[&_svg]-h-3 h-6 w-6 rounded-[6px] bg-transparent text-foreground shadow-none hover:bg-muted dark:text-foreground [&_svg]:w-3" /> <Separator orientation="vertical" className="mx-0 hidden h-4 md:flex" /> <ChartCodeViewer chart={chart}>{children}</ChartCodeViewer> </div> </div> ) } function ChartTitle({ chart }: { chart: Block }) { const { subcategory } = chart if (!subcategory) { return null } if (subcategory === "Line") { return ( <> <LineChart /> Chart </> ) } if (subcategory === "Bar") { return ( <> <BarChartBig /> Chart </> ) } if (subcategory === "Pie") { return ( <> <PieChart /> Chart </> ) } if (subcategory === "Area") { return ( <> <AreaChart /> Chart </> ) } if (subcategory === "Radar") { return ( <> <Hexagon /> Chart </> ) } if (subcategory === "Radial") { return ( <> <Radar /> Chart </> ) } if (subcategory === "Tooltip") { return ( <> <MousePointer2 /> Tooltip </> ) } return subcategory }
shadcn-ui/ui/apps/www/components/chart-toolbar.tsx
{ "file_path": "shadcn-ui/ui/apps/www/components/chart-toolbar.tsx", "repo_id": "shadcn-ui/ui", "token_count": 996 }
72
"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { siteConfig } from "@/config/site" import { cn } from "@/lib/utils" import { Icons } from "@/components/icons" export function MainNav() { const pathname = usePathname() return ( <div className="mr-4 hidden md:flex"> <Link href="/" className="mr-4 flex items-center space-x-2 lg:mr-6"> <Icons.logo className="h-6 w-6" /> <span className="hidden font-bold lg:inline-block"> {siteConfig.name} </span> </Link> <nav className="flex items-center gap-4 text-sm lg:gap-6"> <Link href="/docs" className={cn( "transition-colors hover:text-foreground/80", pathname === "/docs" ? "text-foreground" : "text-foreground/60" )} > Docs </Link> <Link href="/docs/components" className={cn( "transition-colors hover:text-foreground/80", pathname?.startsWith("/docs/components") && !pathname?.startsWith("/docs/component/chart") ? "text-foreground" : "text-foreground/60" )} > Components </Link> <Link href="/blocks" className={cn( "transition-colors hover:text-foreground/80", pathname?.startsWith("/blocks") ? "text-foreground" : "text-foreground/60" )} > Blocks </Link> <Link href="/charts" className={cn( "transition-colors hover:text-foreground/80", pathname?.startsWith("/docs/component/chart") || pathname?.startsWith("/charts") ? "text-foreground" : "text-foreground/60" )} > Charts </Link> <Link href="/themes" className={cn( "transition-colors hover:text-foreground/80", pathname?.startsWith("/themes") ? "text-foreground" : "text-foreground/60" )} > Themes </Link> <Link href="/examples" className={cn( "transition-colors hover:text-foreground/80", pathname?.startsWith("/examples") ? "text-foreground" : "text-foreground/60" )} > Examples </Link> <Link href="/colors" className={cn( "transition-colors hover:text-foreground/80", pathname?.startsWith("/colors") ? "text-foreground" : "text-foreground/60" )} > Colors </Link> </nav> </div> ) }
shadcn-ui/ui/apps/www/components/main-nav.tsx
{ "file_path": "shadcn-ui/ui/apps/www/components/main-nav.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1553 }
73
"use client" import * as React from "react" import { CheckIcon, CopyIcon, InfoCircledIcon, MoonIcon, ResetIcon, SunIcon, } from "@radix-ui/react-icons" import template from "lodash.template" import { useTheme } from "next-themes" import { cn } from "@/lib/utils" import { useConfig } from "@/hooks/use-config" import { copyToClipboardWithMeta } from "@/components/copy-button" import { ThemeWrapper } from "@/components/theme-wrapper" import { Button } from "@/registry/new-york/ui/button" import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, DialogTrigger, } from "@/registry/new-york/ui/dialog" import { Drawer, DrawerContent, DrawerTrigger, } from "@/registry/new-york/ui/drawer" import { Label } from "@/registry/new-york/ui/label" import { Popover, PopoverContent, PopoverTrigger, } from "@/registry/new-york/ui/popover" import { Skeleton } from "@/registry/new-york/ui/skeleton" import { Tooltip, TooltipContent, TooltipTrigger, } from "@/registry/new-york/ui/tooltip" import { BaseColor, baseColors } from "@/registry/registry-base-colors" import "@/styles/mdx.css" export function ThemeCustomizer() { const [config, setConfig] = useConfig() const { resolvedTheme: mode } = useTheme() const [mounted, setMounted] = React.useState(false) React.useEffect(() => { setMounted(true) }, []) return ( <div className="flex items-center gap-2"> <Drawer> <DrawerTrigger asChild> <Button size="sm" className="md:hidden"> Customize </Button> </DrawerTrigger> <DrawerContent className="p-6 pt-0"> <Customizer /> </DrawerContent> </Drawer> <div className="hidden items-center md:flex"> <Popover> <PopoverTrigger asChild> <Button size="sm">Customize</Button> </PopoverTrigger> <PopoverContent align="start" className="z-40 w-[340px] rounded-[12px] bg-white p-6 dark:bg-zinc-950" > <Customizer /> </PopoverContent> </Popover> <div className="ml-2 hidden items-center gap-0.5"> {mounted ? ( <> {["zinc", "rose", "blue", "green", "orange"].map((color) => { const baseColor = baseColors.find( (baseColor) => baseColor.name === color ) const isActive = config.theme === color if (!baseColor) { return null } return ( <Tooltip key={baseColor.name}> <TooltipTrigger asChild> <button onClick={() => setConfig({ ...config, theme: baseColor.name, }) } className={cn( "flex h-8 w-8 items-center justify-center rounded-full border-2 text-xs", isActive ? "border-[--theme-primary]" : "border-transparent" )} style={ { "--theme-primary": `hsl(${ baseColor?.activeColor[ mode === "dark" ? "dark" : "light" ] })`, } as React.CSSProperties } > <span className={cn( "flex h-5 w-5 items-center justify-center rounded-full bg-[--theme-primary]" )} > {isActive && ( <CheckIcon className="h-4 w-4 text-white" /> )} </span> <span className="sr-only">{baseColor.label}</span> </button> </TooltipTrigger> <TooltipContent align="center" className="rounded-[0.5rem] bg-zinc-900 text-zinc-50" > {baseColor.label} </TooltipContent> </Tooltip> ) })} </> ) : ( <div className="mr-1 flex items-center gap-4"> <Skeleton className="h-5 w-5 rounded-full" /> <Skeleton className="h-5 w-5 rounded-full" /> <Skeleton className="h-5 w-5 rounded-full" /> <Skeleton className="h-5 w-5 rounded-full" /> <Skeleton className="h-5 w-5 rounded-full" /> </div> )} </div> </div> <CopyCodeButton variant="ghost" size="sm" className="[&_svg]:hidden" /> </div> ) } function Customizer() { const [mounted, setMounted] = React.useState(false) const { setTheme: setMode, resolvedTheme: mode } = useTheme() const [config, setConfig] = useConfig() React.useEffect(() => { setMounted(true) }, []) return ( <ThemeWrapper defaultTheme="zinc" className="flex flex-col space-y-4 md:space-y-6" > <div className="flex items-start pt-4 md:pt-0"> <div className="space-y-1 pr-2"> <div className="font-semibold leading-none tracking-tight"> Customize </div> <div className="text-xs text-muted-foreground"> Pick a style and color for your components. </div> </div> <Button variant="ghost" size="icon" className="ml-auto rounded-[0.5rem]" onClick={() => { setConfig({ ...config, theme: "zinc", radius: 0.5, }) }} > <ResetIcon /> <span className="sr-only">Reset</span> </Button> </div> <div className="flex flex-1 flex-col space-y-4 md:space-y-6"> <div className="space-y-1.5"> <div className="flex w-full items-center"> <Label className="text-xs">Style</Label> <Popover> <PopoverTrigger> <InfoCircledIcon className="ml-1 h-3 w-3" /> <span className="sr-only">About styles</span> </PopoverTrigger> <PopoverContent className="space-y-3 rounded-[0.5rem] text-sm" side="right" align="start" alignOffset={-20} > <p className="font-medium"> What is the difference between the New York and Default style? </p> <p> A style comes with its own set of components, animations, icons and more. </p> <p> The <span className="font-medium">Default</span> style has larger inputs, uses lucide-react for icons and tailwindcss-animate for animations. </p> <p> The <span className="font-medium">New York</span> style ships with smaller buttons and cards with shadows. It uses icons from Radix Icons. </p> </PopoverContent> </Popover> </div> <div className="grid grid-cols-3 gap-2"> <Button variant={"outline"} size="sm" onClick={() => setConfig({ ...config, style: "default" })} className={cn( config.style === "default" && "border-2 border-primary" )} > Default </Button> <Button variant={"outline"} size="sm" onClick={() => setConfig({ ...config, style: "new-york" })} className={cn( config.style === "new-york" && "border-2 border-primary" )} > New York </Button> </div> </div> <div className="space-y-1.5"> <Label className="text-xs">Color</Label> <div className="grid grid-cols-3 gap-2"> {baseColors.map((theme) => { const isActive = config.theme === theme.name return mounted ? ( <Button variant={"outline"} size="sm" key={theme.name} onClick={() => { setConfig({ ...config, theme: theme.name, }) }} className={cn( "justify-start", isActive && "border-2 border-primary" )} style={ { "--theme-primary": `hsl(${ theme?.activeColor[mode === "dark" ? "dark" : "light"] })`, } as React.CSSProperties } > <span className={cn( "mr-1 flex h-5 w-5 shrink-0 -translate-x-1 items-center justify-center rounded-full bg-[--theme-primary]" )} > {isActive && <CheckIcon className="h-4 w-4 text-white" />} </span> {theme.label} </Button> ) : ( <Skeleton className="h-8 w-full" key={theme.name} /> ) })} </div> </div> <div className="space-y-1.5"> <Label className="text-xs">Radius</Label> <div className="grid grid-cols-5 gap-2"> {["0", "0.3", "0.5", "0.75", "1.0"].map((value) => { return ( <Button variant={"outline"} size="sm" key={value} onClick={() => { setConfig({ ...config, radius: parseFloat(value), }) }} className={cn( config.radius === parseFloat(value) && "border-2 border-primary" )} > {value} </Button> ) })} </div> </div> <div className="space-y-1.5"> <Label className="text-xs">Mode</Label> <div className="grid grid-cols-3 gap-2"> {mounted ? ( <> <Button variant={"outline"} size="sm" onClick={() => setMode("light")} className={cn(mode === "light" && "border-2 border-primary")} > <SunIcon className="mr-1 -translate-x-1" /> Light </Button> <Button variant={"outline"} size="sm" onClick={() => setMode("dark")} className={cn(mode === "dark" && "border-2 border-primary")} > <MoonIcon className="mr-1 -translate-x-1" /> Dark </Button> </> ) : ( <> <Skeleton className="h-8 w-full" /> <Skeleton className="h-8 w-full" /> </> )} </div> </div> </div> </ThemeWrapper> ) } function CopyCodeButton({ className, ...props }: React.ComponentProps<typeof Button>) { const [config] = useConfig() const activeTheme = baseColors.find((theme) => theme.name === config.theme) const [hasCopied, setHasCopied] = React.useState(false) React.useEffect(() => { setTimeout(() => { setHasCopied(false) }, 2000) }, [hasCopied]) return ( <> {activeTheme && ( <Button onClick={() => { copyToClipboardWithMeta(getThemeCode(activeTheme, config.radius), { name: "copy_theme_code", properties: { theme: activeTheme.name, radius: config.radius, }, }) setHasCopied(true) }} className={cn("md:hidden", className)} {...props} > {hasCopied ? ( <CheckIcon className="mr-2 h-4 w-4" /> ) : ( <CopyIcon className="mr-2 h-4 w-4" /> )} Copy code </Button> )} <Dialog> <DialogTrigger asChild> <Button className={cn("hidden md:flex", className)} {...props}> Copy code </Button> </DialogTrigger> <DialogContent className="max-w-2xl outline-none"> <DialogHeader> <DialogTitle>Theme</DialogTitle> <DialogDescription> Copy and paste the following code into your CSS file. </DialogDescription> </DialogHeader> <ThemeWrapper defaultTheme="zinc" className="relative"> <CustomizerCode /> {activeTheme && ( <Button size="sm" onClick={() => { copyToClipboardWithMeta( getThemeCode(activeTheme, config.radius), { name: "copy_theme_code", properties: { theme: activeTheme.name, radius: config.radius, }, } ) setHasCopied(true) }} className="absolute right-4 top-4 bg-muted text-muted-foreground hover:bg-muted hover:text-muted-foreground" > {hasCopied ? ( <CheckIcon className="mr-2 h-4 w-4" /> ) : ( <CopyIcon className="mr-2 h-4 w-4" /> )} Copy </Button> )} </ThemeWrapper> </DialogContent> </Dialog> </> ) } function CustomizerCode() { const [config] = useConfig() const activeTheme = baseColors.find((theme) => theme.name === config.theme) return ( <ThemeWrapper defaultTheme="zinc" className="relative space-y-4"> <div data-rehype-pretty-code-fragment=""> <pre className="max-h-[450px] overflow-x-auto rounded-lg border bg-zinc-950 py-4 dark:bg-zinc-900"> <code className="relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm"> <span className="line text-white">@layer base &#123;</span> <span className="line text-white">&nbsp;&nbsp;:root &#123;</span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--background:{" "} {activeTheme?.cssVars.light["background"]}; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--foreground:{" "} {activeTheme?.cssVars.light["foreground"]}; </span> {[ "card", "popover", "primary", "secondary", "muted", "accent", "destructive", ].map((prefix) => ( <> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--{prefix}:{" "} { activeTheme?.cssVars.light[ prefix as keyof typeof activeTheme.cssVars.light ] } ; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--{prefix}-foreground:{" "} { activeTheme?.cssVars.light[ `${prefix}-foreground` as keyof typeof activeTheme.cssVars.light ] } ; </span> </> ))} <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--border:{" "} {activeTheme?.cssVars.light["border"]}; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--input:{" "} {activeTheme?.cssVars.light["input"]}; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--ring:{" "} {activeTheme?.cssVars.light["ring"]}; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--radius: {config.radius}rem; </span> {["chart-1", "chart-2", "chart-3", "chart-4", "chart-5"].map( (prefix) => ( <> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--{prefix}:{" "} { activeTheme?.cssVars.light[ prefix as keyof typeof activeTheme.cssVars.light ] } ; </span> </> ) )} <span className="line text-white">&nbsp;&nbsp;&#125;</span> <span className="line text-white">&nbsp;</span> <span className="line text-white">&nbsp;&nbsp;.dark &#123;</span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--background:{" "} {activeTheme?.cssVars.dark["background"]}; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--foreground:{" "} {activeTheme?.cssVars.dark["foreground"]}; </span> {[ "card", "popover", "primary", "secondary", "muted", "accent", "destructive", ].map((prefix) => ( <> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--{prefix}:{" "} { activeTheme?.cssVars.dark[ prefix as keyof typeof activeTheme.cssVars.dark ] } ; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--{prefix}-foreground:{" "} { activeTheme?.cssVars.dark[ `${prefix}-foreground` as keyof typeof activeTheme.cssVars.dark ] } ; </span> </> ))} <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--border:{" "} {activeTheme?.cssVars.dark["border"]}; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--input:{" "} {activeTheme?.cssVars.dark["input"]}; </span> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--ring:{" "} {activeTheme?.cssVars.dark["ring"]}; </span> {["chart-1", "chart-2", "chart-3", "chart-4", "chart-5"].map( (prefix) => ( <> <span className="line text-white"> &nbsp;&nbsp;&nbsp;&nbsp;--{prefix}:{" "} { activeTheme?.cssVars.dark[ prefix as keyof typeof activeTheme.cssVars.dark ] } ; </span> </> ) )} <span className="line text-white">&nbsp;&nbsp;&#125;</span> <span className="line text-white">&#125;</span> </code> </pre> </div> </ThemeWrapper> ) } function getThemeCode(theme: BaseColor, radius: number) { if (!theme) { return "" } return template(BASE_STYLES_WITH_VARIABLES)({ colors: theme.cssVars, radius, }) } const BASE_STYLES_WITH_VARIABLES = ` @layer base { :root { --background: <%- colors.light["background"] %>; --foreground: <%- colors.light["foreground"] %>; --card: <%- colors.light["card"] %>; --card-foreground: <%- colors.light["card-foreground"] %>; --popover: <%- colors.light["popover"] %>; --popover-foreground: <%- colors.light["popover-foreground"] %>; --primary: <%- colors.light["primary"] %>; --primary-foreground: <%- colors.light["primary-foreground"] %>; --secondary: <%- colors.light["secondary"] %>; --secondary-foreground: <%- colors.light["secondary-foreground"] %>; --muted: <%- colors.light["muted"] %>; --muted-foreground: <%- colors.light["muted-foreground"] %>; --accent: <%- colors.light["accent"] %>; --accent-foreground: <%- colors.light["accent-foreground"] %>; --destructive: <%- colors.light["destructive"] %>; --destructive-foreground: <%- colors.light["destructive-foreground"] %>; --border: <%- colors.light["border"] %>; --input: <%- colors.light["input"] %>; --ring: <%- colors.light["ring"] %>; --radius: <%- radius %>rem; --chart-1: <%- colors.light["chart-1"] %>; --chart-2: <%- colors.light["chart-2"] %>; --chart-3: <%- colors.light["chart-3"] %>; --chart-4: <%- colors.light["chart-4"] %>; --chart-5: <%- colors.light["chart-5"] %>; } .dark { --background: <%- colors.dark["background"] %>; --foreground: <%- colors.dark["foreground"] %>; --card: <%- colors.dark["card"] %>; --card-foreground: <%- colors.dark["card-foreground"] %>; --popover: <%- colors.dark["popover"] %>; --popover-foreground: <%- colors.dark["popover-foreground"] %>; --primary: <%- colors.dark["primary"] %>; --primary-foreground: <%- colors.dark["primary-foreground"] %>; --secondary: <%- colors.dark["secondary"] %>; --secondary-foreground: <%- colors.dark["secondary-foreground"] %>; --muted: <%- colors.dark["muted"] %>; --muted-foreground: <%- colors.dark["muted-foreground"] %>; --accent: <%- colors.dark["accent"] %>; --accent-foreground: <%- colors.dark["accent-foreground"] %>; --destructive: <%- colors.dark["destructive"] %>; --destructive-foreground: <%- colors.dark["destructive-foreground"] %>; --border: <%- colors.dark["border"] %>; --input: <%- colors.dark["input"] %>; --ring: <%- colors.dark["ring"] %>; --chart-1: <%- colors.dark["chart-1"] %>; --chart-2: <%- colors.dark["chart-2"] %>; --chart-3: <%- colors.dark["chart-3"] %>; --chart-4: <%- colors.dark["chart-4"] %>; --chart-5: <%- colors.dark["chart-5"] %>; } } `
shadcn-ui/ui/apps/www/components/theme-customizer.tsx
{ "file_path": "shadcn-ui/ui/apps/www/components/theme-customizer.tsx", "repo_id": "shadcn-ui/ui", "token_count": 13253 }
74
"use client" import * as React from "react" import { Area, AreaChart, CartesianGrid, XAxis } from "recharts" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, ChartTooltip, ChartTooltipContent, } from "@/registry/default/ui/chart" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/registry/default/ui/select" export const description = "An interactive area chart" const chartData = [ { date: "2024-04-01", desktop: 222, mobile: 150 }, { date: "2024-04-02", desktop: 97, mobile: 180 }, { date: "2024-04-03", desktop: 167, mobile: 120 }, { date: "2024-04-04", desktop: 242, mobile: 260 }, { date: "2024-04-05", desktop: 373, mobile: 290 }, { date: "2024-04-06", desktop: 301, mobile: 340 }, { date: "2024-04-07", desktop: 245, mobile: 180 }, { date: "2024-04-08", desktop: 409, mobile: 320 }, { date: "2024-04-09", desktop: 59, mobile: 110 }, { date: "2024-04-10", desktop: 261, mobile: 190 }, { date: "2024-04-11", desktop: 327, mobile: 350 }, { date: "2024-04-12", desktop: 292, mobile: 210 }, { date: "2024-04-13", desktop: 342, mobile: 380 }, { date: "2024-04-14", desktop: 137, mobile: 220 }, { date: "2024-04-15", desktop: 120, mobile: 170 }, { date: "2024-04-16", desktop: 138, mobile: 190 }, { date: "2024-04-17", desktop: 446, mobile: 360 }, { date: "2024-04-18", desktop: 364, mobile: 410 }, { date: "2024-04-19", desktop: 243, mobile: 180 }, { date: "2024-04-20", desktop: 89, mobile: 150 }, { date: "2024-04-21", desktop: 137, mobile: 200 }, { date: "2024-04-22", desktop: 224, mobile: 170 }, { date: "2024-04-23", desktop: 138, mobile: 230 }, { date: "2024-04-24", desktop: 387, mobile: 290 }, { date: "2024-04-25", desktop: 215, mobile: 250 }, { date: "2024-04-26", desktop: 75, mobile: 130 }, { date: "2024-04-27", desktop: 383, mobile: 420 }, { date: "2024-04-28", desktop: 122, mobile: 180 }, { date: "2024-04-29", desktop: 315, mobile: 240 }, { date: "2024-04-30", desktop: 454, mobile: 380 }, { date: "2024-05-01", desktop: 165, mobile: 220 }, { date: "2024-05-02", desktop: 293, mobile: 310 }, { date: "2024-05-03", desktop: 247, mobile: 190 }, { date: "2024-05-04", desktop: 385, mobile: 420 }, { date: "2024-05-05", desktop: 481, mobile: 390 }, { date: "2024-05-06", desktop: 498, mobile: 520 }, { date: "2024-05-07", desktop: 388, mobile: 300 }, { date: "2024-05-08", desktop: 149, mobile: 210 }, { date: "2024-05-09", desktop: 227, mobile: 180 }, { date: "2024-05-10", desktop: 293, mobile: 330 }, { date: "2024-05-11", desktop: 335, mobile: 270 }, { date: "2024-05-12", desktop: 197, mobile: 240 }, { date: "2024-05-13", desktop: 197, mobile: 160 }, { date: "2024-05-14", desktop: 448, mobile: 490 }, { date: "2024-05-15", desktop: 473, mobile: 380 }, { date: "2024-05-16", desktop: 338, mobile: 400 }, { date: "2024-05-17", desktop: 499, mobile: 420 }, { date: "2024-05-18", desktop: 315, mobile: 350 }, { date: "2024-05-19", desktop: 235, mobile: 180 }, { date: "2024-05-20", desktop: 177, mobile: 230 }, { date: "2024-05-21", desktop: 82, mobile: 140 }, { date: "2024-05-22", desktop: 81, mobile: 120 }, { date: "2024-05-23", desktop: 252, mobile: 290 }, { date: "2024-05-24", desktop: 294, mobile: 220 }, { date: "2024-05-25", desktop: 201, mobile: 250 }, { date: "2024-05-26", desktop: 213, mobile: 170 }, { date: "2024-05-27", desktop: 420, mobile: 460 }, { date: "2024-05-28", desktop: 233, mobile: 190 }, { date: "2024-05-29", desktop: 78, mobile: 130 }, { date: "2024-05-30", desktop: 340, mobile: 280 }, { date: "2024-05-31", desktop: 178, mobile: 230 }, { date: "2024-06-01", desktop: 178, mobile: 200 }, { date: "2024-06-02", desktop: 470, mobile: 410 }, { date: "2024-06-03", desktop: 103, mobile: 160 }, { date: "2024-06-04", desktop: 439, mobile: 380 }, { date: "2024-06-05", desktop: 88, mobile: 140 }, { date: "2024-06-06", desktop: 294, mobile: 250 }, { date: "2024-06-07", desktop: 323, mobile: 370 }, { date: "2024-06-08", desktop: 385, mobile: 320 }, { date: "2024-06-09", desktop: 438, mobile: 480 }, { date: "2024-06-10", desktop: 155, mobile: 200 }, { date: "2024-06-11", desktop: 92, mobile: 150 }, { date: "2024-06-12", desktop: 492, mobile: 420 }, { date: "2024-06-13", desktop: 81, mobile: 130 }, { date: "2024-06-14", desktop: 426, mobile: 380 }, { date: "2024-06-15", desktop: 307, mobile: 350 }, { date: "2024-06-16", desktop: 371, mobile: 310 }, { date: "2024-06-17", desktop: 475, mobile: 520 }, { date: "2024-06-18", desktop: 107, mobile: 170 }, { date: "2024-06-19", desktop: 341, mobile: 290 }, { date: "2024-06-20", desktop: 408, mobile: 450 }, { date: "2024-06-21", desktop: 169, mobile: 210 }, { date: "2024-06-22", desktop: 317, mobile: 270 }, { date: "2024-06-23", desktop: 480, mobile: 530 }, { date: "2024-06-24", desktop: 132, mobile: 180 }, { date: "2024-06-25", desktop: 141, mobile: 190 }, { date: "2024-06-26", desktop: 434, mobile: 380 }, { date: "2024-06-27", desktop: 448, mobile: 490 }, { date: "2024-06-28", desktop: 149, mobile: 200 }, { date: "2024-06-29", desktop: 103, mobile: 160 }, { date: "2024-06-30", desktop: 446, mobile: 400 }, ] const chartConfig = { visitors: { label: "Visitors", }, desktop: { label: "Desktop", color: "hsl(var(--chart-1))", }, mobile: { label: "Mobile", color: "hsl(var(--chart-2))", }, } satisfies ChartConfig export default function Component() { const [timeRange, setTimeRange] = React.useState("90d") const filteredData = chartData.filter((item) => { const date = new Date(item.date) const now = new Date() let daysToSubtract = 90 if (timeRange === "30d") { daysToSubtract = 30 } else if (timeRange === "7d") { daysToSubtract = 7 } now.setDate(now.getDate() - daysToSubtract) return date >= now }) return ( <Card> <CardHeader className="flex items-center gap-2 space-y-0 border-b py-5 sm:flex-row"> <div className="grid flex-1 gap-1 text-center sm:text-left"> <CardTitle>Area Chart - Interactive</CardTitle> <CardDescription> Showing total visitors for the last 3 months </CardDescription> </div> <Select value={timeRange} onValueChange={setTimeRange}> <SelectTrigger className="w-[160px] rounded-lg sm:ml-auto" aria-label="Select a value" > <SelectValue placeholder="Last 3 months" /> </SelectTrigger> <SelectContent className="rounded-xl"> <SelectItem value="90d" className="rounded-lg"> Last 3 months </SelectItem> <SelectItem value="30d" className="rounded-lg"> Last 30 days </SelectItem> <SelectItem value="7d" className="rounded-lg"> Last 7 days </SelectItem> </SelectContent> </Select> </CardHeader> <CardContent className="px-2 pt-4 sm:px-6 sm:pt-6"> <ChartContainer config={chartConfig} className="aspect-auto h-[250px] w-full" > <AreaChart data={filteredData}> <defs> <linearGradient id="fillDesktop" x1="0" y1="0" x2="0" y2="1"> <stop offset="5%" stopColor="var(--color-desktop)" stopOpacity={0.8} /> <stop offset="95%" stopColor="var(--color-desktop)" stopOpacity={0.1} /> </linearGradient> <linearGradient id="fillMobile" x1="0" y1="0" x2="0" y2="1"> <stop offset="5%" stopColor="var(--color-mobile)" stopOpacity={0.8} /> <stop offset="95%" stopColor="var(--color-mobile)" stopOpacity={0.1} /> </linearGradient> </defs> <CartesianGrid vertical={false} /> <XAxis dataKey="date" tickLine={false} axisLine={false} tickMargin={8} minTickGap={32} tickFormatter={(value) => { const date = new Date(value) return date.toLocaleDateString("en-US", { month: "short", day: "numeric", }) }} /> <ChartTooltip cursor={false} content={ <ChartTooltipContent labelFormatter={(value) => { return new Date(value).toLocaleDateString("en-US", { month: "short", day: "numeric", }) }} indicator="dot" /> } /> <Area dataKey="mobile" type="natural" fill="url(#fillMobile)" stroke="var(--color-mobile)" stackId="a" /> <Area dataKey="desktop" type="natural" fill="url(#fillDesktop)" stroke="var(--color-desktop)" stackId="a" /> <ChartLegend content={<ChartLegendContent />} /> </AreaChart> </ChartContainer> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/chart-area-interactive.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/chart-area-interactive.tsx", "repo_id": "shadcn-ui/ui", "token_count": 4557 }
75
"use client" import { Avatar, AvatarFallback, AvatarImage, } from "@/registry/default/ui/avatar" import { Card, CardContent, CardHeader, CardTitle, } from "@/registry/default/ui/card" export default function Component() { return ( <Card x-chunk="dashboard-01-chunk-5"> <CardHeader> <CardTitle>Recent Sales</CardTitle> </CardHeader> <CardContent className="grid gap-8"> <div className="flex items-center gap-4"> <Avatar className="hidden h-9 w-9 sm:flex"> <AvatarImage src="/avatars/01.png" alt="Avatar" /> <AvatarFallback>OM</AvatarFallback> </Avatar> <div className="grid gap-1"> <p className="text-sm font-medium leading-none">Olivia Martin</p> <p className="text-sm text-muted-foreground"> [email protected] </p> </div> <div className="ml-auto font-medium">+$1,999.00</div> </div> <div className="flex items-center gap-4"> <Avatar className="hidden h-9 w-9 sm:flex"> <AvatarImage src="/avatars/02.png" alt="Avatar" /> <AvatarFallback>JL</AvatarFallback> </Avatar> <div className="grid gap-1"> <p className="text-sm font-medium leading-none">Jackson Lee</p> <p className="text-sm text-muted-foreground"> [email protected] </p> </div> <div className="ml-auto font-medium">+$39.00</div> </div> <div className="flex items-center gap-4"> <Avatar className="hidden h-9 w-9 sm:flex"> <AvatarImage src="/avatars/03.png" alt="Avatar" /> <AvatarFallback>IN</AvatarFallback> </Avatar> <div className="grid gap-1"> <p className="text-sm font-medium leading-none">Isabella Nguyen</p> <p className="text-sm text-muted-foreground"> [email protected] </p> </div> <div className="ml-auto font-medium">+$299.00</div> </div> <div className="flex items-center gap-4"> <Avatar className="hidden h-9 w-9 sm:flex"> <AvatarImage src="/avatars/04.png" alt="Avatar" /> <AvatarFallback>WK</AvatarFallback> </Avatar> <div className="grid gap-1"> <p className="text-sm font-medium leading-none">William Kim</p> <p className="text-sm text-muted-foreground">[email protected]</p> </div> <div className="ml-auto font-medium">+$99.00</div> </div> <div className="flex items-center gap-4"> <Avatar className="hidden h-9 w-9 sm:flex"> <AvatarImage src="/avatars/05.png" alt="Avatar" /> <AvatarFallback>SD</AvatarFallback> </Avatar> <div className="grid gap-1"> <p className="text-sm font-medium leading-none">Sofia Davis</p> <p className="text-sm text-muted-foreground"> [email protected] </p> </div> <div className="ml-auto font-medium">+$39.00</div> </div> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/dashboard-01-chunk-5.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-01-chunk-5.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1616 }
76
"use client" import { ChevronLeft, ChevronRight, Copy, CreditCard, MoreVertical, Truck, } from "lucide-react" import { Button } from "@/registry/default/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/registry/default/ui/dropdown-menu" import { Pagination, PaginationContent, PaginationItem, } from "@/registry/default/ui/pagination" import { Separator } from "@/registry/default/ui/separator" export default function Component() { return ( <Card className="overflow-hidden" x-chunk="dashboard-05-chunk-4"> <CardHeader className="flex flex-row items-start bg-muted/50"> <div className="grid gap-0.5"> <CardTitle className="group flex items-center gap-2 text-lg"> Order Oe31b70H <Button size="icon" variant="outline" className="h-6 w-6 opacity-0 transition-opacity group-hover:opacity-100" > <Copy className="h-3 w-3" /> <span className="sr-only">Copy Order ID</span> </Button> </CardTitle> <CardDescription>Date: November 23, 2023</CardDescription> </div> <div className="ml-auto flex items-center gap-1"> <Button size="sm" variant="outline" className="h-8 gap-1"> <Truck className="h-3.5 w-3.5" /> <span className="lg:sr-only xl:not-sr-only xl:whitespace-nowrap"> Track Order </span> </Button> <DropdownMenu> <DropdownMenuTrigger asChild> <Button size="icon" variant="outline" className="h-8 w-8"> <MoreVertical className="h-3.5 w-3.5" /> <span className="sr-only">More</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Export</DropdownMenuItem> <DropdownMenuSeparator /> <DropdownMenuItem>Trash</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </div> </CardHeader> <CardContent className="p-6 text-sm"> <div className="grid gap-3"> <div className="font-semibold">Order Details</div> <ul className="grid gap-3"> <li className="flex items-center justify-between"> <span className="text-muted-foreground"> Glimmer Lamps x <span>2</span> </span> <span>$250.00</span> </li> <li className="flex items-center justify-between"> <span className="text-muted-foreground"> Aqua Filters x <span>1</span> </span> <span>$49.00</span> </li> </ul> <Separator className="my-2" /> <ul className="grid gap-3"> <li className="flex items-center justify-between"> <span className="text-muted-foreground">Subtotal</span> <span>$299.00</span> </li> <li className="flex items-center justify-between"> <span className="text-muted-foreground">Shipping</span> <span>$5.00</span> </li> <li className="flex items-center justify-between"> <span className="text-muted-foreground">Tax</span> <span>$25.00</span> </li> <li className="flex items-center justify-between font-semibold"> <span className="text-muted-foreground">Total</span> <span>$329.00</span> </li> </ul> </div> <Separator className="my-4" /> <div className="grid grid-cols-2 gap-4"> <div className="grid gap-3"> <div className="font-semibold">Shipping Information</div> <address className="grid gap-0.5 not-italic text-muted-foreground"> <span>Liam Johnson</span> <span>1234 Main St.</span> <span>Anytown, CA 12345</span> </address> </div> <div className="grid auto-rows-max gap-3"> <div className="font-semibold">Billing Information</div> <div className="text-muted-foreground"> Same as shipping address </div> </div> </div> <Separator className="my-4" /> <div className="grid gap-3"> <div className="font-semibold">Customer Information</div> <dl className="grid gap-3"> <div className="flex items-center justify-between"> <dt className="text-muted-foreground">Customer</dt> <dd>Liam Johnson</dd> </div> <div className="flex items-center justify-between"> <dt className="text-muted-foreground">Email</dt> <dd> <a href="mailto:">[email protected]</a> </dd> </div> <div className="flex items-center justify-between"> <dt className="text-muted-foreground">Phone</dt> <dd> <a href="tel:">+1 234 567 890</a> </dd> </div> </dl> </div> <Separator className="my-4" /> <div className="grid gap-3"> <div className="font-semibold">Payment Information</div> <dl className="grid gap-3"> <div className="flex items-center justify-between"> <dt className="flex items-center gap-1 text-muted-foreground"> <CreditCard className="h-4 w-4" /> Visa </dt> <dd>**** **** **** 4532</dd> </div> </dl> </div> </CardContent> <CardFooter className="flex flex-row items-center border-t bg-muted/50 px-6 py-3"> <div className="text-xs text-muted-foreground"> Updated <time dateTime="2023-11-23">November 23, 2023</time> </div> <Pagination className="ml-auto mr-0 w-auto"> <PaginationContent> <PaginationItem> <Button size="icon" variant="outline" className="h-6 w-6"> <ChevronLeft className="h-3.5 w-3.5" /> <span className="sr-only">Previous Order</span> </Button> </PaginationItem> <PaginationItem> <Button size="icon" variant="outline" className="h-6 w-6"> <ChevronRight className="h-3.5 w-3.5" /> <span className="sr-only">Next Order</span> </Button> </PaginationItem> </PaginationContent> </Pagination> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/dashboard-05-chunk-4.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-05-chunk-4.tsx", "repo_id": "shadcn-ui/ui", "token_count": 3553 }
77
"use client" import Link from "next/link" import { type LucideIcon } from "lucide-react" import { cn } from "@/registry/default/lib/utils" export function NavSecondary({ className, items, }: { items: { title: string url: string icon: LucideIcon items?: { title: string url: string }[] }[] } & React.ComponentProps<"ul">) { if (!items?.length) { return null } return ( <ul className={cn("grid gap-0.5", className)}> {items.map((item) => ( <li key={item.title}> <Link href={item.url} className="flex h-7 items-center gap-2.5 overflow-hidden rounded-md px-1.5 text-xs ring-ring transition-all hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2" > <item.icon className="h-4 w-4 shrink-0 translate-x-0.5 text-muted-foreground" /> <div className="line-clamp-1 grow overflow-hidden pr-6 font-medium text-muted-foreground"> {item.title} </div> </Link> </li> ))} </ul> ) }
shadcn-ui/ui/apps/www/registry/default/block/sidebar-01/components/nav-secondary.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/sidebar-01/components/nav-secondary.tsx", "repo_id": "shadcn-ui/ui", "token_count": 507 }
78
import { Badge } from "@/registry/default/ui/badge" export default function BadgeSecondary() { return <Badge variant="secondary">Secondary</Badge> }
shadcn-ui/ui/apps/www/registry/default/example/badge-secondary.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/badge-secondary.tsx", "repo_id": "shadcn-ui/ui", "token_count": 46 }
79
import { Mail } from "lucide-react" import { Button } from "@/registry/default/ui/button" export default function ButtonWithIcon() { return ( <Button> <Mail className="mr-2 h-4 w-4" /> Login with Email </Button> ) }
shadcn-ui/ui/apps/www/registry/default/example/button-with-icon.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/button-with-icon.tsx", "repo_id": "shadcn-ui/ui", "token_count": 89 }
80
"use client" import { Avatar, AvatarFallback, AvatarImage, } from "@/registry/default/ui/avatar" import { Button } from "@/registry/default/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { Input } from "@/registry/default/ui/input" import { Label } from "@/registry/default/ui/label" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/registry/default/ui/select" import { Separator } from "@/registry/default/ui/separator" export function CardsShare() { return ( <Card> <CardHeader className="pb-3"> <CardTitle>Share this document</CardTitle> <CardDescription> Anyone with the link can view this document. </CardDescription> </CardHeader> <CardContent> <div className="flex space-x-2"> <Label htmlFor="link" className="sr-only"> Link </Label> <Input id="link" value="http://example.com/link/to/document" readOnly /> <Button variant="secondary" className="shrink-0"> Copy Link </Button> </div> <Separator className="my-4" /> <div className="space-y-4"> <h4 className="text-sm font-medium">People with access</h4> <div className="grid gap-6"> <div className="flex items-center justify-between space-x-4"> <div className="flex items-center space-x-4"> <Avatar> <AvatarImage src="/avatars/03.png" alt="Image" /> <AvatarFallback>OM</AvatarFallback> </Avatar> <div> <p className="text-sm font-medium leading-none"> Olivia Martin </p> <p className="text-sm text-muted-foreground">[email protected]</p> </div> </div> <Select defaultValue="edit"> <SelectTrigger className="ml-auto w-[110px]" aria-label="Edit"> <SelectValue placeholder="Select" /> </SelectTrigger> <SelectContent> <SelectItem value="edit">Can edit</SelectItem> <SelectItem value="view">Can view</SelectItem> </SelectContent> </Select> </div> <div className="flex items-center justify-between space-x-4"> <div className="flex items-center space-x-4"> <Avatar> <AvatarImage src="/avatars/05.png" alt="Image" /> <AvatarFallback>IN</AvatarFallback> </Avatar> <div> <p className="text-sm font-medium leading-none"> Isabella Nguyen </p> <p className="text-sm text-muted-foreground">[email protected]</p> </div> </div> <Select defaultValue="view"> <SelectTrigger className="ml-auto w-[110px]" aria-label="Edit"> <SelectValue placeholder="Select" /> </SelectTrigger> <SelectContent> <SelectItem value="edit">Can edit</SelectItem> <SelectItem value="view">Can view</SelectItem> </SelectContent> </Select> </div> <div className="flex items-center justify-between space-x-4"> <div className="flex items-center space-x-4"> <Avatar> <AvatarImage src="/avatars/01.png" alt="Image" /> <AvatarFallback>SD</AvatarFallback> </Avatar> <div> <p className="text-sm font-medium leading-none"> Sofia Davis </p> <p className="text-sm text-muted-foreground">[email protected]</p> </div> </div> <Select defaultValue="view"> <SelectTrigger className="ml-auto w-[110px]" aria-label="Edit"> <SelectValue placeholder="Select" /> </SelectTrigger> <SelectContent> <SelectItem value="edit">Can edit</SelectItem> <SelectItem value="view">Can view</SelectItem> </SelectContent> </Select> </div> </div> </div> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/example/cards/share.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/cards/share.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2388 }
81
import { Checkbox } from "@/registry/default/ui/checkbox" export default function CheckboxDisabled() { return ( <div className="flex items-center space-x-2"> <Checkbox id="terms2" disabled /> <label htmlFor="terms2" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70" > Accept terms and conditions </label> </div> ) }
shadcn-ui/ui/apps/www/registry/default/example/checkbox-disabled.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/checkbox-disabled.tsx", "repo_id": "shadcn-ui/ui", "token_count": 170 }
82
"use client" import * as React from "react" import { addDays, format } from "date-fns" import { Calendar as CalendarIcon } from "lucide-react" import { cn } from "@/lib/utils" import { Button } from "@/registry/default/ui/button" import { Calendar } from "@/registry/default/ui/calendar" import { Popover, PopoverContent, PopoverTrigger, } from "@/registry/default/ui/popover" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/registry/default/ui/select" export default function DatePickerWithPresets() { const [date, setDate] = React.useState<Date>() return ( <Popover> <PopoverTrigger asChild> <Button variant={"outline"} className={cn( "w-[280px] justify-start text-left font-normal", !date && "text-muted-foreground" )} > <CalendarIcon className="mr-2 h-4 w-4" /> {date ? format(date, "PPP") : <span>Pick a date</span>} </Button> </PopoverTrigger> <PopoverContent className="flex w-auto flex-col space-y-2 p-2"> <Select onValueChange={(value) => setDate(addDays(new Date(), parseInt(value))) } > <SelectTrigger> <SelectValue placeholder="Select" /> </SelectTrigger> <SelectContent position="popper"> <SelectItem value="0">Today</SelectItem> <SelectItem value="1">Tomorrow</SelectItem> <SelectItem value="3">In 3 days</SelectItem> <SelectItem value="7">In a week</SelectItem> </SelectContent> </Select> <div className="rounded-md border"> <Calendar mode="single" selected={date} onSelect={setDate} /> </div> </PopoverContent> </Popover> ) }
shadcn-ui/ui/apps/www/registry/default/example/date-picker-with-presets.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/date-picker-with-presets.tsx", "repo_id": "shadcn-ui/ui", "token_count": 798 }
83
"use client" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { z } from "zod" import { toast } from "@/registry/default/hooks/use-toast" import { Button } from "@/registry/default/ui/button" import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/registry/default/ui/form" import { InputOTP, InputOTPGroup, InputOTPSlot, } from "@/registry/default/ui/input-otp" const FormSchema = z.object({ pin: z.string().min(6, { message: "Your one-time password must be 6 characters.", }), }) export default function InputOTPForm() { const form = useForm<z.infer<typeof FormSchema>>({ resolver: zodResolver(FormSchema), defaultValues: { pin: "", }, }) function onSubmit(data: z.infer<typeof FormSchema>) { toast({ title: "You submitted the following values:", description: ( <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4"> <code className="text-white">{JSON.stringify(data, null, 2)}</code> </pre> ), }) } return ( <Form {...form}> <form onSubmit={form.handleSubmit(onSubmit)} className="w-2/3 space-y-6"> <FormField control={form.control} name="pin" render={({ field }) => ( <FormItem> <FormLabel>One-Time Password</FormLabel> <FormControl> <InputOTP maxLength={6} {...field}> <InputOTPGroup> <InputOTPSlot index={0} /> <InputOTPSlot index={1} /> <InputOTPSlot index={2} /> <InputOTPSlot index={3} /> <InputOTPSlot index={4} /> <InputOTPSlot index={5} /> </InputOTPGroup> </InputOTP> </FormControl> <FormDescription> Please enter the one-time password sent to your phone. </FormDescription> <FormMessage /> </FormItem> )} /> <Button type="submit">Submit</Button> </form> </Form> ) }
shadcn-ui/ui/apps/www/registry/default/example/input-otp-form.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/input-otp-form.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1067 }
84
"use client" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { z } from "zod" import { toast } from "@/registry/default/hooks/use-toast" import { Button } from "@/registry/default/ui/button" import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, } from "@/registry/default/ui/form" import { Switch } from "@/registry/default/ui/switch" const FormSchema = z.object({ marketing_emails: z.boolean().default(false).optional(), security_emails: z.boolean(), }) export default function SwitchForm() { const form = useForm<z.infer<typeof FormSchema>>({ resolver: zodResolver(FormSchema), defaultValues: { security_emails: true, }, }) function onSubmit(data: z.infer<typeof FormSchema>) { toast({ title: "You submitted the following values:", description: ( <pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4"> <code className="text-white">{JSON.stringify(data, null, 2)}</code> </pre> ), }) } return ( <Form {...form}> <form onSubmit={form.handleSubmit(onSubmit)} className="w-full space-y-6"> <div> <h3 className="mb-4 text-lg font-medium">Email Notifications</h3> <div className="space-y-4"> <FormField control={form.control} name="marketing_emails" render={({ field }) => ( <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4"> <div className="space-y-0.5"> <FormLabel className="text-base"> Marketing emails </FormLabel> <FormDescription> Receive emails about new products, features, and more. </FormDescription> </div> <FormControl> <Switch checked={field.value} onCheckedChange={field.onChange} /> </FormControl> </FormItem> )} /> <FormField control={form.control} name="security_emails" render={({ field }) => ( <FormItem className="flex flex-row items-center justify-between rounded-lg border p-4"> <div className="space-y-0.5"> <FormLabel className="text-base">Security emails</FormLabel> <FormDescription> Receive emails about your account security. </FormDescription> </div> <FormControl> <Switch checked={field.value} onCheckedChange={field.onChange} disabled aria-readonly /> </FormControl> </FormItem> )} /> </div> </div> <Button type="submit">Submit</Button> </form> </Form> ) }
shadcn-ui/ui/apps/www/registry/default/example/switch-form.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/switch-form.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1647 }
85
import { Bold, Italic, Underline } from "lucide-react" import { ToggleGroup, ToggleGroupItem, } from "@/registry/default/ui/toggle-group" export default function ToggleGroupDemo() { return ( <ToggleGroup type="multiple"> <ToggleGroupItem value="bold" aria-label="Toggle bold"> <Bold className="h-4 w-4" /> </ToggleGroupItem> <ToggleGroupItem value="italic" aria-label="Toggle italic"> <Italic className="h-4 w-4" /> </ToggleGroupItem> <ToggleGroupItem value="underline" aria-label="Toggle underline"> <Underline className="h-4 w-4" /> </ToggleGroupItem> </ToggleGroup> ) }
shadcn-ui/ui/apps/www/registry/default/example/toggle-group-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/toggle-group-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 270 }
86
export default function TypographyH4() { return ( <h4 className="scroll-m-20 text-xl font-semibold tracking-tight"> People stopped telling jokes </h4> ) }
shadcn-ui/ui/apps/www/registry/default/example/typography-h4.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/typography-h4.tsx", "repo_id": "shadcn-ui/ui", "token_count": 65 }
87
"use client" import { Button } from "@/registry/new-york/ui/button" import { Card, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" export default function Component() { return ( <Card className="sm:col-span-2" x-chunk="dashboard-05-chunk-0"> <CardHeader className="pb-3"> <CardTitle>Your Orders</CardTitle> <CardDescription className="text-balance max-w-lg leading-relaxed"> Introducing Our Dynamic Orders Dashboard for Seamless Management and Insightful Analysis. </CardDescription> </CardHeader> <CardFooter> <Button>Create New Order</Button> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-05-chunk-0.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-05-chunk-0.tsx", "repo_id": "shadcn-ui/ui", "token_count": 288 }
88
import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/registry/new-york/ui/alert-dialog" import { Button } from "@/registry/new-york/ui/button" export default function AlertDialogDemo() { return ( <AlertDialog> <AlertDialogTrigger asChild> <Button variant="outline">Show Dialog</Button> </AlertDialogTrigger> <AlertDialogContent> <AlertDialogHeader> <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle> <AlertDialogDescription> This action cannot be undone. This will permanently delete your account and remove your data from our servers. </AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogAction>Continue</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/alert-dialog-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/alert-dialog-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 399 }
89
import { Button } from "@/registry/new-york/ui/button" export default function ButtonGhost() { return <Button variant="ghost">Ghost</Button> }
shadcn-ui/ui/apps/www/registry/new-york/example/button-ghost.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/button-ghost.tsx", "repo_id": "shadcn-ui/ui", "token_count": 44 }
90
"use client" import * as React from "react" import { CalendarIcon, EnvelopeClosedIcon, FaceIcon, GearIcon, PersonIcon, RocketIcon, } from "@radix-ui/react-icons" import { CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandSeparator, CommandShortcut, } from "@/registry/new-york/ui/command" export default function CommandDialogDemo() { const [open, setOpen] = React.useState(false) React.useEffect(() => { const down = (e: KeyboardEvent) => { if (e.key === "j" && (e.metaKey || e.ctrlKey)) { e.preventDefault() setOpen((open) => !open) } } document.addEventListener("keydown", down) return () => document.removeEventListener("keydown", down) }, []) return ( <> <p className="text-sm text-muted-foreground"> Press{" "} <kbd className="pointer-events-none inline-flex h-5 select-none items-center gap-1 rounded border bg-muted px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100"> <span className="text-xs"></span>J </kbd> </p> <CommandDialog open={open} onOpenChange={setOpen}> <CommandInput placeholder="Type a command or search..." /> <CommandList> <CommandEmpty>No results found.</CommandEmpty> <CommandGroup heading="Suggestions"> <CommandItem> <CalendarIcon className="mr-2 h-4 w-4" /> <span>Calendar</span> </CommandItem> <CommandItem> <FaceIcon className="mr-2 h-4 w-4" /> <span>Search Emoji</span> </CommandItem> <CommandItem> <RocketIcon className="mr-2 h-4 w-4" /> <span>Launch</span> </CommandItem> </CommandGroup> <CommandSeparator /> <CommandGroup heading="Settings"> <CommandItem> <PersonIcon className="mr-2 h-4 w-4" /> <span>Profile</span> <CommandShortcut>P</CommandShortcut> </CommandItem> <CommandItem> <EnvelopeClosedIcon className="mr-2 h-4 w-4" /> <span>Mail</span> <CommandShortcut>B</CommandShortcut> </CommandItem> <CommandItem> <GearIcon className="mr-2 h-4 w-4" /> <span>Settings</span> <CommandShortcut>S</CommandShortcut> </CommandItem> </CommandGroup> </CommandList> </CommandDialog> </> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/command-dialog.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/command-dialog.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1221 }
91
import { Input } from "@/registry/new-york/ui/input" export default function InputDisabled() { return <Input disabled type="email" placeholder="Email" /> }
shadcn-ui/ui/apps/www/registry/new-york/example/input-disabled.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/input-disabled.tsx", "repo_id": "shadcn-ui/ui", "token_count": 47 }
92
import { Button } from "@/registry/new-york/ui/button" import { Input } from "@/registry/new-york/ui/input" import { Label } from "@/registry/new-york/ui/label" import { Popover, PopoverContent, PopoverTrigger, } from "@/registry/new-york/ui/popover" export default function PopoverDemo() { return ( <Popover> <PopoverTrigger asChild> <Button variant="outline">Open popover</Button> </PopoverTrigger> <PopoverContent className="w-80"> <div className="grid gap-4"> <div className="space-y-2"> <h4 className="font-medium leading-none">Dimensions</h4> <p className="text-sm text-muted-foreground"> Set the dimensions for the layer. </p> </div> <div className="grid gap-2"> <div className="grid grid-cols-3 items-center gap-4"> <Label htmlFor="width">Width</Label> <Input id="width" defaultValue="100%" className="col-span-2 h-8" /> </div> <div className="grid grid-cols-3 items-center gap-4"> <Label htmlFor="maxWidth">Max. width</Label> <Input id="maxWidth" defaultValue="300px" className="col-span-2 h-8" /> </div> <div className="grid grid-cols-3 items-center gap-4"> <Label htmlFor="height">Height</Label> <Input id="height" defaultValue="25px" className="col-span-2 h-8" /> </div> <div className="grid grid-cols-3 items-center gap-4"> <Label htmlFor="maxHeight">Max. height</Label> <Input id="maxHeight" defaultValue="none" className="col-span-2 h-8" /> </div> </div> </div> </PopoverContent> </Popover> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/popover-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/popover-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1092 }
93
import { Skeleton } from "@/registry/new-york/ui/skeleton" export default function SkeletonCard() { return ( <div className="flex flex-col space-y-3"> <Skeleton className="h-[125px] w-[250px] rounded-xl" /> <div className="space-y-2"> <Skeleton className="h-4 w-[250px]" /> <Skeleton className="h-4 w-[200px]" /> </div> </div> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/skeleton-card.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/skeleton-card.tsx", "repo_id": "shadcn-ui/ui", "token_count": 167 }
94
export const baseColors = [ { name: "zinc", label: "Zinc", activeColor: { light: "240 5.9% 10%", dark: "240 5.2% 33.9%", }, cssVars: { light: { background: "0 0% 100%", foreground: "240 10% 3.9%", card: "0 0% 100%", "card-foreground": "240 10% 3.9%", popover: "0 0% 100%", "popover-foreground": "240 10% 3.9%", primary: "240 5.9% 10%", "primary-foreground": "0 0% 98%", secondary: "240 4.8% 95.9%", "secondary-foreground": "240 5.9% 10%", muted: "240 4.8% 95.9%", "muted-foreground": "240 3.8% 46.1%", accent: "240 4.8% 95.9%", "accent-foreground": "240 5.9% 10%", destructive: "0 84.2% 60.2%", "destructive-foreground": "0 0% 98%", border: "240 5.9% 90%", input: "240 5.9% 90%", ring: "240 5.9% 10%", radius: "0.5rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "240 10% 3.9%", foreground: "0 0% 98%", card: "240 10% 3.9%", "card-foreground": "0 0% 98%", popover: "240 10% 3.9%", "popover-foreground": "0 0% 98%", primary: "0 0% 98%", "primary-foreground": "240 5.9% 10%", secondary: "240 3.7% 15.9%", "secondary-foreground": "0 0% 98%", muted: "240 3.7% 15.9%", "muted-foreground": "240 5% 64.9%", accent: "240 3.7% 15.9%", "accent-foreground": "0 0% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "0 0% 98%", border: "240 3.7% 15.9%", input: "240 3.7% 15.9%", ring: "240 4.9% 83.9%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "slate", label: "Slate", activeColor: { light: "215.4 16.3% 46.9%", dark: "215.3 19.3% 34.5%", }, cssVars: { light: { background: "0 0% 100%", foreground: "222.2 84% 4.9%", card: "0 0% 100%", "card-foreground": "222.2 84% 4.9%", popover: "0 0% 100%", "popover-foreground": "222.2 84% 4.9%", primary: "222.2 47.4% 11.2%", "primary-foreground": "210 40% 98%", secondary: "210 40% 96.1%", "secondary-foreground": "222.2 47.4% 11.2%", muted: "210 40% 96.1%", "muted-foreground": "215.4 16.3% 46.9%", accent: "210 40% 96.1%", "accent-foreground": "222.2 47.4% 11.2%", destructive: "0 84.2% 60.2%", "destructive-foreground": "210 40% 98%", border: "214.3 31.8% 91.4%", input: "214.3 31.8% 91.4%", ring: "222.2 84% 4.9%", radius: "0.5rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "222.2 84% 4.9%", foreground: "210 40% 98%", card: "222.2 84% 4.9%", "card-foreground": "210 40% 98%", popover: "222.2 84% 4.9%", "popover-foreground": "210 40% 98%", primary: "210 40% 98%", "primary-foreground": "222.2 47.4% 11.2%", secondary: "217.2 32.6% 17.5%", "secondary-foreground": "210 40% 98%", muted: "217.2 32.6% 17.5%", "muted-foreground": "215 20.2% 65.1%", accent: "217.2 32.6% 17.5%", "accent-foreground": "210 40% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "210 40% 98%", border: "217.2 32.6% 17.5%", input: "217.2 32.6% 17.5%", ring: "212.7 26.8% 83.9", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "stone", label: "Stone", activeColor: { light: "25 5.3% 44.7%", dark: "33.3 5.5% 32.4%", }, cssVars: { light: { background: "0 0% 100%", foreground: "20 14.3% 4.1%", card: "0 0% 100%", "card-foreground": "20 14.3% 4.1%", popover: "0 0% 100%", "popover-foreground": "20 14.3% 4.1%", primary: "24 9.8% 10%", "primary-foreground": "60 9.1% 97.8%", secondary: "60 4.8% 95.9%", "secondary-foreground": "24 9.8% 10%", muted: "60 4.8% 95.9%", "muted-foreground": "25 5.3% 44.7%", accent: "60 4.8% 95.9%", "accent-foreground": "24 9.8% 10%", destructive: "0 84.2% 60.2%", "destructive-foreground": "60 9.1% 97.8%", border: "20 5.9% 90%", input: "20 5.9% 90%", ring: "20 14.3% 4.1%", radius: "0.95rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "20 14.3% 4.1%", foreground: "60 9.1% 97.8%", card: "20 14.3% 4.1%", "card-foreground": "60 9.1% 97.8%", popover: "20 14.3% 4.1%", "popover-foreground": "60 9.1% 97.8%", primary: "60 9.1% 97.8%", "primary-foreground": "24 9.8% 10%", secondary: "12 6.5% 15.1%", "secondary-foreground": "60 9.1% 97.8%", muted: "12 6.5% 15.1%", "muted-foreground": "24 5.4% 63.9%", accent: "12 6.5% 15.1%", "accent-foreground": "60 9.1% 97.8%", destructive: "0 62.8% 30.6%", "destructive-foreground": "60 9.1% 97.8%", border: "12 6.5% 15.1%", input: "12 6.5% 15.1%", ring: "24 5.7% 82.9%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "gray", label: "Gray", activeColor: { light: "220 8.9% 46.1%", dark: "215 13.8% 34.1%", }, cssVars: { light: { background: "0 0% 100%", foreground: "224 71.4% 4.1%", card: "0 0% 100%", "card-foreground": "224 71.4% 4.1%", popover: "0 0% 100%", "popover-foreground": "224 71.4% 4.1%", primary: "220.9 39.3% 11%", "primary-foreground": "210 20% 98%", secondary: "220 14.3% 95.9%", "secondary-foreground": "220.9 39.3% 11%", muted: "220 14.3% 95.9%", "muted-foreground": "220 8.9% 46.1%", accent: "220 14.3% 95.9%", "accent-foreground": "220.9 39.3% 11%", destructive: "0 84.2% 60.2%", "destructive-foreground": "210 20% 98%", border: "220 13% 91%", input: "220 13% 91%", ring: "224 71.4% 4.1%", radius: "0.35rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "224 71.4% 4.1%", foreground: "210 20% 98%", card: "224 71.4% 4.1%", "card-foreground": "210 20% 98%", popover: "224 71.4% 4.1%", "popover-foreground": "210 20% 98%", primary: "210 20% 98%", "primary-foreground": "220.9 39.3% 11%", secondary: "215 27.9% 16.9%", "secondary-foreground": "210 20% 98%", muted: "215 27.9% 16.9%", "muted-foreground": "217.9 10.6% 64.9%", accent: "215 27.9% 16.9%", "accent-foreground": "210 20% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "210 20% 98%", border: "215 27.9% 16.9%", input: "215 27.9% 16.9%", ring: "216 12.2% 83.9%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "neutral", label: "Neutral", activeColor: { light: "0 0% 45.1%", dark: "0 0% 32.2%", }, cssVars: { light: { background: "0 0% 100%", foreground: "0 0% 3.9%", card: "0 0% 100%", "card-foreground": "0 0% 3.9%", popover: "0 0% 100%", "popover-foreground": "0 0% 3.9%", primary: "0 0% 9%", "primary-foreground": "0 0% 98%", secondary: "0 0% 96.1%", "secondary-foreground": "0 0% 9%", muted: "0 0% 96.1%", "muted-foreground": "0 0% 45.1%", accent: "0 0% 96.1%", "accent-foreground": "0 0% 9%", destructive: "0 84.2% 60.2%", "destructive-foreground": "0 0% 98%", border: "0 0% 89.8%", input: "0 0% 89.8%", ring: "0 0% 3.9%", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "0 0% 3.9%", foreground: "0 0% 98%", card: "0 0% 3.9%", "card-foreground": "0 0% 98%", popover: "0 0% 3.9%", "popover-foreground": "0 0% 98%", primary: "0 0% 98%", "primary-foreground": "0 0% 9%", secondary: "0 0% 14.9%", "secondary-foreground": "0 0% 98%", muted: "0 0% 14.9%", "muted-foreground": "0 0% 63.9%", accent: "0 0% 14.9%", "accent-foreground": "0 0% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "0 0% 98%", border: "0 0% 14.9%", input: "0 0% 14.9%", ring: "0 0% 83.1%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "red", label: "Red", activeColor: { light: "0 72.2% 50.6%", dark: "0 72.2% 50.6%", }, cssVars: { light: { background: "0 0% 100%", foreground: "0 0% 3.9%", card: "0 0% 100%", "card-foreground": "0 0% 3.9%", popover: "0 0% 100%", "popover-foreground": "0 0% 3.9%", primary: "0 72.2% 50.6%", "primary-foreground": "0 85.7% 97.3%", secondary: "0 0% 96.1%", "secondary-foreground": "0 0% 9%", muted: "0 0% 96.1%", "muted-foreground": "0 0% 45.1%", accent: "0 0% 96.1%", "accent-foreground": "0 0% 9%", destructive: "0 84.2% 60.2%", "destructive-foreground": "0 0% 98%", border: "0 0% 89.8%", input: "0 0% 89.8%", ring: "0 72.2% 50.6%", radius: "0.4rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "0 0% 3.9%", foreground: "0 0% 98%", card: "0 0% 3.9%", "card-foreground": "0 0% 98%", popover: "0 0% 3.9%", "popover-foreground": "0 0% 98%", primary: "0 72.2% 50.6%", "primary-foreground": "0 85.7% 97.3%", secondary: "0 0% 14.9%", "secondary-foreground": "0 0% 98%", muted: "0 0% 14.9%", "muted-foreground": "0 0% 63.9%", accent: "0 0% 14.9%", "accent-foreground": "0 0% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "0 0% 98%", border: "0 0% 14.9%", input: "0 0% 14.9%", ring: "0 72.2% 50.6%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "rose", label: "Rose", activeColor: { light: "346.8 77.2% 49.8%", dark: "346.8 77.2% 49.8%", }, cssVars: { light: { background: "0 0% 100%", foreground: "240 10% 3.9%", card: "0 0% 100%", "card-foreground": "240 10% 3.9%", popover: "0 0% 100%", "popover-foreground": "240 10% 3.9%", primary: "346.8 77.2% 49.8%", "primary-foreground": "355.7 100% 97.3%", secondary: "240 4.8% 95.9%", "secondary-foreground": "240 5.9% 10%", muted: "240 4.8% 95.9%", "muted-foreground": "240 3.8% 46.1%", accent: "240 4.8% 95.9%", "accent-foreground": "240 5.9% 10%", destructive: "0 84.2% 60.2%", "destructive-foreground": "0 0% 98%", border: "240 5.9% 90%", input: "240 5.9% 90%", ring: "346.8 77.2% 49.8%", radius: "0.5rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "20 14.3% 4.1%", foreground: "0 0% 95%", popover: "0 0% 9%", "popover-foreground": "0 0% 95%", card: "24 9.8% 10%", "card-foreground": "0 0% 95%", primary: "346.8 77.2% 49.8%", "primary-foreground": "355.7 100% 97.3%", secondary: "240 3.7% 15.9%", "secondary-foreground": "0 0% 98%", muted: "0 0% 15%", "muted-foreground": "240 5% 64.9%", accent: "12 6.5% 15.1%", "accent-foreground": "0 0% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "0 85.7% 97.3%", border: "240 3.7% 15.9%", input: "240 3.7% 15.9%", ring: "346.8 77.2% 49.8%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "orange", label: "Orange", activeColor: { light: "24.6 95% 53.1%", dark: "20.5 90.2% 48.2%", }, cssVars: { light: { background: "0 0% 100%", foreground: "20 14.3% 4.1%", card: "0 0% 100%", "card-foreground": "20 14.3% 4.1%", popover: "0 0% 100%", "popover-foreground": "20 14.3% 4.1%", primary: "24.6 95% 53.1%", "primary-foreground": "60 9.1% 97.8%", secondary: "60 4.8% 95.9%", "secondary-foreground": "24 9.8% 10%", muted: "60 4.8% 95.9%", "muted-foreground": "25 5.3% 44.7%", accent: "60 4.8% 95.9%", "accent-foreground": "24 9.8% 10%", destructive: "0 84.2% 60.2%", "destructive-foreground": "60 9.1% 97.8%", border: "20 5.9% 90%", input: "20 5.9% 90%", ring: "24.6 95% 53.1%", radius: "0.95rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "20 14.3% 4.1%", foreground: "60 9.1% 97.8%", card: "20 14.3% 4.1%", "card-foreground": "60 9.1% 97.8%", popover: "20 14.3% 4.1%", "popover-foreground": "60 9.1% 97.8%", primary: "20.5 90.2% 48.2%", "primary-foreground": "60 9.1% 97.8%", secondary: "12 6.5% 15.1%", "secondary-foreground": "60 9.1% 97.8%", muted: "12 6.5% 15.1%", "muted-foreground": "24 5.4% 63.9%", accent: "12 6.5% 15.1%", "accent-foreground": "60 9.1% 97.8%", destructive: "0 72.2% 50.6%", "destructive-foreground": "60 9.1% 97.8%", border: "12 6.5% 15.1%", input: "12 6.5% 15.1%", ring: "20.5 90.2% 48.2%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "green", label: "Green", activeColor: { light: "142.1 76.2% 36.3%", dark: "142.1 70.6% 45.3%", }, cssVars: { light: { background: "0 0% 100%", foreground: "240 10% 3.9%", card: "0 0% 100%", "card-foreground": "240 10% 3.9%", popover: "0 0% 100%", "popover-foreground": "240 10% 3.9%", primary: "142.1 76.2% 36.3%", "primary-foreground": "355.7 100% 97.3%", secondary: "240 4.8% 95.9%", "secondary-foreground": "240 5.9% 10%", muted: "240 4.8% 95.9%", "muted-foreground": "240 3.8% 46.1%", accent: "240 4.8% 95.9%", "accent-foreground": "240 5.9% 10%", destructive: "0 84.2% 60.2%", "destructive-foreground": "0 0% 98%", border: "240 5.9% 90%", input: "240 5.9% 90%", ring: "142.1 76.2% 36.3%", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "20 14.3% 4.1%", foreground: "0 0% 95%", popover: "0 0% 9%", "popover-foreground": "0 0% 95%", card: "24 9.8% 10%", "card-foreground": "0 0% 95%", primary: "142.1 70.6% 45.3%", "primary-foreground": "144.9 80.4% 10%", secondary: "240 3.7% 15.9%", "secondary-foreground": "0 0% 98%", muted: "0 0% 15%", "muted-foreground": "240 5% 64.9%", accent: "12 6.5% 15.1%", "accent-foreground": "0 0% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "0 85.7% 97.3%", border: "240 3.7% 15.9%", input: "240 3.7% 15.9%", ring: "142.4 71.8% 29.2%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "blue", label: "Blue", activeColor: { light: "221.2 83.2% 53.3%", dark: "217.2 91.2% 59.8%", }, cssVars: { light: { background: "0 0% 100%", foreground: "222.2 84% 4.9%", card: "0 0% 100%", "card-foreground": "222.2 84% 4.9%", popover: "0 0% 100%", "popover-foreground": "222.2 84% 4.9%", primary: "221.2 83.2% 53.3%", "primary-foreground": "210 40% 98%", secondary: "210 40% 96.1%", "secondary-foreground": "222.2 47.4% 11.2%", muted: "210 40% 96.1%", "muted-foreground": "215.4 16.3% 46.9%", accent: "210 40% 96.1%", "accent-foreground": "222.2 47.4% 11.2%", destructive: "0 84.2% 60.2%", "destructive-foreground": "210 40% 98%", border: "214.3 31.8% 91.4%", input: "214.3 31.8% 91.4%", ring: "221.2 83.2% 53.3%", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "222.2 84% 4.9%", foreground: "210 40% 98%", card: "222.2 84% 4.9%", "card-foreground": "210 40% 98%", popover: "222.2 84% 4.9%", "popover-foreground": "210 40% 98%", primary: "217.2 91.2% 59.8%", "primary-foreground": "222.2 47.4% 11.2%", secondary: "217.2 32.6% 17.5%", "secondary-foreground": "210 40% 98%", muted: "217.2 32.6% 17.5%", "muted-foreground": "215 20.2% 65.1%", accent: "217.2 32.6% 17.5%", "accent-foreground": "210 40% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "210 40% 98%", border: "217.2 32.6% 17.5%", input: "217.2 32.6% 17.5%", ring: "224.3 76.3% 48%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "yellow", label: "Yellow", activeColor: { light: "47.9 95.8% 53.1%", dark: "47.9 95.8% 53.1%", }, cssVars: { light: { background: "0 0% 100%", foreground: "20 14.3% 4.1%", card: "0 0% 100%", "card-foreground": "20 14.3% 4.1%", popover: "0 0% 100%", "popover-foreground": "20 14.3% 4.1%", primary: "47.9 95.8% 53.1%", "primary-foreground": "26 83.3% 14.1%", secondary: "60 4.8% 95.9%", "secondary-foreground": "24 9.8% 10%", muted: "60 4.8% 95.9%", "muted-foreground": "25 5.3% 44.7%", accent: "60 4.8% 95.9%", "accent-foreground": "24 9.8% 10%", destructive: "0 84.2% 60.2%", "destructive-foreground": "60 9.1% 97.8%", border: "20 5.9% 90%", input: "20 5.9% 90%", ring: "20 14.3% 4.1%", radius: "0.95rem", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "20 14.3% 4.1%", foreground: "60 9.1% 97.8%", card: "20 14.3% 4.1%", "card-foreground": "60 9.1% 97.8%", popover: "20 14.3% 4.1%", "popover-foreground": "60 9.1% 97.8%", primary: "47.9 95.8% 53.1%", "primary-foreground": "26 83.3% 14.1%", secondary: "12 6.5% 15.1%", "secondary-foreground": "60 9.1% 97.8%", muted: "12 6.5% 15.1%", "muted-foreground": "24 5.4% 63.9%", accent: "12 6.5% 15.1%", "accent-foreground": "60 9.1% 97.8%", destructive: "0 62.8% 30.6%", "destructive-foreground": "60 9.1% 97.8%", border: "12 6.5% 15.1%", input: "12 6.5% 15.1%", ring: "35.5 91.7% 32.9%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, { name: "violet", label: "Violet", activeColor: { light: "262.1 83.3% 57.8%", dark: "263.4 70% 50.4%", }, cssVars: { light: { background: "0 0% 100%", foreground: "224 71.4% 4.1%", card: "0 0% 100%", "card-foreground": "224 71.4% 4.1%", popover: "0 0% 100%", "popover-foreground": "224 71.4% 4.1%", primary: "262.1 83.3% 57.8%", "primary-foreground": "210 20% 98%", secondary: "220 14.3% 95.9%", "secondary-foreground": "220.9 39.3% 11%", muted: "220 14.3% 95.9%", "muted-foreground": "220 8.9% 46.1%", accent: "220 14.3% 95.9%", "accent-foreground": "220.9 39.3% 11%", destructive: "0 84.2% 60.2%", "destructive-foreground": "210 20% 98%", border: "220 13% 91%", input: "220 13% 91%", ring: "262.1 83.3% 57.8%", "chart-1": "12 76% 61%", "chart-2": "173 58% 39%", "chart-3": "197 37% 24%", "chart-4": "43 74% 66%", "chart-5": "27 87% 67%", }, dark: { background: "224 71.4% 4.1%", foreground: "210 20% 98%", card: "224 71.4% 4.1%", "card-foreground": "210 20% 98%", popover: "224 71.4% 4.1%", "popover-foreground": "210 20% 98%", primary: "263.4 70% 50.4%", "primary-foreground": "210 20% 98%", secondary: "215 27.9% 16.9%", "secondary-foreground": "210 20% 98%", muted: "215 27.9% 16.9%", "muted-foreground": "217.9 10.6% 64.9%", accent: "215 27.9% 16.9%", "accent-foreground": "210 20% 98%", destructive: "0 62.8% 30.6%", "destructive-foreground": "210 20% 98%", border: "215 27.9% 16.9%", input: "215 27.9% 16.9%", ring: "263.4 70% 50.4%", "chart-1": "220 70% 50%", "chart-2": "160 60% 45%", "chart-3": "30 80% 55%", "chart-4": "280 65% 60%", "chart-5": "340 75% 55%", }, }, }, ] as const export type BaseColor = (typeof baseColors)[number]
shadcn-ui/ui/apps/www/registry/registry-base-colors.ts
{ "file_path": "shadcn-ui/ui/apps/www/registry/registry-base-colors.ts", "repo_id": "shadcn-ui/ui", "token_count": 13834 }
95
import { detect } from "@antfu/ni" export async function getPackageManager( targetDir: string ): Promise<"yarn" | "pnpm" | "bun" | "npm"> { const packageManager = await detect({ programmatic: true, cwd: targetDir }) if (packageManager === "yarn@berry") return "yarn" if (packageManager === "pnpm@6") return "pnpm" if (packageManager === "bun") return "bun" return packageManager ?? "npm" }
shadcn-ui/ui/packages/cli/src/utils/get-package-manager.ts
{ "file_path": "shadcn-ui/ui/packages/cli/src/utils/get-package-manager.ts", "repo_id": "shadcn-ui/ui", "token_count": 135 }
96
body { background-color: red; }
shadcn-ui/ui/packages/cli/test/fixtures/next-pages-src/src/pages/other.css
{ "file_path": "shadcn-ui/ui/packages/cli/test/fixtures/next-pages-src/src/pages/other.css", "repo_id": "shadcn-ui/ui", "token_count": 13 }
97
import path from "path" import { expect, test } from "vitest" import { getConfig } from "../../src/utils/get-config" import { getItemTargetPath } from "../../src/utils/registry" test("get item target path", async () => { // Full config. let appDir = path.resolve(__dirname, "../fixtures/config-full") expect( await getItemTargetPath(await getConfig(appDir), { type: "components:ui", }) ).toEqual(path.resolve(appDir, "./src/components/ui")) // Partial config. appDir = path.resolve(__dirname, "../fixtures/config-partial") expect( await getItemTargetPath(await getConfig(appDir), { type: "components:ui", }) ).toEqual(path.resolve(appDir, "./components/ui")) // JSX. appDir = path.resolve(__dirname, "../fixtures/config-jsx") expect( await getItemTargetPath(await getConfig(appDir), { type: "components:ui", }) ).toEqual(path.resolve(appDir, "./components/ui")) // Custom paths. appDir = path.resolve(__dirname, "../fixtures/config-ui") expect( await getItemTargetPath(await getConfig(appDir), { type: "components:ui", }) ).toEqual(path.resolve(appDir, "./src/ui")) })
shadcn-ui/ui/packages/cli/test/utils/get-item-target-path.test.ts
{ "file_path": "shadcn-ui/ui/packages/cli/test/utils/get-item-target-path.test.ts", "repo_id": "shadcn-ui/ui", "token_count": 448 }
98
import path from "path" import { FRAMEWORKS, Framework } from "@/src/utils/frameworks" import { Config, RawConfig, getConfig, resolveConfigPaths, } from "@/src/utils/get-config" import { getPackageInfo } from "@/src/utils/get-package-info" import fg from "fast-glob" import fs from "fs-extra" import { loadConfig } from "tsconfig-paths" type ProjectInfo = { framework: Framework isSrcDir: boolean isRSC: boolean isTsx: boolean tailwindConfigFile: string | null tailwindCssFile: string | null aliasPrefix: string | null } const PROJECT_SHARED_IGNORE = [ "**/node_modules/**", ".next", "public", "dist", "build", ] export async function getProjectInfo(cwd: string): Promise<ProjectInfo | null> { const [ configFiles, isSrcDir, isTsx, tailwindConfigFile, tailwindCssFile, aliasPrefix, packageJson, ] = await Promise.all([ fg.glob("**/{next,vite,astro}.config.*|gatsby-config.*|composer.json", { cwd, deep: 3, ignore: PROJECT_SHARED_IGNORE, }), fs.pathExists(path.resolve(cwd, "src")), isTypeScriptProject(cwd), getTailwindConfigFile(cwd), getTailwindCssFile(cwd), getTsConfigAliasPrefix(cwd), getPackageInfo(cwd, false), ]) const isUsingAppDir = await fs.pathExists( path.resolve(cwd, `${isSrcDir ? "src/" : ""}app`) ) const type: ProjectInfo = { framework: FRAMEWORKS["manual"], isSrcDir, isRSC: false, isTsx, tailwindConfigFile, tailwindCssFile, aliasPrefix, } // Next.js. if (configFiles.find((file) => file.startsWith("next.config."))?.length) { type.framework = isUsingAppDir ? FRAMEWORKS["next-app"] : FRAMEWORKS["next-pages"] type.isRSC = isUsingAppDir return type } // Astro. if (configFiles.find((file) => file.startsWith("astro.config."))?.length) { type.framework = FRAMEWORKS["astro"] return type } // Gatsby. if (configFiles.find((file) => file.startsWith("gatsby-config."))?.length) { type.framework = FRAMEWORKS["gatsby"] return type } // Laravel. if (configFiles.find((file) => file.startsWith("composer.json"))?.length) { type.framework = FRAMEWORKS["laravel"] return type } // Remix. if ( Object.keys(packageJson?.dependencies ?? {}).find((dep) => dep.startsWith("@remix-run/") ) ) { type.framework = FRAMEWORKS["remix"] return type } // Vite. // Some Remix templates also have a vite.config.* file. // We'll assume that it got caught by the Remix check above. if (configFiles.find((file) => file.startsWith("vite.config."))?.length) { type.framework = FRAMEWORKS["vite"] return type } return type } export async function getTailwindCssFile(cwd: string) { const files = await fg.glob(["**/*.css", "**/*.scss"], { cwd, deep: 5, ignore: PROJECT_SHARED_IGNORE, }) if (!files.length) { return null } for (const file of files) { const contents = await fs.readFile(path.resolve(cwd, file), "utf8") // Assume that if the file contains `@tailwind base` it's the main css file. if (contents.includes("@tailwind base")) { return file } } return null } export async function getTailwindConfigFile(cwd: string) { const files = await fg.glob("tailwind.config.*", { cwd, deep: 3, ignore: PROJECT_SHARED_IGNORE, }) if (!files.length) { return null } return files[0] } export async function getTsConfigAliasPrefix(cwd: string) { const tsConfig = await loadConfig(cwd) if (tsConfig?.resultType === "failed" || !tsConfig?.paths) { return null } // This assume that the first alias is the prefix. for (const [alias, paths] of Object.entries(tsConfig.paths)) { if ( paths.includes("./*") || paths.includes("./src/*") || paths.includes("./app/*") || paths.includes("./resources/js/*") // Laravel. ) { return alias.at(0) ?? null } } return null } export async function isTypeScriptProject(cwd: string) { const files = await fg.glob("tsconfig.*", { cwd, deep: 1, ignore: PROJECT_SHARED_IGNORE, }) return files.length > 0 } export async function getTsConfig() { try { const tsconfigPath = path.join("tsconfig.json") const tsconfig = await fs.readJSON(tsconfigPath) if (!tsconfig) { throw new Error("tsconfig.json is missing") } return tsconfig } catch (error) { return null } } export async function getProjectConfig( cwd: string, defaultProjectInfo: ProjectInfo | null = null ): Promise<Config | null> { // Check for existing component config. const [existingConfig, projectInfo] = await Promise.all([ getConfig(cwd), !defaultProjectInfo ? getProjectInfo(cwd) : Promise.resolve(defaultProjectInfo), ]) if (existingConfig) { return existingConfig } if ( !projectInfo || !projectInfo.tailwindConfigFile || !projectInfo.tailwindCssFile ) { return null } const config: RawConfig = { $schema: "https://ui.shadcn.com/schema.json", rsc: projectInfo.isRSC, tsx: projectInfo.isTsx, style: "new-york", tailwind: { config: projectInfo.tailwindConfigFile, baseColor: "zinc", css: projectInfo.tailwindCssFile, cssVariables: true, prefix: "", }, aliases: { components: `${projectInfo.aliasPrefix}/components`, ui: `${projectInfo.aliasPrefix}/components/ui`, hooks: `${projectInfo.aliasPrefix}/hooks`, lib: `${projectInfo.aliasPrefix}/lib`, utils: `${projectInfo.aliasPrefix}/lib/utils`, }, } return await resolveConfigPaths(cwd, config) }
shadcn-ui/ui/packages/shadcn/src/utils/get-project-info.ts
{ "file_path": "shadcn-ui/ui/packages/shadcn/src/utils/get-project-info.ts", "repo_id": "shadcn-ui/ui", "token_count": 2269 }
99
import { promises as fs } from "fs" import path from "path" import { Config } from "@/src/utils/get-config" import { highlighter } from "@/src/utils/highlighter" import { registryItemCssVarsSchema } from "@/src/utils/registry/schema" import { spinner } from "@/src/utils/spinner" import postcss from "postcss" import AtRule from "postcss/lib/at-rule" import Root from "postcss/lib/root" import Rule from "postcss/lib/rule" import { z } from "zod" export async function updateCssVars( cssVars: z.infer<typeof registryItemCssVarsSchema> | undefined, config: Config, options: { cleanupDefaultNextStyles?: boolean silent?: boolean } ) { if ( !cssVars || !Object.keys(cssVars).length || !config.resolvedPaths.tailwindCss ) { return } options = { cleanupDefaultNextStyles: false, silent: false, ...options, } const cssFilepath = config.resolvedPaths.tailwindCss const cssFilepathRelative = path.relative( config.resolvedPaths.cwd, cssFilepath ) const cssVarsSpinner = spinner( `Updating ${highlighter.info(cssFilepathRelative)}`, { silent: options.silent, } ).start() const raw = await fs.readFile(cssFilepath, "utf8") let output = await transformCssVars(raw, cssVars, config, { cleanupDefaultNextStyles: options.cleanupDefaultNextStyles, }) await fs.writeFile(cssFilepath, output, "utf8") cssVarsSpinner.succeed() } export async function transformCssVars( input: string, cssVars: z.infer<typeof registryItemCssVarsSchema>, config: Config, options: { cleanupDefaultNextStyles?: boolean } ) { options = { cleanupDefaultNextStyles: false, ...options, } const plugins = [updateCssVarsPlugin(cssVars)] if (options.cleanupDefaultNextStyles) { plugins.push(cleanupDefaultNextStylesPlugin()) } // Only add the base layer plugin if we're using css variables. if (config.tailwind.cssVariables) { plugins.push(updateBaseLayerPlugin()) } const result = await postcss(plugins).process(input, { from: undefined, }) return result.css } function updateBaseLayerPlugin() { return { postcssPlugin: "update-base-layer", Once(root: Root) { const requiredRules = [ { selector: "*", apply: "border-border" }, { selector: "body", apply: "bg-background text-foreground" }, ] let baseLayer = root.nodes.find( (node): node is AtRule => node.type === "atrule" && node.name === "layer" && node.params === "base" && requiredRules.every(({ selector, apply }) => node.nodes?.some( (rule): rule is Rule => rule.type === "rule" && rule.selector === selector && rule.nodes.some( (applyRule): applyRule is AtRule => applyRule.type === "atrule" && applyRule.name === "apply" && applyRule.params === apply ) ) ) ) as AtRule | undefined if (!baseLayer) { baseLayer = postcss.atRule({ name: "layer", params: "base", raws: { semicolon: true, between: " ", before: "\n" }, }) root.append(baseLayer) } requiredRules.forEach(({ selector, apply }) => { const existingRule = baseLayer?.nodes?.find( (node): node is Rule => node.type === "rule" && node.selector === selector ) if (!existingRule) { baseLayer?.append( postcss.rule({ selector, nodes: [ postcss.atRule({ name: "apply", params: apply, raws: { semicolon: true, before: "\n " }, }), ], raws: { semicolon: true, between: " ", before: "\n " }, }) ) } }) }, } } function updateCssVarsPlugin( cssVars: z.infer<typeof registryItemCssVarsSchema> ) { return { postcssPlugin: "update-css-vars", Once(root: Root) { let baseLayer = root.nodes.find( (node) => node.type === "atrule" && node.name === "layer" && node.params === "base" ) as AtRule | undefined if (!(baseLayer instanceof AtRule)) { baseLayer = postcss.atRule({ name: "layer", params: "base", nodes: [], raws: { semicolon: true, before: "\n", between: " ", }, }) root.append(baseLayer) } if (baseLayer !== undefined) { // Add variables for each key in cssVars Object.entries(cssVars).forEach(([key, vars]) => { const selector = key === "light" ? ":root" : `.${key}` // TODO: Fix typecheck. addOrUpdateVars(baseLayer as AtRule, selector, vars) }) } }, } } function removeConflictVars(root: Rule | Root) { const rootRule = root.nodes.find( (node): node is Rule => node.type === "rule" && node.selector === ":root" ) if (rootRule) { const propsToRemove = ["--background", "--foreground"] rootRule.nodes .filter( (node): node is postcss.Declaration => node.type === "decl" && propsToRemove.includes(node.prop) ) .forEach((node) => node.remove()) if (rootRule.nodes.length === 0) { rootRule.remove() } } } function cleanupDefaultNextStylesPlugin() { return { postcssPlugin: "cleanup-default-next-styles", Once(root: Root) { const bodyRule = root.nodes.find( (node): node is Rule => node.type === "rule" && node.selector === "body" ) if (bodyRule) { // Remove color from the body node. bodyRule.nodes .find( (node): node is postcss.Declaration => node.type === "decl" && node.prop === "color" && ["rgb(var(--foreground-rgb))", "var(--foreground)"].includes( node.value ) ) ?.remove() // Remove background: linear-gradient. bodyRule.nodes .find((node): node is postcss.Declaration => { return ( node.type === "decl" && node.prop === "background" && // This is only going to run on create project, so all good. (node.value.startsWith("linear-gradient") || node.value === "var(--background)") ) }) ?.remove() // If the body rule is empty, remove it. if (bodyRule.nodes.length === 0) { bodyRule.remove() } } removeConflictVars(root) const darkRootRule = root.nodes.find( (node): node is Rule => node.type === "atrule" && node.params === "(prefers-color-scheme: dark)" ) if (darkRootRule) { removeConflictVars(darkRootRule) if (darkRootRule.nodes.length === 0) { darkRootRule.remove() } } }, } } function addOrUpdateVars( baseLayer: AtRule, selector: string, vars: Record<string, string> ) { let ruleNode = baseLayer.nodes?.find( (node): node is Rule => node.type === "rule" && node.selector === selector ) if (!ruleNode) { if (Object.keys(vars).length > 0) { ruleNode = postcss.rule({ selector, raws: { between: " ", before: "\n " }, }) baseLayer.append(ruleNode) } } Object.entries(vars).forEach(([key, value]) => { const prop = `--${key.replace(/^--/, "")}` const newDecl = postcss.decl({ prop, value, raws: { semicolon: true }, }) const existingDecl = ruleNode?.nodes.find( (node): node is postcss.Declaration => node.type === "decl" && node.prop === prop ) existingDecl ? existingDecl.replaceWith(newDecl) : ruleNode?.append(newDecl) }) }
shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-css-vars.ts
{ "file_path": "shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-css-vars.ts", "repo_id": "shadcn-ui/ui", "token_count": 3666 }
100
body { background-color: red; }
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages-src/src/styles/other.css
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages-src/src/styles/other.css", "repo_id": "shadcn-ui/ui", "token_count": 13 }
101
DATABASE_URL="file:./data.db?connection_limit=1" SESSION_SECRET="super-duper-s3cret"
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/.env.example
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/.env.example", "repo_id": "shadcn-ui/ui", "token_count": 38 }
102
import type { LoaderFunctionArgs } from "@remix-run/node"; import { json } from "@remix-run/node"; import { Form, Link, NavLink, Outlet, useLoaderData } from "@remix-run/react"; import { getNoteListItems } from "~/models/note.server"; import { requireUserId } from "~/session.server"; import { useUser } from "~/utils"; export const loader = async ({ request }: LoaderFunctionArgs) => { const userId = await requireUserId(request); const noteListItems = await getNoteListItems({ userId }); return json({ noteListItems }); }; export default function NotesPage() { const data = useLoaderData<typeof loader>(); const user = useUser(); return ( <div className="flex h-full min-h-screen flex-col"> <header className="flex items-center justify-between bg-slate-800 p-4 text-white"> <h1 className="text-3xl font-bold"> <Link to="">Notes</Link> </h1> <p>{user.email}</p> <Form action="/logout" method="post"> <button type="submit" className="rounded bg-slate-600 px-4 py-2 text-blue-100 hover:bg-blue-500 active:bg-blue-600" > Logout </button> </Form> </header> <main className="flex h-full bg-white"> <div className="h-full w-80 border-r bg-gray-50"> <Link to="new" className="block p-4 text-xl text-blue-500"> + New Note </Link> <hr /> {data.noteListItems.length === 0 ? ( <p className="p-4">No notes yet</p> ) : ( <ol> {data.noteListItems.map((note) => ( <li key={note.id}> <NavLink className={({ isActive }) => `block border-b p-4 text-xl ${isActive ? "bg-white" : ""}` } to={note.id} > {note.title} </NavLink> </li> ))} </ol> )} </div> <div className="flex-1 p-6"> <Outlet /> </div> </main> </div> ); }
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/notes.tsx
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/notes.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1080 }
103
import type { Config } from "tailwindcss"; export default { content: ["./app/**/*.{js,jsx,ts,tsx}"], theme: { extend: {}, }, plugins: [], } satisfies Config;
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/tailwind.config.ts
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/tailwind.config.ts", "repo_id": "shadcn-ui/ui", "token_count": 67 }
104
import path from "path" import { expect, test } from "vitest" import { getConfig, getRawConfig } from "../../src/utils/get-config" test("get raw config", async () => { expect( await getRawConfig(path.resolve(__dirname, "../fixtures/config-none")) ).toEqual(null) expect( await getRawConfig(path.resolve(__dirname, "../fixtures/config-partial")) ).toEqual({ style: "default", tailwind: { config: "./tailwind.config.ts", css: "./src/assets/css/tailwind.css", baseColor: "neutral", cssVariables: false, }, rsc: false, tsx: true, aliases: { components: "@/components", utils: "@/lib/utils", }, }) expect( getRawConfig(path.resolve(__dirname, "../fixtures/config-invalid")) ).rejects.toThrowError() }) test("get config", async () => { expect( await getConfig(path.resolve(__dirname, "../fixtures/config-none")) ).toEqual(null) expect( getConfig(path.resolve(__dirname, "../fixtures/config-invalid")) ).rejects.toThrowError() expect( await getConfig(path.resolve(__dirname, "../fixtures/config-partial")) ).toEqual({ style: "default", tailwind: { config: "./tailwind.config.ts", css: "./src/assets/css/tailwind.css", baseColor: "neutral", cssVariables: false, }, rsc: false, tsx: true, aliases: { components: "@/components", utils: "@/lib/utils", }, resolvedPaths: { cwd: path.resolve(__dirname, "../fixtures/config-partial"), tailwindConfig: path.resolve( __dirname, "../fixtures/config-partial", "tailwind.config.ts" ), tailwindCss: path.resolve( __dirname, "../fixtures/config-partial", "./src/assets/css/tailwind.css" ), components: path.resolve( __dirname, "../fixtures/config-partial", "./components" ), utils: path.resolve( __dirname, "../fixtures/config-partial", "./lib/utils" ), ui: path.resolve( __dirname, "../fixtures/config-partial", "./components/ui" ), hooks: path.resolve(__dirname, "../fixtures/config-partial", "./hooks"), lib: path.resolve(__dirname, "../fixtures/config-partial", "./lib"), }, }) expect( await getConfig(path.resolve(__dirname, "../fixtures/config-full")) ).toEqual({ style: "new-york", rsc: false, tsx: true, tailwind: { config: "tailwind.config.ts", baseColor: "zinc", css: "src/app/globals.css", cssVariables: true, prefix: "tw-", }, aliases: { components: "~/components", utils: "~/lib/utils", lib: "~/lib", hooks: "~/lib/hooks", ui: "~/ui", }, resolvedPaths: { cwd: path.resolve(__dirname, "../fixtures/config-full"), tailwindConfig: path.resolve( __dirname, "../fixtures/config-full", "tailwind.config.ts" ), tailwindCss: path.resolve( __dirname, "../fixtures/config-full", "./src/app/globals.css" ), components: path.resolve( __dirname, "../fixtures/config-full", "./src/components" ), ui: path.resolve(__dirname, "../fixtures/config-full", "./src/ui"), hooks: path.resolve( __dirname, "../fixtures/config-full", "./src/lib/hooks" ), lib: path.resolve(__dirname, "../fixtures/config-full", "./src/lib"), utils: path.resolve( __dirname, "../fixtures/config-full", "./src/lib/utils" ), }, }) expect( await getConfig(path.resolve(__dirname, "../fixtures/config-jsx")) ).toEqual({ style: "default", tailwind: { config: "./tailwind.config.js", css: "./src/assets/css/tailwind.css", baseColor: "neutral", cssVariables: false, }, rsc: false, tsx: false, aliases: { components: "@/components", utils: "@/lib/utils", }, resolvedPaths: { cwd: path.resolve(__dirname, "../fixtures/config-jsx"), tailwindConfig: path.resolve( __dirname, "../fixtures/config-jsx", "tailwind.config.js" ), tailwindCss: path.resolve( __dirname, "../fixtures/config-jsx", "./src/assets/css/tailwind.css" ), components: path.resolve( __dirname, "../fixtures/config-jsx", "./components" ), ui: path.resolve(__dirname, "../fixtures/config-jsx", "./components/ui"), utils: path.resolve(__dirname, "../fixtures/config-jsx", "./lib/utils"), hooks: path.resolve(__dirname, "../fixtures/config-jsx", "./hooks"), lib: path.resolve(__dirname, "../fixtures/config-jsx", "./lib"), }, }) })
shadcn-ui/ui/packages/shadcn/test/utils/get-config.test.ts
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/utils/get-config.test.ts", "repo_id": "shadcn-ui/ui", "token_count": 2281 }
105
"use client" import React from "react" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { Card, CardDescription, CardTitle } from "@/components/ui/card" import { Icons } from "@/components/icons" import AdBanner from "@/components/ad-banner" import { BellRing, ClipboardList, Flag, Folder, StickyNote, Trophy } from "lucide-react" import CreateNewComponent from "@/components/easyui/create-new" import { Tabs, TabsList, TabsTrigger, TabsContent } from "@/components/ui/tabs" import { RotateCcw } from "lucide-react" import { CopyIcon } from "@radix-ui/react-icons" import LaunchPad from "@/components/easyui/launchpad" import KeyButton from "@/components/easyui/key-button" import SparkleButton from "@/components/easyui/sparkle-button" function SparkleButtonComponent() { const [key, setKey] = React.useState(0); // State to trigger re-render return ( <div className="flex flex-wrap justify-start gap-4 pb-10 max-w-full min-w-full px-0 lg:px-20"> <div className="w-full sm:w-1/2 p-2 mt-3 space-y-4 lg:mt-5 md:lg-5"> <CardTitle className="text-3xl tracking-tight leading-7">Sparkle Button</CardTitle> <CardDescription className="text-balance text-lg text-muted-foreground">Click or Hover to see the Spark.</CardDescription> </div> <Tabs defaultValue="preview" className="relative mr-auto w-full"> <div className="flex items-center justify-between pb-3"> <TabsList className="w-full justify-start rounded-none bg-transparent p-0"> <TabsTrigger value="preview" className="relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"> Preview </TabsTrigger> <TabsTrigger value="code" className="relative h-9 rounded-none border-b-2 border-b-transparent bg-transparent px-4 pb-3 pt-2 font-semibold text-muted-foreground shadow-none transition-none data-[state=active]:border-b-primary data-[state=active]:text-foreground data-[state=active]:shadow-none"> Code </TabsTrigger> </TabsList> </div> <TabsContent value="preview" className="relative rounded-md" key={key}> <div className="flex items-center justify-center max-w-full mx-auto px-4 py-0.5 border rounded-lg h-[400px]"> <Button onClick={() => setKey((prev) => prev + 1)} className="absolute right-0 top-0 z-10 ml-4 flex items-center rounded-lg px-3 py-1" variant="ghost"> <RotateCcw size={16} /> </Button> {/* @ts-ignore */} <SparkleButton text="Sparkle Button" size="lg" /> </div> </TabsContent> <TabsContent value="code"> <div className="flex flex-col space-y-4 ml-3 lg:ml-4 md:lg-3"> <h2 className="font-semibold mt-12 scroll-m-20 border-b pb-2 text-2xl tracking-tight first:mt-0 leading-7"> Installation </h2> <p className="font-semibold mt-5 tracking-tight leading-7">Step 1: Copy and paste the following code into your<span className="font-normal italic"> components/sparkle-button.tsx</span></p> <div className="w-full rounded-md [&_pre]:my-0 [&_pre]:max-h-[350px] [&_pre]:overflow-auto relative bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700 font-sm"> <button onClick={() => { const codeElement = document.getElementById('codeBlock'); const codeToCopy = codeElement ? codeElement.textContent : ''; // @ts-ignore navigator.clipboard.writeText(codeToCopy).then(() => { alert('Code copied to clipboard!'); }); }} className="absolute right-0 top-0 z-10 m-4 flex items-center rounded-lg px-3 py-1 text-white" title="Copy code to clipboard"> {/* <svg xmlns="http://www.w3.org/2000/svg" className="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2"> <path strokeLinecap="round" strokeLinejoin="round" d="M8 5C6.895 5 6 5.895 6 7v10c0 1.105.895 2 2 2h8c1.105 0 2-.895 2-2V7c0-1.105-.895-2-2-2H8zm0 0V3c0-1.105.895-2 2-2h4c1.105 0 2 .895 2 2v2m-6 4h4" /> </svg> */} <CopyIcon className="text-black hover:text-gray-400 active:text-blue-700 h-4 dark:text-white" style={{ backdropFilter: 'blur(20px)' }} /> </button> <pre className={`ml-2 py-2 pb-2 pl-2 font-sm min-h-[600px] lg:min-h-[600px] sm:min-h-[300px]`}> <code id="codeBlock" className="text-left language-js text-sm"> {`import React, { CSSProperties, useEffect, useRef, useState } from "react" import { Button } from "../ui/button" const RANDOM = (min: number, max: number) => Math.floor(Math.random() * (max - min + 1) + min) interface SparkleProps { text: string size: string variant: string } const SparkleButton = ({ text, size, variant }: SparkleProps) => { const [isActive, setIsActive] = useState(false) const particlesRef = useRef<Array<HTMLDivElement | null>>([]) useEffect(() => { particlesRef.current.forEach((P) => { if (P) { P.style.setProperty("--x", \`\${RANDOM(20, 80)}\`) P.style.setProperty("--y", \`\${RANDOM(20, 80)}\`) P.style.setProperty("--duration", \`\${RANDOM(6, 20)}\`) P.style.setProperty("--delay", \`\${RANDOM(1, 10)}\`) P.style.setProperty("--alpha", \`\${RANDOM(40, 90) / 100}\`) P.style.setProperty( "--origin-x", \`\${Math.random() > 0.5 ? RANDOM(300, 800) * -1 : RANDOM(300, 800)}%\` ) P.style.setProperty( "--origin-y", \`\${Math.random() > 0.5 ? RANDOM(300, 800) * -1 : RANDOM(300, 800)}%\` ) P.style.setProperty("--size", \`\${RANDOM(40, 90) / 100}\`) } }) }, []) return ( <div className="flex items-center justify-center w-full h-full bg-transparent overflow-hidden"> <div className="sparkle-button relative"> <Button className="relative text-2xl text-sm py-3 px-5 rounded-full flex items-center gap-1 whitespace-nowrap transition-all duration-250 cursor-pointer" onMouseEnter={() => setIsActive(true)} onMouseLeave={() => setIsActive(false)} size={size} variant={variant} style={ { "--active": isActive ? "1" : "0", "--cut": "0.1em", background: \` radial-gradient( 40% 50% at center 100%, hsl(270 calc(var(--active) * 97%) 72% / var(--active)), transparent ), radial-gradient( 80% 100% at center 120%, hsl(260 calc(var(--active) * 97%) 70% / var(--active)), transparent ), hsl(260 calc(var(--active) * 97%) calc((var(--active) * 44%) + 12%)) \`, boxShadow: \` 0 0 calc(var(--active) * 6em) calc(var(--active) * 3em) hsl(260 97% 61% / 0.75), 0 0.05em 0 0 hsl(260 calc(var(--active) * 97%) calc((var(--active) * 50%) + 30%)) inset, 0 -0.05em 0 0 hsl(260 calc(var(--active) * 97%) calc(var(--active) * 60%)) inset \`, transform: \`scale(calc(1 + (var(--active) * 0.1)))\`, } as CSSProperties } > <span className="text relative z-10 translate-x-[2%] -translate-y-[6%] " style={{ background: \`linear-gradient(90deg, hsl(0 0% calc((var(--active) * 100%) + 65%)), hsl(0 0% calc((var(--active) * 100%) + 26%)))\`, WebkitBackgroundClip: "text", color: "transparent", }} > {text} </span> <svg className="sparkle w-6 h-6 ml-3 relative z-10 -translate-x-[25%] -translate-y-[5%]" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M10 7L15 12L10 17" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ color: \`hsl(0 0% calc((var(--active, 0) * 70%) + 20%))\`, // animation: isActive ? 'bounce 0.6s' : 'none', animationDelay: "calc((0.25s * 1.5) + (0.1s * 1s))", "--scale": "0.5", }} /> <path d="M15 12H3" stroke="currentColor" strokeWidth="2" strokeLinecap="round" strokeLinejoin="round" style={{ color: \`hsl(0 0% calc((var(--active, 0) * 70%) + 20%))\`, // animation: isActive ? 'bounce 0.6s' : 'none', animationDelay: "calc((0.25s * 1.5) + (0.2s * 1s))", "--scale": "1.5", }} /> </svg> <div className="spark absolute inset-0 rounded-full rotate-0 overflow-hidden" style={{ mask: "linear-gradient(white, transparent 50%)", animation: "flip 3.6s infinite steps(2, end)", }} > <div className="spark-rotate absolute w-[200%] aspect-square top-0 left-1/2 -translate-x-1/2 -translate-y-[15%] -rotate-90 animate-rotate" style={{ opacity: \`calc((var(--active)) + 0.4)\`, background: "conic-gradient(from 0deg, transparent 0 340deg, white 360deg)", }} /> </div> <div className="backdrop absolute rounded-full transition-all duration-250" style={{ inset: "var(--cut)", background: \` radial-gradient( 40% 50% at center 100%, hsl(270 calc(var(--active) * 97%) 72% / var(--active)), transparent ), radial-gradient( 80% 100% at center 120%, hsl(260 calc(var(--active) * 97%) 70% / var(--active)), transparent ), hsl(260 calc(var(--active) * 97%) calc((var(--active) * 44%) + 12%)) \`, }} /> </Button> <div className="particle-pen absolute w-[200%] aspect-square top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 z-[-1]" style={{ WebkitMask: "radial-gradient(white, transparent 65%)", opacity: isActive ? "1" : "0", transition: "opacity 0.25s", }} > {[...Array(20)].map((_, index) => ( <div key={index} ref={(el) => (particlesRef.current[index] = el)} className="particle absolute animate-float-out" style={ { "--duration": \`calc(var(--duration, 1) * 1s)\`, "--delay": \`calc(var(--delay, 0) * -1s)\`, width: "calc(var(--size, 0.25) * 1rem)", aspectRatio: "1", top: "calc(var(--y, 50) * 1%)", left: "calc(var(--x, 50) * 1%)", opacity: "var(--alpha, 1)", animationDirection: index % 2 === 0 ? "reverse" : "normal", animationPlayState: isActive ? "running" : "paused", transformOrigin: "var(--origin-x, 1000%) var(--origin-y, 1000%)", } as CSSProperties } > <svg width="100%" height="100%" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg" > <path d="M7.5 0L9.08257 5.17647L13.5 7.5L9.08257 9.82353L7.5 15L5.91743 9.82353L1.5 7.5L5.91743 5.17647L7.5 0Z" fill="hsl(260, 97%, 61%)" /> </svg> </div> ))} </div> </div> </div> ) } export default SparkleButton`} </code> </pre> </div> </div> <div className="flex flex-col space-y-4 ml-3 lg:ml-4 md:lg-3"> <p className="font-semibold mt-5 tracking-tight leading-7">Step 2: Update the import paths and run this code.</p> <div className="w-full rounded-md [&_pre]:my-0 [&_pre]:max-h-[350px] [&_pre]:overflow-auto relative bg-gray-100 dark:bg-gray-800 border border-gray-200 dark:border-gray-700"> <button onClick={() => { const codeElement = document.getElementById('codeBlock2'); const copycode2 = codeElement ? codeElement.textContent : ''; if (copycode2) { navigator.clipboard.writeText(copycode2).then(() => { alert('Code copied to clipboard!'); }); } }} className="absolute right-0 top-0 z-10 m-4 flex items-center rounded-lg bg-transparent px-3 py-1 text-white" title="Copy code to clipboard"> <CopyIcon className="text-black hover:text-gray-400 active:text-blue-700 h-4 dark:text-white" /> </button> <pre className="ml-2 py-2 pb-2 pl-2 font-sm"><code id="codeBlock2" className="text-left language-js text-sm"> {`"use client" import SparkleButton from "@/components/easyui/sparkle-button" import React from "react" function Home() { return ( <div className="flex flex-col mx-auto justify-center text-center items-center align-center py-20"> <SparkleButton text="Sparkle Button" size="lg" /> </div> ) } export default Home `} {/* </div> */} </code></pre> </div> </div> {/* <div className="mt-5 px-4 ml-3 lg:ml-1 md:lg-3"> */} {/* <h2 className="text-2xl font-semibold mb-5 tracking-tight leading-7 border-b dark:border-gray-700 pb-2 scroll-m-20">Props</h2> <table className="min-w-full table-auto border-collapse border border-gray-300 dark:border-gray-700"> <thead> <tr className="bg-gray-100 dark:bg-gray-900"> <th className="border border-gray-300 px-4 py-2 dark:border-gray-700">Prop Name</th> <th className="border border-gray-300 px-4 py-2 dark:border-gray-700">Type</th> <th className="border border-gray-300 px-4 py-2 dark:border-gray-700">Description</th> <th className="border border-gray-300 px-4 py-2 dark:border-gray-700">Default Value</th> </tr> </thead> <tbody> <tr> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">id</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">Number</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700"> Unique identifier for each application. </td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">-</td> </tr> <tr> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">name</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">String</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700"> Name of the application. </td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">-</td> </tr> <tr> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">icon</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">String</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700"> URL or path to the application&apos;s icon image. </td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">-</td> </tr> <tr> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">category</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">String</td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700"> Category to which the application belongs. </td> <td className="border border-gray-300 px-4 py-2 dark:border-gray-700">-</td> </tr> </tbody> </table> */} {/* </div> */} </TabsContent> </Tabs> {/* <div className="py-10 ml-3"> <h2 className="font-heading mt-12 scroll-m-20 border-b pb-2 text-2xl font-semibold tracking-tight first:mt-0">Credits</h2> <p className="leading-7 [&:not(:first-child)]:mt-6 tracking tight">Credit to <a href="https://github.com/vaunblu/lab/blob/main/src/app/create-new/page.tsx" className="underline italic font-semibold" target="_blank" rel="noopener noreferrer">@vaunblu</a> for the inspiration behind this component.</p> </div> */} </div> ) } export default SparkleButtonComponent
DarkInventor/easy-ui/app/(docs)/sparkle-button-component/page.tsx
{ "file_path": "DarkInventor/easy-ui/app/(docs)/sparkle-button-component/page.tsx", "repo_id": "DarkInventor/easy-ui", "token_count": 8916 }
0
import Balance from "react-wrap-balancer" import { cn } from "@/lib/utils" function PageHeader({ className, children, ...props }: React.HTMLAttributes<HTMLDivElement>) { return ( <section className={cn( "mx-auto flex max-w-[980px] flex-col items-center gap-2 py-8 md:py-12 md:pb-8 lg:py-24 lg:pb-20", className )} {...props} > {children} </section> ) } function PageHeaderHeading({ className, ...props }: React.HTMLAttributes<HTMLHeadingElement>) { return ( <h1 className={cn( "text-center text-3xl font-bold leading-tight tracking-tighter md:text-5xl lg:leading-[1.1]", className )} {...props} /> ) } function PageHeaderDescription({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) { return ( <Balance className={cn( "max-w-[750px] text-center text-lg font-light text-foreground", className )} {...props} /> ) } function PageActions({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) { return ( <div className={cn( "flex w-full items-center justify-center space-x-4 py-4 md:pb-10", className )} {...props} /> ) } export { PageHeader, PageHeaderHeading, PageHeaderDescription, PageActions }
DarkInventor/easy-ui/components/page-header.tsx
{ "file_path": "DarkInventor/easy-ui/components/page-header.tsx", "repo_id": "DarkInventor/easy-ui", "token_count": 587 }
1
import { SiteHeader } from "@/app/(app)/_components/side-header"; import { SiteFooter } from "@/app/(app)/_components/site-footer"; interface AppLayoutProps { children: React.ReactNode; } export default function AppLayout({ children }: AppLayoutProps) { return ( <> <SiteHeader /> <main className="flex-1">{children}</main> <SiteFooter /> </> ); }
alifarooq9/rapidlaunch/apps/www/src/app/(app)/layout.tsx
{ "file_path": "alifarooq9/rapidlaunch/apps/www/src/app/(app)/layout.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 176 }
2
import { pgTableCreator, timestamp, varchar } from "drizzle-orm/pg-core"; import { sql } from "drizzle-orm"; /** * This is an example of how to use the multi-project schema feature of Drizzle ORM. Use the same * database instance for multiple projects. * * @see https://orm.drizzle.team/docs/goodies#multi-project-schema */ export const createTable = pgTableCreator((name) => `rapidlaunch_${name}`); export const earlyAccess = createTable("early_access", { id: varchar("id", { length: 255 }) .notNull() .primaryKey() .default(sql`gen_random_uuid()`), name: varchar("name", { length: 255 }), email: varchar("email", { length: 255 }).notNull().unique(), createdAt: timestamp("createdAt", { mode: "date" }).notNull().defaultNow(), });
alifarooq9/rapidlaunch/packages/db/src/schema.ts
{ "file_path": "alifarooq9/rapidlaunch/packages/db/src/schema.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 271 }
3
/** @type {import("eslint").Linter.Config} */ const config = { parser: "@typescript-eslint/parser", parserOptions: { project: true, }, plugins: ["@typescript-eslint"], extends: [ "next/core-web-vitals", "plugin:@typescript-eslint/recommended-type-checked", "plugin:@typescript-eslint/stylistic-type-checked", ], rules: { // These opinionated rules are enabled in stylistic-type-checked above. // Feel free to reconfigure them to your own preference. "@typescript-eslint/array-type": "off", "@typescript-eslint/consistent-type-definitions": "off", "@typescript-eslint/consistent-type-imports": [ "warn", { prefer: "type-imports", fixStyle: "inline-type-imports", }, ], "@typescript-eslint/no-unused-vars": [ "warn", { argsIgnorePattern: "^_" }, ], "@typescript-eslint/require-await": "off", "@typescript-eslint/no-misused-promises": [ "error", { checksVoidReturn: { attributes: false }, }, ], }, overrides: [ { files: "*.mdx", parser: "eslint-mdx", }, ], }; module.exports = config;
alifarooq9/rapidlaunch/starterkits/saas/.eslintrc.cjs
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/.eslintrc.cjs", "repo_id": "alifarooq9/rapidlaunch", "token_count": 683 }
4
"use client"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { z } from "zod"; import { RadioGroupItem, RadioGroup } from "@/components/ui/radio-group"; import { Label } from "@/components/ui/label"; import { CardTitle, CardDescription, CardHeader, CardContent, Card, } from "@/components/ui/card"; import { buttonVariants } from "@/components/ui/button"; import { pricingFeatures, pricingIds, pricingPlans } from "@/config/pricing"; import { cn } from "@/lib/utils"; import type { OrgSubscription } from "@/types/org-subscription"; import { CheckIcon, XIcon } from "lucide-react"; import { SwitchPlanModal } from "@/app/(app)/(user)/org/billing/_components/switch-plan-modal"; type AvailablePlansProps = { subscription: OrgSubscription; }; const FormSchema = z.object({ plan: pricingPlans.length > 0 ? z.enum( pricingPlans.map((plan) => plan.id) as [string, ...string[]], ) : z.enum(["default"]), billing: z.enum(["monthly", "yearly"]), }); export function AvailablePlans({ subscription }: AvailablePlansProps) { const form = useForm({ resolver: zodResolver(FormSchema), defaultValues: { plan: pricingPlans.find( (plan) => plan.variantId?.monthly === subscription?.variant_id || plan.variantId?.yearly === subscription?.variant_id, )?.id ?? pricingPlans[0]?.id, billing: pricingPlans.find( (plan) => plan.variantId?.monthly === subscription?.variant_id || plan.variantId?.yearly === subscription?.variant_id, ) ? "monthly" : "yearly", }, }); const selectedPlanId = form.watch("plan")!; const selectedBilling = form.watch("billing"); const selectedPlan = pricingPlans.find((plan) => plan.id === selectedPlanId) ?? pricingPlans[0]; const selectedVariantId = selectedBilling === "monthly" ? selectedPlan?.variantId?.monthly : selectedPlan?.variantId?.yearly; return ( <form> <Card> <CardHeader> <CardTitle>Available Plans</CardTitle> <CardDescription> View available plans and change subscription </CardDescription> </CardHeader> <CardContent> <div className=" grid gap-4 lg:grid-cols-2 lg:gap-6"> <div className=""> <div className="space-y-4"> <Card> <CardHeader> <CardTitle>Billing Cycle</CardTitle> <CardDescription> Choose your billing cycle </CardDescription> </CardHeader> <CardContent> <RadioGroup defaultValue={ pricingPlans.find( (plan) => plan.variantId ?.monthly === subscription?.variant_id || plan.variantId ?.yearly === subscription?.variant_id, ) ? "monthly" : "yearly" } {...form.register("billing")} className="grid grid-cols-2 gap-4" onValueChange={(value: string) => form.setValue("billing", value) } > <div> <RadioGroupItem className="peer sr-only" id="monthly" value="monthly" /> <Label className={buttonVariants({ variant: "outline", className: "w-full cursor-pointer peer-data-[state=checked]:border-primary", })} htmlFor="monthly" > Monthly </Label> </div> <div> <RadioGroupItem className="peer sr-only" id="yearly" value="yearly" /> <Label className={buttonVariants({ className: "w-full cursor-pointer peer-data-[state=checked]:border-primary", variant: "outline", })} htmlFor="yearly" > Yearly </Label> </div> </RadioGroup> </CardContent> </Card> <Card> <CardHeader> <CardTitle>Plans</CardTitle> <CardDescription> Choose your plan </CardDescription> </CardHeader> <CardContent> <RadioGroup defaultValue={ pricingPlans.find( (plan) => plan.variantId ?.monthly === subscription?.variant_id || plan.variantId ?.yearly === subscription?.variant_id, )?.id ?? pricingPlans[0]?.id } className="space-y-2" {...form.register("plan")} onValueChange={( value: string | undefined, ) => form.setValue("plan", value)} > {pricingPlans.map((plan) => ( <div key={plan.id}> <RadioGroupItem className="peer sr-only" id={plan.title} value={plan.id} /> <Label className="flex cursor-pointer items-center justify-between rounded-lg border border-border p-4 shadow-sm transition-colors hover:bg-muted peer-data-[state=checked]:border-primary" htmlFor={plan.title} > <div className="space-y-1"> <p className="font-heading font-semibold"> {plan.title} </p> <p className="pr-2 text-xs font-light text-muted-foreground"> { plan.description } </p> </div> <div className="font-heading text-lg font-medium"> $ {selectedBilling === "monthly" ? plan.price .monthly : plan.price .yearly} </div> </Label> </div> ))} </RadioGroup> </CardContent> </Card> </div> </div> <div className="space-y-4"> <Card> <CardHeader> <CardTitle className="text-lg"> {selectedPlan?.title} Plan </CardTitle> <CardDescription> {selectedPlan?.description} </CardDescription> </CardHeader> <CardContent> <ul className="space-y-1"> {pricingFeatures.map((feature) => ( <li key={feature.id} className={cn( "flex items-center text-sm font-light", !feature.inludedIn.includes( selectedPlanId, ) && "text-muted-foreground/70", )} > {feature.inludedIn.includes( selectedPlanId, ) ? ( <CheckIcon className="mr-1 h-4 w-4" /> ) : ( <XIcon className="mr-1 h-4 w-4 text-muted-foreground/70" /> )} {feature.title} </li> ))} </ul> </CardContent> </Card> {selectedVariantId === subscription?.variant_id ? ( <div className={buttonVariants({ className: "w-full cursor-not-allowed opacity-70", variant: "outline", })} > Current Plan </div> ) : selectedPlan?.id === pricingIds.free ? null : ( <div className="flex w-full flex-col gap-2"> <SwitchPlanModal cardBrand={ subscription?.card_brand ?? "" } lastCardDigits={ subscription?.card_last_four ?? "" } currencyCode={ selectedPlan?.currency.code ?? "USD" } currencySymbol={ selectedPlan?.currency.symbol ?? "$" } planName={selectedPlan?.title ?? ""} price={ selectedBilling === "monthly" ? selectedPlan?.price.monthly ?? 0 : selectedPlan?.price.yearly ?? 0 } variantId={selectedVariantId} status={subscription?.status ?? ""} /> </div> )} </div> </div> </CardContent> </Card> </form> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/available-plans.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/available-plans.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 11962 }
5
export const orgMembersInvitePageConfig = { title: "Invite Members", description: "Invite members to your organization here! Manage requests and more!", } as const;
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/invite/_constants/page-config.ts
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/invite/_constants/page-config.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 56 }
6
import { AppPageLoading } from "@/app/(app)/_components/page-loading"; import { profileSettingsPageConfig } from "@/app/(app)/(user)/profile/settings/_constants/page-config"; import { Skeleton } from "@/components/ui/skeleton"; export default function ProfileSettingsLoading() { return ( <AppPageLoading title={profileSettingsPageConfig.title} description={profileSettingsPageConfig.description} > <div className="grid grid-cols-1 gap-4 sm:grid-cols-2"> <Skeleton className="h-60 w-full" /> <Skeleton className="h-60 w-full" /> <Skeleton className="h-60 w-full" /> </div> </AppPageLoading> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/profile/settings/loading.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/profile/settings/loading.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 308 }
7
"use client"; import { Icons } from "@/components/ui/icons"; import { create } from "zustand"; type SwitchOrgPendingState = { isPending: boolean; setIsPending: (value: boolean) => void; }; export const switchOrgPendingState = create<SwitchOrgPendingState>()((set) => ({ isPending: false, setIsPending: (value) => set({ isPending: value }), })); export function SwtichOrgLoading() { const { isPending } = switchOrgPendingState(); if (!isPending) return null; return ( <div aria-description="Org Switching Loading" className="fixed inset-0 z-[20000] flex h-screen w-screen flex-col items-center justify-center gap-2 bg-background" > <Icons.loader className="h-7 w-7" /> <p className="text-lg font-semibold">Switching Org...</p> </div> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/org-switch-loading.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/org-switch-loading.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 349 }
8
"use client"; import { DataTable } from "@/app/(app)/_components/data-table"; import { type ColumnDef } from "@tanstack/react-table"; import React, { useMemo } from "react"; import { type FeedbackData, getColumns } from "./columns"; import { feedbackStatusEnum, feedbackLabelEnum } from "@/server/db/schema"; import { useDataTable } from "@/hooks/use-data-table"; import type { DataTableFilterableColumn, DataTableSearchableColumn, } from "@/types/data-table"; import { type getAllPaginatedFeedbacksQuery } from "@/server/actions/feedback/queries"; /** @learn more about data-table at shadcn ui website @see https://ui.shadcn.com/docs/components/data-table */ const filterableColumns: DataTableFilterableColumn<FeedbackData>[] = [ { id: "status", title: "Status", options: feedbackStatusEnum.enumValues.map((v) => ({ label: v, value: v, })), }, { id: "label", title: "Label", options: feedbackLabelEnum.enumValues.map((v) => ({ label: v, value: v, })), }, ]; type FeedbacksTableProps = { feedbacksPromise: ReturnType<typeof getAllPaginatedFeedbacksQuery>; }; const searchableColumns: DataTableSearchableColumn<FeedbackData>[] = [ { id: "title", placeholder: "Search title..." }, ]; export function FeedbacksTable({ feedbacksPromise }: FeedbacksTableProps) { const { data, pageCount, total } = React.use(feedbacksPromise); const columns = useMemo<ColumnDef<FeedbackData, unknown>[]>( () => getColumns(), [], ); const { table } = useDataTable({ data, columns, pageCount, searchableColumns, filterableColumns, }); return ( <DataTable table={table} columns={columns} filterableColumns={filterableColumns} searchableColumns={searchableColumns} totalRows={total} /> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/feedbacks/_components/feedbacks-table.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/feedbacks/_components/feedbacks-table.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 815 }
9
import { AppPageLoading } from "@/app/(app)/_components/page-loading"; import { usersPageConfig } from "@/app/(app)/admin/users/_constants/page-config"; import { Skeleton } from "@/components/ui/skeleton"; export default function UsersPageLoading() { return ( <AppPageLoading title={usersPageConfig.title} description={usersPageConfig.description} > <Skeleton className="h-96 w-full" /> </AppPageLoading> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/users/loading.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/users/loading.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 187 }
10
import Link from "next/link"; import { WebHeaderNav } from "@/app/(web)/_components/header-nav"; import { Icons } from "@/components/ui/icons"; import { siteUrls } from "@/config/urls"; import { ThemeToggle } from "@/components/theme-toggle"; import { HeaderAuth } from "@/app/(web)/_components/header-auth"; import { Suspense } from "react"; import { Button } from "@/components/ui/button"; import { MobileNav } from "@/app/(web)/_components/mobile-nav"; export function WebHeader() { return ( <div className="container sticky top-0 z-50 max-w-[1400px] pt-5"> <header className=" relative flex h-14 w-full items-center rounded-lg border border-border bg-background/60 backdrop-blur sm:px-12"> <div className="absolute left-4 z-10 flex items-center gap-4 transition-transform"> <div className="z-50 block lg:hidden"> <MobileNav /> </div> <Link href={siteUrls.home}> <Icons.logo /> <span className="sr-only">Rapidlaunch logo</span> </Link> </div> <div className="absolute left-0 right-0 mx-auto hidden lg:block "> <WebHeaderNav /> </div> <div className="absolute right-4 flex items-center space-x-2"> <ThemeToggle /> <Suspense fallback={ <Button disabled aria-disabled variant="secondary" className="w-28" > <Icons.loader className="h-4 w-4" /> </Button> } > <HeaderAuth /> </Suspense> </div> </header> </div> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(web)/_components/header.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(web)/_components/header.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 1140 }
11
import { docs } from "@/app/source"; import { createSearchAPI } from "fumadocs-core/search/server"; export const { GET } = createSearchAPI("advanced", { indexes: docs.getPages().map((page) => ({ title: page.data.title, structuredData: page.data.exports.structuredData, id: page.url, url: page.url, })), });
alifarooq9/rapidlaunch/starterkits/saas/src/app/api/(docs)/search/route.ts
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/api/(docs)/search/route.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 140 }
12
import { getOrgByIdQuery } from "@/server/actions/organization/queries"; import { RequestCard } from "@/app/invite/org/[orgId]/_components/request-card"; import { notFound } from "next/navigation"; import { type Metadata } from "next"; export type OrgRequestProps = { params: { orgId: string; }; }; export default async function OrgRequestPage({ params: { orgId }, }: OrgRequestProps) { const org = await getOrgByIdQuery({ orgId }); if (!org) { return notFound(); } return ( <main className="container flex min-h-screen flex-col items-center justify-center"> <RequestCard org={org} orgId={orgId} /> </main> ); } export async function generateMetadata({ params, }: OrgRequestProps): Promise<Metadata> { const org = await getOrgByIdQuery({ orgId: params.orgId }); if (!org) { return notFound(); } return { title: `Invite to ${org.name}`, description: `Invite your team to ${org.name} and get started building your next project.`, }; }
alifarooq9/rapidlaunch/starterkits/saas/src/app/invite/org/[orgId]/page.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/invite/org/[orgId]/page.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 402 }
13
"use client"; import * as React from "react"; import { MoonIcon, SunIcon } from "lucide-react"; import { useTheme } from "next-themes"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; export function ThemeToggle() { const { setTheme, theme, themes } = useTheme(); return ( <DropdownMenu> <DropdownMenuTrigger asChild> <Button variant="outline" size="icon" className="flex-shrink-0"> <SunIcon className="h-[1.2rem] w-[1.2rem] rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" /> <MoonIcon className="absolute h-[1.2rem] w-[1.2rem] rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" /> <span className="sr-only">Toggle theme</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> {themes.map((t) => ( <DropdownMenuCheckboxItem key={t} checked={theme === t} onClick={() => setTheme(t)} className="text-sm capitalize" > {t} </DropdownMenuCheckboxItem> ))} </DropdownMenuContent> </DropdownMenu> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/components/theme-toggle.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/components/theme-toggle.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 745 }
14
/** * This file contains the pricing data for the pricing page. * * @add a new pricing plan, add a new object to the `pricing` array. * 1. Add id to the pricingIds object then use it as the id of the new pricing object. * 2. Add badge(optional), title, description, price, currency, duration, highlight, popular, and uniqueFeatures(optional) to the new pricing object. * 3. if the new pricing plan has unique features, add a new object to the `uniqueFeatures` array. * * @add a new feature, add a new object to the `features` array. * 1. Add id to the features object then use it as the id of the new feature object. * 2. Add title and inludedIn to the new feature object. (inludedIn is an array of pricing plan ids that include this feature) */ export type PrincingPlan = { id: string; badge?: string; title: string; description: string; price: { monthly: number; yearly: number; }; currency: { code: string; symbol: string; }; duration: string; highlight: string; buttonHighlighted: boolean; uniqueFeatures?: string[]; variantId?: { monthly: number; yearly: number; }; }; export type PricingFeature = { id: string; title: string; inludedIn: string[]; }; export const pricingIds = { free: "free", pro: "pro", premium: "premium", } as const; export const pricingFeatures: PricingFeature[] = [ { id: "1", title: "SSO with unlimited social connections and MFA", inludedIn: [pricingIds.free, pricingIds.pro, pricingIds.premium], }, { id: "2", title: "Custom domains", inludedIn: [pricingIds.free, pricingIds.pro, pricingIds.premium], }, { id: "3", title: "Basic role and permission management", inludedIn: [pricingIds.free, pricingIds.pro, pricingIds.premium], }, { id: "4", title: "View and manage users", inludedIn: [pricingIds.free, pricingIds.pro, pricingIds.premium], }, { id: "5", title: "Custom Branding", inludedIn: [pricingIds.pro, pricingIds.premium], }, { id: "7", title: "Rapidlaunch Branding", inludedIn: [pricingIds.pro, pricingIds.premium], }, { id: "8", title: "Custom Branding", inludedIn: [pricingIds.pro, pricingIds.premium], }, { id: "9", title: "Up to 2,000 machine to machine (M2M) connections", inludedIn: [pricingIds.pro, pricingIds.premium], }, { id: "10", title: "Rapidlaunch Branding", inludedIn: [pricingIds.premium], }, { id: "11", title: "Custom Branding", inludedIn: [pricingIds.premium], }, { id: "12", title: "Up to 2,000 machine to machine (M2M) connections", inludedIn: [pricingIds.premium], }, { id: "13", title: "Rapidlaunch Branding", inludedIn: [pricingIds.premium], }, ]; export const pricingPlans: PrincingPlan[] = [ { id: pricingIds.free, title: "Free", description: "Everything you need to get started with 10,500 free MAU. No setup fees, monthly fees, or hidden fees.", price: { monthly: 0, yearly: 0, }, currency: { code: "USD", symbol: "$", }, duration: "Forever", highlight: "No credit card required. 30-day money-back guarantee. No hidden fees.", buttonHighlighted: false, uniqueFeatures: ["Up to 2,000 machine to machine (M2M) connections"], }, { id: pricingIds.pro, badge: "Most Popular", title: "Pro", description: "Advanced features to help you scale any business without limits.", price: { monthly: 99, yearly: 999, }, variantId: { monthly: 362869, yearly: 362870 }, currency: { code: "USD", symbol: "$", }, duration: "per month", highlight: "No credit card required. 30-day money-back guarantee. No hidden fees.", buttonHighlighted: true, uniqueFeatures: ["Up to 5,000 machine to machine (M2M) connections"], }, { id: pricingIds.premium, title: "Premium", description: "For teams with more complex needs requiring the highest levels of support.", price: { monthly: 199, yearly: 1999, }, variantId: { monthly: 362872, yearly: 362874 }, currency: { code: "USD", symbol: "$", }, duration: "per month", highlight: "No credit card required. 30-day money-back guarantee. No hidden fees.", buttonHighlighted: false, uniqueFeatures: ["Up to 100,000 machine to machine (M2M) connections"], }, ];
alifarooq9/rapidlaunch/starterkits/saas/src/config/pricing.ts
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/config/pricing.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 2230 }
15
"use server"; import { db } from "@/server/db"; import { createOrgInsertSchema, membersToOrganizations, membersToOrganizationsInsertSchema, orgRequestInsertSchema, orgRequests, organizations, } from "@/server/db/schema"; import { adminProcedure, protectedProcedure } from "@/server/procedures"; import { and, eq } from "drizzle-orm"; import { getOrganizations } from "@/server/actions/organization/queries"; import { z } from "zod"; /** * Create a new organization mutations * @param name - Name of the organization * @param image - Image URL of the organization * @returns The created organization */ type CreateOrgProps = Omit<typeof organizations.$inferInsert, "id" | "ownerId">; export async function createOrgMutation({ ...props }: CreateOrgProps) { const { user } = await protectedProcedure(); const organizationParse = await createOrgInsertSchema.safeParseAsync({ ownerId: user.id, ...props, }); if (!organizationParse.success) { throw new Error("Invalid organization data", { cause: organizationParse.error.errors, }); } const createOrg = await db .insert(organizations) .values(organizationParse.data) .returning() .execute(); await db.insert(membersToOrganizations).values({ memberId: organizationParse.data.ownerId, memberEmail: user.email!, organizationId: createOrg[0]!.id, role: "Admin", }); return createOrg[0]; } /** * Update the name of the organization * @param name - New name of the organization * @returns The updated organization */ const updateOrgNameSchema = createOrgInsertSchema.pick({ name: true, }); type UpdateOrgNameProps = z.infer<typeof updateOrgNameSchema>; export async function updateOrgNameMutation({ name }: UpdateOrgNameProps) { const { user } = await protectedProcedure(); const { currentOrg } = await getOrganizations(); const organizationNameParse = await updateOrgNameSchema.safeParseAsync({ name, }); if (!organizationNameParse.success) { throw new Error("Invalid organization data", { cause: organizationNameParse.error.errors, }); } const memToOrg = await db.query.membersToOrganizations.findFirst({ where: and( eq(membersToOrganizations.memberId, user.id), eq(membersToOrganizations.organizationId, currentOrg.id), eq(membersToOrganizations.role, "Admin"), ), }); if (currentOrg.ownerId === user.id || memToOrg) { return await db .update(organizations) .set({ name: organizationNameParse.data.name }) .where(eq(organizations.id, currentOrg.id)) .execute(); } throw new Error("You are not an admin of this organization"); } /** * Update the image of the organization * @param image - New image URL of the organization * @returns The updated organization */ const updateOrgImageSchema = createOrgInsertSchema.pick({ image: true, }); type UpdateOrgImageProps = z.infer<typeof updateOrgImageSchema>; export async function updateOrgImageMutation({ image }: UpdateOrgImageProps) { const { user } = await protectedProcedure(); const { currentOrg } = await getOrganizations(); const organizationImageParse = await updateOrgImageSchema.safeParseAsync({ image, }); if (!organizationImageParse.success) { throw new Error("Invalid organization data", { cause: organizationImageParse.error.errors, }); } const memToOrg = await db.query.membersToOrganizations.findFirst({ where: and( eq(membersToOrganizations.memberId, user.id), eq(membersToOrganizations.organizationId, currentOrg.id), eq(membersToOrganizations.role, "Admin"), ), }); if (currentOrg.ownerId === user.id || memToOrg) { return await db .update(organizations) .set({ image: organizationImageParse.data.image }) .where(eq(organizations.id, currentOrg.id)) .execute(); } throw new Error("You are not an admin of this organization"); } /** * Delete the organization * @returns The deleted organization */ export async function deleteOrgMutation() { const { user } = await protectedProcedure(); const { currentOrg } = await getOrganizations(); if (currentOrg.ownerId !== user.id) { throw new Error("You are not the owner of this organization"); } return await db .delete(organizations) .where(eq(organizations.id, currentOrg.id)) .execute(); } export async function deleteOrgAdminMutation({ id }: { id: string }) { await adminProcedure(); return await db .delete(organizations) .where(eq(organizations.id, id)) .execute(); } /** * Send a request to join an organization * @param orgId - ID of the organization */ type OrgRequestProps = { orgId: typeof orgRequestInsertSchema._type.organizationId; }; export async function sendOrgRequestMutation({ orgId }: OrgRequestProps) { const { user } = await protectedProcedure(); const orgRequestParse = await orgRequestInsertSchema.safeParseAsync({ organizationId: orgId, userId: user.id, }); if (!orgRequestParse.success) { throw new Error("Invalid organization data", { cause: orgRequestParse.error.errors, }); } return await db .insert(orgRequests) .values({ organizationId: orgRequestParse.data.organizationId, userId: orgRequestParse.data.userId, }) .onConflictDoNothing({ where: and( eq(orgRequests.organizationId, orgId), eq(orgRequests.userId, user.id), ), }) .execute(); } /** * Accept a request to join an organization * @param requestId - ID of the request */ const acceptOrgRequestSchema = z.object({ requestId: z.string(), }); type AcceptOrgRequestProps = z.infer<typeof acceptOrgRequestSchema>; export async function acceptOrgRequestMutation({ requestId, }: AcceptOrgRequestProps) { const { user } = await protectedProcedure(); const { currentOrg } = await getOrganizations(); const acceptReqParse = await acceptOrgRequestSchema.safeParseAsync({ requestId, }); if (!acceptReqParse.success) { throw new Error("Invalid request data", { cause: acceptReqParse.error.errors, }); } const memToOrg = await db.query.membersToOrganizations.findFirst({ where: and( eq(membersToOrganizations.memberId, user.id), eq(membersToOrganizations.organizationId, currentOrg.id), eq(membersToOrganizations.role, "Admin"), ), }); if (currentOrg.ownerId === user.id || memToOrg) { const request = await db.query.orgRequests.findFirst({ where: eq(orgRequests.id, acceptReqParse.data.requestId), with: { user: true, }, }); if (!request) { throw new Error("Request not found"); } await db.insert(membersToOrganizations).values({ memberId: request.userId, organizationId: currentOrg.id, memberEmail: request.user.email, }); return await db .delete(orgRequests) .where(eq(orgRequests.id, acceptReqParse.data.requestId)) .execute(); } throw new Error("You are not an admin of this organization"); } /** * Decline a request to join an organization * @param requestId - ID of the request */ const declineOrgRequestSchema = z.object({ requestId: z.string(), }); type DeclineOrgRequestProps = z.infer<typeof declineOrgRequestSchema>; export async function declineOrgRequestMutation({ requestId, }: DeclineOrgRequestProps) { const { user } = await protectedProcedure(); const { currentOrg } = await getOrganizations(); const declineReqParse = await declineOrgRequestSchema.safeParseAsync({ requestId, }); if (!declineReqParse.success) { throw new Error("Invalid request data", { cause: declineReqParse.error.errors, }); } const memToOrg = await db.query.membersToOrganizations.findFirst({ where: and( eq(membersToOrganizations.memberId, user.id), eq(membersToOrganizations.organizationId, currentOrg.id), eq(membersToOrganizations.role, "Admin"), ), }); if (currentOrg.ownerId === user.id || memToOrg) { return await db .delete(orgRequests) .where(eq(orgRequests.id, declineReqParse.data.requestId)) .execute(); } throw new Error("You are not an admin of this organization"); } /** * Update Member Role * @param memberId - Member's id which you want to update * @param role - The Role you want to update */ const updateMemberRoleSchema = membersToOrganizationsInsertSchema.pick({ role: true, memberId: true, }); type UpdateMemberRoleProps = z.infer<typeof updateMemberRoleSchema>; export async function updateMemberRoleMutation({ memberId, role, }: UpdateMemberRoleProps) { const { user } = await protectedProcedure(); const { currentOrg } = await getOrganizations(); const updateMemberRoleParse = await updateMemberRoleSchema.safeParseAsync({ memberId, role, }); if (!updateMemberRoleParse.success) { throw new Error("Invalid update member data", { cause: updateMemberRoleParse.error.errors, }); } const memToOrg = await db.query.membersToOrganizations.findFirst({ where: and( eq(membersToOrganizations.memberId, user.id), eq(membersToOrganizations.organizationId, currentOrg.id), eq(membersToOrganizations.role, "Admin"), ), }); if ( updateMemberRoleParse.data.role === "Admin" && currentOrg.ownerId !== user.id ) { throw new Error("You are not the owner of this organization"); } if (currentOrg.ownerId === user.id || memToOrg) { return await db .update(membersToOrganizations) .set({ role: updateMemberRoleParse.data.role }) .where( and( eq( membersToOrganizations.memberId, updateMemberRoleParse.data.memberId, ), eq(membersToOrganizations.organizationId, currentOrg.id), ), ) .execute(); } throw new Error("You are not an admin of this organization"); } /** * Remove User from org * @param userId - the id of user your want to remove */ const removeUserSchema = membersToOrganizationsInsertSchema.pick({ memberId: true, }); type RemoveUserProps = z.infer<typeof removeUserSchema>; export async function removeUserMutation({ memberId }: RemoveUserProps) { const { user } = await protectedProcedure(); const { currentOrg } = await getOrganizations(); const removeUserParse = await removeUserSchema.safeParseAsync({ memberId, }); if (!removeUserParse.success) { throw new Error("Invalid remove user data", { cause: removeUserParse.error.errors, }); } if (currentOrg.ownerId === removeUserParse.data.memberId) { throw new Error("You can't remove the owner of the organization"); } const memToOrg = await db.query.membersToOrganizations.findFirst({ where: and( eq(membersToOrganizations.memberId, user.id), eq(membersToOrganizations.organizationId, currentOrg.id), eq(membersToOrganizations.role, "Admin"), ), }); if (currentOrg.ownerId === user.id || memToOrg) { const result = await db .delete(membersToOrganizations) .where( and( eq( membersToOrganizations.memberId, removeUserParse.data.memberId, ), eq(membersToOrganizations.organizationId, currentOrg.id), ), ) .execute(); return result; } throw new Error("You are not an admin of this organization"); }
alifarooq9/rapidlaunch/starterkits/saas/src/server/actions/organization/mutations.ts
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/server/actions/organization/mutations.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 5000 }
16
import { createUploadthing, type FileRouter } from "uploadthing/next"; import { UploadThingError } from "uploadthing/server"; import { getUser } from "@/server/auth"; import { getOrganizations } from "@/server/actions/organization/queries"; import { db } from "@/server/db"; import { and, eq } from "drizzle-orm"; import { membersToOrganizations } from "@/server/db/schema"; /** * File router for the application * learn more about uploadthing here: @see https://docs.uploadthing.com/getting-started/appdir */ const f = createUploadthing(); export const ourFileRouter = { profilePicture: f({ image: { maxFileSize: "4MB" } }) .middleware(async () => { const user = await getUser(); if (!user) throw new UploadThingError("Unauthorized"); return { userId: user.id }; }) .onUploadComplete(async ({ metadata, file }) => { return { uploadedBy: metadata.userId, url: file.url }; }), orgProfilePicture: f({ image: { maxFileSize: "4MB" } }) .middleware(async () => { const user = await getUser(); if (!user) throw new UploadThingError("Unauthorized"); const { currentOrg } = await getOrganizations(); if (!currentOrg) throw new UploadThingError({ message: "You are not a member of any organization", code: "BAD_REQUEST", }); const memToOrg = await db.query.membersToOrganizations.findFirst({ where: and( eq(membersToOrganizations.memberId, user.id), eq(membersToOrganizations.organizationId, currentOrg.id), eq(membersToOrganizations.role, "Admin"), ), }); if (currentOrg.ownerId === user.id || memToOrg) { return { orgId: currentOrg.id, userId: user.id }; } throw new UploadThingError({ message: "You are not an admin of this organization", code: "BAD_REQUEST", }); }) .onUploadError((error) => { return error.error; }) .onUploadComplete(async ({ metadata, file }) => { return { uploadedBy: metadata.userId, url: file.url, orgId: metadata.orgId, }; }), } satisfies FileRouter; export type OurFileRouter = typeof ourFileRouter;
alifarooq9/rapidlaunch/starterkits/saas/src/server/uploadthing/core.ts
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/server/uploadthing/core.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 1118 }
17
import Stripe from 'stripe'; import { stripe } from '@/utils/stripe/config'; import { upsertProductRecord, upsertPriceRecord, manageSubscriptionStatusChange } from '@/utils/supabase-admin'; import { headers } from 'next/headers'; const relevantEvents = new Set([ 'product.created', 'product.updated', 'price.created', 'price.updated', 'checkout.session.completed', 'customer.subscription.created', 'customer.subscription.updated', 'customer.subscription.deleted' ]); export async function POST(req: Request) { const body = await req.text(); const sig = headers().get('Stripe-Signature') as string; const webhookSecret = process.env.STRIPE_WEBHOOK_SECRET; let event: Stripe.Event; try { if (!sig || !webhookSecret) return; event = stripe.webhooks.constructEvent(body, sig, webhookSecret); } catch (err) { console.log(` Error message: ${err.message}`); return new Response(`Webhook Error: ${err.message}`, { status: 400 }); } if (relevantEvents.has(event.type)) { try { switch (event.type) { case 'product.created': case 'product.updated': await upsertProductRecord(event.data.object as Stripe.Product); break; case 'price.created': case 'price.updated': await upsertPriceRecord(event.data.object as Stripe.Price); break; case 'customer.subscription.created': case 'customer.subscription.updated': case 'customer.subscription.deleted': const subscription = event.data.object as Stripe.Subscription; await manageSubscriptionStatusChange( subscription.id, subscription.customer as string, event.type === 'customer.subscription.created' ); break; case 'checkout.session.completed': const checkoutSession = event.data.object as Stripe.Checkout.Session; if (checkoutSession.mode === 'subscription') { const subscriptionId = checkoutSession.subscription; await manageSubscriptionStatusChange( subscriptionId as string, checkoutSession.customer as string, true ); } break; default: throw new Error('Unhandled relevant event!'); } } catch (error) { console.log(error); return new Response( 'Webhook handler failed. View your nextjs function logs.', { status: 400 } ); } } return new Response(JSON.stringify({ received: true })); }
horizon-ui/shadcn-nextjs-boilerplate/app/api/webhooks/route.ts
{ "file_path": "horizon-ui/shadcn-nextjs-boilerplate/app/api/webhooks/route.ts", "repo_id": "horizon-ui/shadcn-nextjs-boilerplate", "token_count": 1032 }
18
import { Card } from '@/components/ui/card'; import ReactMarkdown from 'react-markdown'; export default function MessageBox(props: { output: string }) { const { output } = props; return ( <Card className={`${ output ? 'flex' : 'hidden' } !max-h-max bg-zinc-950 p-5 !px-[22px] !py-[22px] text-base font-normal leading-6 text-white backdrop-blur-xl dark:border-zinc-800 dark:!bg-white/5 dark:text-white md:text-base md:leading-[26px]`} > <ReactMarkdown className="text-base font-normal"> {output ? output : ''} </ReactMarkdown> </Card> ); }
horizon-ui/shadcn-nextjs-boilerplate/components/MessageBoxChat.tsx
{ "file_path": "horizon-ui/shadcn-nextjs-boilerplate/components/MessageBoxChat.tsx", "repo_id": "horizon-ui/shadcn-nextjs-boilerplate", "token_count": 246 }
19
/*eslint-disable*/ 'use client'; import MainChart from '@/components/dashboard/main/cards/MainChart'; import MainDashboardTable from '@/components/dashboard/main/cards/MainDashboardTable'; import DashboardLayout from '@/components/layout'; import tableDataUserReports from '@/variables/tableDataUserReports'; import { User } from '@supabase/supabase-js'; interface Props { user: User | null | undefined; userDetails: { [x: string]: any } | null | any; } export default function Settings(props: Props) { return ( <DashboardLayout user={props.user} userDetails={props.userDetails} title="Subscription Page" description="Manage your subscriptions" > <div className="h-full w-full"> <div className="mb-5 flex gap-5 flex-col xl:flex-row w-full"> <MainChart /> </div> {/* Conversion and talbes*/} <div className="h-full w-full rounded-lg "> <MainDashboardTable tableData={tableDataUserReports} /> </div> </div> </DashboardLayout> ); }
horizon-ui/shadcn-nextjs-boilerplate/components/dashboard/main/index.tsx
{ "file_path": "horizon-ui/shadcn-nextjs-boilerplate/components/dashboard/main/index.tsx", "repo_id": "horizon-ui/shadcn-nextjs-boilerplate", "token_count": 402 }
20
'use client'; import { Button } from '@/components/ui/button'; import SidebarImage from '@/public/SidebarBadge.png'; import Image from 'next/image'; export default function SidebarDocs() { return ( <div className="relative flex flex-col items-center rounded-lg border border-zinc-200 px-3 py-4 dark:border-white/10"> <Image width="54" height="30" className="w-[54px]" src={SidebarImage.src} alt="" /> <div className="mb-3 flex w-full flex-col pt-4"> <p className="mb-2.5 text-center text-lg font-bold text-zinc-950 dark:text-white"> Go unlimited with PRO </p> <p className="text-center text-sm font-medium text-zinc-500 dark:text-zinc-400 focus:dark:!bg-white/20 active:dark:!bg-white/20"> Get your AI Saas Project to another level and start doing more with Horizon AI Boilerplate PRO! </p> </div>{' '} <a target="_blank" href="https://horizon-ui.com/boilerplate-shadcn#pricing" > <Button className="mt-auto flex h-full w-[200px] items-center justify-center rounded-lg px-4 py-2.5 text-sm font-medium"> Get started with PRO </Button> </a> </div> ); }
horizon-ui/shadcn-nextjs-boilerplate/components/sidebar/components/SidebarCard.tsx
{ "file_path": "horizon-ui/shadcn-nextjs-boilerplate/components/sidebar/components/SidebarCard.tsx", "repo_id": "horizon-ui/shadcn-nextjs-boilerplate", "token_count": 555 }
21
/** * USERS * Note: This table contains user data. Users should only be able to view and update their own data. */ create table users ( -- UUID from auth.users id uuid references auth.users not null primary key, full_name text, avatar_url text, credits bigint DEFAULT 0, trial_credits bigint DEFAULT 3, -- The customer's billing address, stored in JSON format. billing_address jsonb, -- Stores your customer's payment instruments. payment_method jsonb ); alter table users enable row level security; create policy "Can view own user data." on users for select using (auth.uid() = id); create policy "Can update own user data." on users for update using (auth.uid() = id); /** * This trigger automatically creates a user entry when a new user signs up via Supabase Auth. */ create function public.handle_new_user() returns trigger as $$ begin insert into public.users (id, full_name, avatar_url) values (new.id, new.raw_user_meta_data->>'full_name', new.raw_user_meta_data->>'avatar_url'); return new; end; $$ language plpgsql security definer; create trigger on_auth_user_created after insert on auth.users for each row execute procedure public.handle_new_user(); /** * CUSTOMERS * Note: this is a private table that contains a mapping of user IDs to Stripe customer IDs. */ create table customers ( -- UUID from auth.users id uuid references auth.users not null primary key, -- The user's customer ID in Stripe. User must not be able to update this. stripe_customer_id text ); alter table customers enable row level security; -- No policies as this is a private table that the user must not have access to. /** * PRODUCTS * Note: products are created and managed in Stripe and synced to our DB via Stripe webhooks. */ create table products ( -- Product ID from Stripe, e.g. prod_1234. id text primary key, -- Whether the product is currently available for purchase. active boolean, -- The product's name, meant to be displayable to the customer. Whenever this product is sold via a subscription, name will show up on associated invoice line item descriptions. name text, -- The product's description, meant to be displayable to the customer. Use this field to optionally store a long form explanation of the product being sold for your own rendering purposes. description text, -- A URL of the product image in Stripe, meant to be displayable to the customer. image text, -- Set of key-value pairs, used to store additional information about the object in a structured format. metadata jsonb ); alter table products enable row level security; create policy "Allow public read-only access." on products for select using (true); /** * PRICES * Note: prices are created and managed in Stripe and synced to our DB via Stripe webhooks. */ create type pricing_type as enum ('one_time', 'recurring'); create type pricing_plan_interval as enum ('day', 'week', 'month', 'year'); create table prices ( -- Price ID from Stripe, e.g. price_1234. id text primary key, -- The ID of the prduct that this price belongs to. product_id text references products, -- Whether the price can be used for new purchases. active boolean, -- A brief description of the price. description text, -- The unit amount as a positive integer in the smallest currency unit (e.g., 100 cents for US$1.00 or 100 for 100, a zero-decimal currency). unit_amount bigint, -- Three-letter ISO currency code, in lowercase. currency text check (char_length(currency) = 3), -- One of `one_time` or `recurring` depending on whether the price is for a one-time purchase or a recurring (subscription) purchase. type pricing_type, -- The frequency at which a subscription is billed. One of `day`, `week`, `month` or `year`. interval pricing_plan_interval, -- The number of intervals (specified in the `interval` attribute) between subscription billings. For example, `interval=month` and `interval_count=3` bills every 3 months. interval_count integer, -- Default number of trial days when subscribing a customer to this price using [`trial_from_plan=true`](https://stripe.com/docs/api#create_subscription-trial_from_plan). trial_period_days integer, -- Set of key-value pairs, used to store additional information about the object in a structured format. metadata jsonb ); alter table prices enable row level security; create policy "Allow public read-only access." on prices for select using (true); /** * SUBSCRIPTIONS * Note: subscriptions are created and managed in Stripe and synced to our DB via Stripe webhooks. */ create type subscription_status as enum ('trialing', 'active', 'canceled', 'incomplete', 'incomplete_expired', 'past_due', 'unpaid', 'paused'); create table subscriptions ( -- Subscription ID from Stripe, e.g. sub_1234. id text primary key, user_id uuid references auth.users not null, -- The status of the subscription object, one of subscription_status type above. status subscription_status, -- Set of key-value pairs, used to store additional information about the object in a structured format. metadata jsonb, -- ID of the price that created this subscription. price_id text references prices, -- Quantity multiplied by the unit amount of the price creates the amount of the subscription. Can be used to charge multiple seats. quantity integer, -- If true the subscription has been canceled by the user and will be deleted at the end of the billing period. cancel_at_period_end boolean, -- Time at which the subscription was created. created timestamp with time zone default timezone('utc'::text, now()) not null, -- Start of the current period that the subscription has been invoiced for. current_period_start timestamp with time zone default timezone('utc'::text, now()) not null, -- End of the current period that the subscription has been invoiced for. At the end of this period, a new invoice will be created. current_period_end timestamp with time zone default timezone('utc'::text, now()) not null, -- If the subscription has ended, the timestamp of the date the subscription ended. ended_at timestamp with time zone default timezone('utc'::text, now()), -- A date in the future at which the subscription will automatically get canceled. cancel_at timestamp with time zone default timezone('utc'::text, now()), -- If the subscription has been canceled, the date of that cancellation. If the subscription was canceled with `cancel_at_period_end`, `canceled_at` will still reflect the date of the initial cancellation request, not the end of the subscription period when the subscription is automatically moved to a canceled state. canceled_at timestamp with time zone default timezone('utc'::text, now()), -- If the subscription has a trial, the beginning of that trial. trial_start timestamp with time zone default timezone('utc'::text, now()), -- If the subscription has a trial, the end of that trial. trial_end timestamp with time zone default timezone('utc'::text, now()) ); alter table subscriptions enable row level security; create policy "Can only view own subs data." on subscriptions for select using (auth.uid() = user_id); -- create policy "Allow subscriber to update credits" on subscriptions for update using (auth.uid() = id) with check ( exists ( -- SELECT 1 FROM subscriptions -- WHERE subscriptions.user_id = users.id -- AND subscriptions.status = 'active' ) -- ); /** * REALTIME SUBSCRIPTIONS * Only allow realtime listening on public tables. */ drop publication if exists supabase_realtime; create publication supabase_realtime for table products, prices;
horizon-ui/shadcn-nextjs-boilerplate/schema.sql
{ "file_path": "horizon-ui/shadcn-nextjs-boilerplate/schema.sql", "repo_id": "horizon-ui/shadcn-nextjs-boilerplate", "token_count": 2020 }
22
import { NextRequest, NextResponse } from 'next/server'; import { parse, serialize } from 'cookie'; // Function to parse cookies from the request export function parseCookies(req: NextRequest) { const cookieHeader = req.headers.get('cookie'); return cookieHeader ? parse(cookieHeader) : {}; } // Function to set cookies in the response export function setCookie( res: NextResponse, name: string, value: any, options: any = {} ) { const stringValue = typeof value === 'object' ? 'j:' + JSON.stringify(value) : String(value); if (options.maxAge) { options.expires = new Date(Date.now() + options.maxAge * 1000); } res.cookies.set(name, stringValue, options); } // Function to get a specific cookie export function getCookie(req: NextRequest, name: string) { const cookies = parseCookies(req); const value = cookies[name]; if (value && value.startsWith('j:')) { try { return JSON.parse(value.slice(2)); } catch (e) { return null; } } return value; }
horizon-ui/shadcn-nextjs-boilerplate/utils/cookies.ts
{ "file_path": "horizon-ui/shadcn-nextjs-boilerplate/utils/cookies.ts", "repo_id": "horizon-ui/shadcn-nextjs-boilerplate", "token_count": 334 }
23
# FIXME: Configure environment variables for your project # Clerk authentication NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_b3Blbi1zdGlua2J1Zy04LmNsZXJrLmFjY291bnRzLmRldiQ NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in # Stripe # If you need a real Stripe subscription payment with checkout page, customer portal, webhook, etc. # You can check out the Next.js Boilerplate Pro at: https://nextjs-boilerplate.com/pro-saas-starter-kit NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_51PNk4fKOp3DEwzQle6Cx1j3IW1Lze5nFKZ4JBX0gLpNQ3hjFbMiT25gw7LEr369ge7JIsVA2qRhdKQm1NAmVehXl00FQxwRfh1 # Use Stripe test mode price id or production price id BILLING_PLAN_ENV=dev ######## [BEGIN] SENSITIVE DATA ######## For security reason, don't update the following variables (secret key) directly in this file. ######## Please create a new file named `.env.local`, all environment files ending with `.local` won't be tracked by Git. ######## After creating the file, you can add the following variables. # Clerk authentication CLERK_SECRET_KEY=your_clerk_secret_key # Stripe STRIPE_SECRET_KEY=your_stripe_secret_key STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret ######## [END] SENSITIVE DATA
ixartz/SaaS-Boilerplate/.env
{ "file_path": "ixartz/SaaS-Boilerplate/.env", "repo_id": "ixartz/SaaS-Boilerplate", "token_count": 438 }
24
import { OrganizationList } from '@clerk/nextjs'; import { getTranslations } from 'next-intl/server'; export async function generateMetadata(props: { params: { locale: string } }) { const t = await getTranslations({ locale: props.params.locale, namespace: 'Dashboard', }); return { title: t('meta_title'), description: t('meta_description'), }; } const OrganizationSelectionPage = () => ( <div className="flex min-h-screen items-center justify-center"> <OrganizationList afterSelectOrganizationUrl="/dashboard" afterCreateOrganizationUrl="/dashboard" hidePersonal skipInvitationScreen /> </div> ); export const dynamic = 'force-dynamic'; export default OrganizationSelectionPage;
ixartz/SaaS-Boilerplate/src/app/[locale]/(auth)/onboarding/organization-selection/page.tsx
{ "file_path": "ixartz/SaaS-Boilerplate/src/app/[locale]/(auth)/onboarding/organization-selection/page.tsx", "repo_id": "ixartz/SaaS-Boilerplate", "token_count": 242 }
25
import { Slot } from '@radix-ui/react-slot'; import type { VariantProps } from 'class-variance-authority'; import * as React from 'react'; import { cn } from '@/utils/Helpers'; import { buttonVariants } from './buttonVariants'; export type ButtonProps = { asChild?: boolean; } & React.ButtonHTMLAttributes<HTMLButtonElement> & VariantProps<typeof buttonVariants>; const Button = React.forwardRef<HTMLButtonElement, ButtonProps>( ({ className, variant, size, asChild = false, ...props }, ref) => { const Comp = asChild ? Slot : 'button'; return ( <Comp className={cn(buttonVariants({ variant, size, className }))} ref={ref} {...props} /> ); }, ); Button.displayName = 'Button'; export { Button };
ixartz/SaaS-Boilerplate/src/components/ui/button.tsx
{ "file_path": "ixartz/SaaS-Boilerplate/src/components/ui/button.tsx", "repo_id": "ixartz/SaaS-Boilerplate", "token_count": 269 }
26
import React from 'react'; export const MessageState = (props: { icon: React.ReactNode; title: React.ReactNode; description: React.ReactNode; button: React.ReactNode; }) => ( <div className="flex h-[600px] flex-col items-center justify-center rounded-md bg-card p-5"> <div className="size-16 rounded-full bg-muted p-3 [&_svg]:stroke-muted-foreground [&_svg]:stroke-2"> {props.icon} </div> <div className="mt-3 text-center"> <div className="text-xl font-semibold">{props.title}</div> <div className="mt-1 text-sm font-medium text-muted-foreground"> {props.description} </div> <div className="mt-5">{props.button}</div> </div> </div> );
ixartz/SaaS-Boilerplate/src/features/dashboard/MessageState.tsx
{ "file_path": "ixartz/SaaS-Boilerplate/src/features/dashboard/MessageState.tsx", "repo_id": "ixartz/SaaS-Boilerplate", "token_count": 294 }
27
import logtail from '@logtail/pino'; import pino, { type DestinationStream } from 'pino'; import pretty from 'pino-pretty'; import { Env } from './Env'; let stream: DestinationStream; if (Env.LOGTAIL_SOURCE_TOKEN) { stream = pino.multistream([ await logtail({ sourceToken: Env.LOGTAIL_SOURCE_TOKEN, options: { sendLogsToBetterStack: true, }, }), { stream: pretty(), // Prints logs to the console }, ]); } else { stream = pretty({ colorize: true, }); } export const logger = pino({ base: undefined }, stream);
ixartz/SaaS-Boilerplate/src/libs/Logger.ts
{ "file_path": "ixartz/SaaS-Boilerplate/src/libs/Logger.ts", "repo_id": "ixartz/SaaS-Boilerplate", "token_count": 225 }
28
import Link from 'next/link'; import { useTranslations } from 'next-intl'; import { buttonVariants } from '@/components/ui/buttonVariants'; import { PricingInformation } from '@/features/billing/PricingInformation'; import { Section } from '@/features/landing/Section'; import { PLAN_ID } from '@/utils/AppConfig'; export const Pricing = () => { const t = useTranslations('Pricing'); return ( <Section subtitle={t('section_subtitle')} title={t('section_title')} description={t('section_description')} > <PricingInformation buttonList={{ [PLAN_ID.FREE]: ( <Link className={buttonVariants({ size: 'sm', className: 'mt-5 w-full', })} href="/sign-up" > {t('button_text')} </Link> ), [PLAN_ID.PREMIUM]: ( <Link className={buttonVariants({ size: 'sm', className: 'mt-5 w-full', })} href="/sign-up" > {t('button_text')} </Link> ), [PLAN_ID.ENTERPRISE]: ( <Link className={buttonVariants({ size: 'sm', className: 'mt-5 w-full', })} href="/sign-up" > {t('button_text')} </Link> ), }} /> </Section> ); };
ixartz/SaaS-Boilerplate/src/templates/Pricing.tsx
{ "file_path": "ixartz/SaaS-Boilerplate/src/templates/Pricing.tsx", "repo_id": "ixartz/SaaS-Boilerplate", "token_count": 832 }
29
import react from '@vitejs/plugin-react'; import { loadEnv } from 'vite'; import tsconfigPaths from 'vite-tsconfig-paths'; import { defineConfig } from 'vitest/config'; export default defineConfig({ plugins: [react(), tsconfigPaths()], test: { globals: true, // This is needed by @testing-library to be cleaned up after each test include: ['src/**/*.test.{js,jsx,ts,tsx}'], coverage: { include: ['src/**/*'], exclude: ['src/**/*.stories.{js,jsx,ts,tsx}', '**/*.d.ts'], }, environmentMatchGlobs: [ ['**/*.test.tsx', 'jsdom'], ['src/hooks/**/*.test.ts', 'jsdom'], ], setupFiles: ['./vitest-setup.ts'], env: loadEnv('', process.cwd(), ''), }, });
ixartz/SaaS-Boilerplate/vitest.config.mts
{ "file_path": "ixartz/SaaS-Boilerplate/vitest.config.mts", "repo_id": "ixartz/SaaS-Boilerplate", "token_count": 295 }
30
import iconMetaData from '../../data/iconMetaData'; export default eventHandler((event) => { setResponseHeader(event, 'Cache-Control', 'public, max-age=86400'); setResponseHeader(event, 'Access-Control-Allow-Origin', '*'); return Object.fromEntries(Object.entries(iconMetaData).map(([name, { tags }]) => [name, tags])); });
lucide-icons/lucide/docs/.vitepress/api/tags/index.get.ts
{ "file_path": "lucide-icons/lucide/docs/.vitepress/api/tags/index.get.ts", "repo_id": "lucide-icons/lucide", "token_count": 105 }
31
import { bundledLanguages, type ThemeRegistration } from 'shikiji'; import { getHighlighter } from 'shikiji'; type CodeExampleType = { title: string; language: string; code: string; }[]; const getIconCodes = (): CodeExampleType => { return [ { language: 'js', title: 'Vanilla', code: `\ import { createIcons, icons } from 'lucide'; import { $CamelCase } from '@lucide/lab'; createIcons({ icons: { $CamelCase } }); document.body.append('<i data-lucide="$Name"></i>');\ `, }, { language: 'tsx', title: 'React', code: `import { Icon } from 'lucide-react'; import { $CamelCase } from '@lucide/lab'; const App = () => { return ( <Icon iconNode={$CamelCase} /> ); }; export default App; `, }, { language: 'vue', title: 'Vue', code: `<script setup> import { Icon } from 'lucide-vue-next'; import { $CamelCase } from '@lucide/lab'; </script> <template> <Icon :iconNode="burger" /> </template> `, }, { language: 'svelte', title: 'Svelte', code: `<script> import { Icon } from 'lucide-svelte'; import { $CamelCase } from '@lucide/lab'; </script> <Icon iconNode={burger} /> `, }, { language: 'tsx', title: 'Preact', code: `import { Icon } from 'lucide-preact'; import { $CamelCase } from '@lucide/lab'; const App = () => { return ( <Icon iconNode={$CamelCase} /> ); }; export default App; `, }, { language: 'tsx', title: 'Solid', code: `import { Icon } from 'lucide-solid'; import { $CamelCase } from '@lucide/lab'; const App = () => { return ( <Icon iconNode={$CamelCase} /> ); }; export default App; `, }, { language: 'tsx', title: 'Angular', code: `// app.module.ts import { LucideAngularModule } from 'lucide-angular'; import { $CamelCase } from '@lucide/lab'; @NgModule({ imports: [ LucideAngularModule.pick({ $CamelCase }) ], }) // app.component.html <lucide-icon name="$CamelCase"></lucide-icon> `, }, ]; }; export type ThemeOptions = | ThemeRegistration | { light: ThemeRegistration; dark: ThemeRegistration }; const highLightCode = async (code: string, lang: string, active?: boolean) => { const highlighter = await getHighlighter({ themes: ['github-light', 'github-dark'], langs: Object.keys(bundledLanguages), }); const highlightedCode = highlighter .codeToHtml(code, { lang, themes: { light: 'github-light', dark: 'github-dark', }, defaultColor: false, }) .replace('shiki-themes', 'shiki-themes vp-code'); return `<div class="language-${lang} ${active ? 'active' : ''}"> <button title="Copy Code" class="copy"></button> <span class="lang">${lang}</span> ${highlightedCode} </div>`; }; export default async function createCodeExamples() { const codes = getIconCodes(); const codeExamplePromises = codes.map(async ({ title, language, code }, index) => { const isFirst = index === 0; const codeString = await highLightCode(code, language, isFirst); return { title, language: language, code: codeString, }; }); return Promise.all(codeExamplePromises); }
lucide-icons/lucide/docs/.vitepress/lib/codeExamples/createLabCodeExamples.ts
{ "file_path": "lucide-icons/lucide/docs/.vitepress/lib/codeExamples/createLabCodeExamples.ts", "repo_id": "lucide-icons/lucide", "token_count": 1317 }
32
import { useFetch } from '@vueuse/core'; const useFetchTags = () => useFetch<Record<string, string[]>>( `${import.meta.env.DEV ? 'http://localhost:3000' : ''}/api/tags`, { immediate: typeof window !== 'undefined' && new URLSearchParams(window.location.search).has('search'), }, ).json(); export default useFetchTags;
lucide-icons/lucide/docs/.vitepress/theme/composables/useFetchTags.ts
{ "file_path": "lucide-icons/lucide/docs/.vitepress/theme/composables/useFetchTags.ts", "repo_id": "lucide-icons/lucide", "token_count": 136 }
33
import { FolderLock } from "lucide-react"; function App() { return ( <div className="app"> <FolderLock strokeWidth={1} /> </div> ); } export default App;
lucide-icons/lucide/docs/guide/basics/examples/stroke-width-icon/App.js
{ "file_path": "lucide-icons/lucide/docs/guide/basics/examples/stroke-width-icon/App.js", "repo_id": "lucide-icons/lucide", "token_count": 67 }
34
import { IconEntity } from '../../.vitepress/theme/types'; export default { paths: async () => { const iconDetailsResponse = await fetch('https://lab.lucide.dev/api/icon-details'); const iconDetails = (await iconDetailsResponse.json()) as Record<string, IconEntity>; return Object.values(iconDetails).map((iconEntity) => { const params = { externalLibrary: 'lab', ...iconEntity, }; return { params, }; }); }, };
lucide-icons/lucide/docs/icons/lab/[name].paths.ts
{ "file_path": "lucide-icons/lucide/docs/icons/lab/[name].paths.ts", "repo_id": "lucide-icons/lucide", "token_count": 184 }
35
<svg width="32" height="30" viewBox="0 0 32 30" fill="none" xmlns="http://www.w3.org/2000/svg"> <g clip-path="url(#a)"> <path d="M31.42 6.75S21.2-.77 13.3.96l-.58.2a5.48 5.48 0 0 0-2.7 1.73l-.38.58-2.9 5.01 5.02.97c2.12 1.35 4.82 1.92 7.32 1.35l8.87 1.73 3.47-5.78Z" fill="#76B3E1"/> <path opacity=".3" d="M31.42 6.75S21.2-.77 13.3.96l-.58.2a5.48 5.48 0 0 0-2.7 1.73l-.38.58-2.9 5.01 5.02.97c2.12 1.35 4.82 1.92 7.32 1.35l8.87 1.73 3.47-5.78Z" fill="url(#b)"/> <path d="m10.02 6.75-.77.19c-3.27.96-4.24 4.05-2.5 6.75 1.92 2.5 5.97 3.85 9.25 2.89l11.95-4.05S17.73 5.01 10.02 6.75Z" fill="#518AC8"/> <path opacity=".3" d="m10.02 6.75-.77.19c-3.27.96-4.24 4.05-2.5 6.75 1.92 2.5 5.97 3.85 9.25 2.89l11.95-4.05S17.73 5.01 10.02 6.75Z" fill="url(#c)"/> <path d="M25.83 15.42a8.67 8.67 0 0 0-9.25-2.89L4.63 16.39.77 23.13l21.6 3.67 3.85-6.94c.77-1.35.58-2.9-.39-4.44Z" fill="url(#d)"/> <path d="M21.98 22.17a8.67 8.67 0 0 0-9.26-2.9L.77 23.14S11 30.84 18.9 28.92l.58-.2c3.28-.96 4.43-4.05 2.5-6.55Z" fill="url(#e)"/> </g> <defs> <linearGradient id="b" x1="5.3" y1=".58" x2="29.3" y2="12.24" gradientUnits="userSpaceOnUse"> <stop offset=".1" stop-color="#76B3E1"/> <stop offset=".3" stop-color="#DCF2FD"/> <stop offset="1" stop-color="#76B3E1"/> </linearGradient> <linearGradient id="c" x1="18.47" y1="6.28" x2="14.27" y2="20.28" gradientUnits="userSpaceOnUse"> <stop stop-color="#76B3E1"/> <stop offset=".5" stop-color="#4377BB"/> <stop offset="1" stop-color="#1F3B77"/> </linearGradient> <linearGradient id="d" x1="3.55" y1="12.38" x2="27.82" y2="28.88" gradientUnits="userSpaceOnUse"> <stop stop-color="#315AA9"/> <stop offset=".5" stop-color="#518AC8"/> <stop offset="1" stop-color="#315AA9"/> </linearGradient> <linearGradient id="e" x1="14.5" y1="14.36" x2="4.7" y2="50.27" gradientUnits="userSpaceOnUse"> <stop stop-color="#4377BB"/> <stop offset=".5" stop-color="#1A336B"/> <stop offset="1" stop-color="#1A336B"/> </linearGradient> <clipPath id="a"> <path fill="#fff" d="M0 0h32v29.94H0z"/> </clipPath> </defs> </svg>
lucide-icons/lucide/docs/public/framework-logos/solid.svg
{ "file_path": "lucide-icons/lucide/docs/public/framework-logos/solid.svg", "repo_id": "lucide-icons/lucide", "token_count": 1173 }
36
import fs from 'fs'; import path from 'path'; import { readSvgDirectory, toCamelCase } from '@lucide/helpers'; const currentDir = process.cwd(); const ICONS_DIR = path.resolve(currentDir, '../icons'); const iconJsonFiles = readSvgDirectory(ICONS_DIR, '.json'); const location = path.resolve(currentDir, '.vitepress/data', 'iconMetaData.ts'); if (fs.existsSync(location)) { fs.unlinkSync(location); } const iconMetaIndexFileImports = []; const iconMetaIndexFileExports = []; iconJsonFiles.forEach((iconJsonFile) => { const iconName = path.basename(iconJsonFile, '.json'); iconMetaIndexFileImports.push( `import ${toCamelCase(iconName)}Metadata from '../../../icons/${iconName}.json';`, ); iconMetaIndexFileExports.push(` '${iconName}': ${toCamelCase(iconName)}Metadata,`); }); try { await fs.promises.writeFile( location, `\ ${iconMetaIndexFileImports.join('\n')} export default { ${iconMetaIndexFileExports.join('\n')} } `, 'utf-8', ); console.log('Successfully write icon json file index'); } catch (error) { throw new Error(`Something went wrong generating icon json file index file,\n ${error}`); }
lucide-icons/lucide/docs/scripts/writeIconMetaIndex.mjs
{ "file_path": "lucide-icons/lucide/docs/scripts/writeIconMetaIndex.mjs", "repo_id": "lucide-icons/lucide", "token_count": 409 }
37
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <circle cx="12" cy="13" r="8" /> <path d="M12 9v4l2 2" /> <path d="M5 3 2 6" /> <path d="m22 6-3-3" /> <path d="M6.38 18.7 4 21" /> <path d="M17.64 18.67 20 21" /> </svg>
lucide-icons/lucide/icons/alarm-clock.svg
{ "file_path": "lucide-icons/lucide/icons/alarm-clock.svg", "repo_id": "lucide-icons/lucide", "token_count": 186 }
38
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M10 2v5.632c0 .424-.272.795-.653.982A6 6 0 0 0 6 14c.006 4 3 7 5 8" /> <path d="M10 5H8a2 2 0 0 0 0 4h.68" /> <path d="M14 2v5.632c0 .424.272.795.652.982A6 6 0 0 1 18 14c0 4-3 7-5 8" /> <path d="M14 5h2a2 2 0 0 1 0 4h-.68" /> <path d="M18 22H6" /> <path d="M9 2h6" /> </svg>
lucide-icons/lucide/icons/amphora.svg
{ "file_path": "lucide-icons/lucide/icons/amphora.svg", "repo_id": "lucide-icons/lucide", "token_count": 256 }
39
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M3.85 8.62a4 4 0 0 1 4.78-4.77 4 4 0 0 1 6.74 0 4 4 0 0 1 4.78 4.78 4 4 0 0 1 0 6.74 4 4 0 0 1-4.77 4.78 4 4 0 0 1-6.75 0 4 4 0 0 1-4.78-4.77 4 4 0 0 1 0-6.76Z" /> <path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" /> <line x1="12" x2="12.01" y1="17" y2="17" /> </svg>
lucide-icons/lucide/icons/badge-help.svg
{ "file_path": "lucide-icons/lucide/icons/badge-help.svg", "repo_id": "lucide-icons/lucide", "token_count": 253 }
40
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <rect x="14" y="14" width="4" height="6" rx="2" /> <rect x="6" y="4" width="4" height="6" rx="2" /> <path d="M6 20h4" /> <path d="M14 10h4" /> <path d="M6 14h2v6" /> <path d="M14 4h2v6" /> </svg>
lucide-icons/lucide/icons/binary.svg
{ "file_path": "lucide-icons/lucide/icons/binary.svg", "repo_id": "lucide-icons/lucide", "token_count": 199 }
41
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m7 7 10 10-5 5V2l5 5L7 17" /> <line x1="18" x2="21" y1="12" y2="12" /> <line x1="3" x2="6" y1="12" y2="12" /> </svg>
lucide-icons/lucide/icons/bluetooth-connected.svg
{ "file_path": "lucide-icons/lucide/icons/bluetooth-connected.svg", "repo_id": "lucide-icons/lucide", "token_count": 165 }
42
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M12 8V4H8" /> <rect width="16" height="12" x="4" y="8" rx="2" /> <path d="M2 14h2" /> <path d="M20 14h2" /> <path d="M15 13v2" /> <path d="M9 13v2" /> </svg>
lucide-icons/lucide/icons/bot.svg
{ "file_path": "lucide-icons/lucide/icons/bot.svg", "repo_id": "lucide-icons/lucide", "token_count": 184 }
43
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M12.765 21.522a.5.5 0 0 1-.765-.424v-8.196a.5.5 0 0 1 .765-.424l5.878 3.674a1 1 0 0 1 0 1.696z" /> <path d="M14.12 3.88 16 2" /> <path d="M18 11a4 4 0 0 0-4-4h-4a4 4 0 0 0-4 4v3a6.1 6.1 0 0 0 2 4.5" /> <path d="M20.97 5c0 2.1-1.6 3.8-3.5 4" /> <path d="M3 21c0-2.1 1.7-3.9 3.8-4" /> <path d="M6 13H2" /> <path d="M6.53 9C4.6 8.8 3 7.1 3 5" /> <path d="m8 2 1.88 1.88" /> <path d="M9 7.13v-1a3.003 3.003 0 1 1 6 0v1" /> </svg>
lucide-icons/lucide/icons/bug-play.svg
{ "file_path": "lucide-icons/lucide/icons/bug-play.svg", "repo_id": "lucide-icons/lucide", "token_count": 365 }
44
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M19 17h2c.6 0 1-.4 1-1v-3c0-.9-.7-1.7-1.5-1.9C18.7 10.6 16 10 16 10s-1.3-1.4-2.2-2.3c-.5-.4-1.1-.7-1.8-.7H5c-.6 0-1.1.4-1.4.9l-1.4 2.9A3.7 3.7 0 0 0 2 12v4c0 .6.4 1 1 1h2" /> <circle cx="7" cy="17" r="2" /> <path d="M9 17h6" /> <circle cx="17" cy="17" r="2" /> </svg>
lucide-icons/lucide/icons/car.svg
{ "file_path": "lucide-icons/lucide/icons/car.svg", "repo_id": "lucide-icons/lucide", "token_count": 278 }
45
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M22 20v-9H2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2Z" /> <path d="M18 11V4H6v7" /> <path d="M15 22v-4a3 3 0 0 0-3-3a3 3 0 0 0-3 3v4" /> <path d="M22 11V9" /> <path d="M2 11V9" /> <path d="M6 4V2" /> <path d="M18 4V2" /> <path d="M10 4V2" /> <path d="M14 4V2" /> </svg>
lucide-icons/lucide/icons/castle.svg
{ "file_path": "lucide-icons/lucide/icons/castle.svg", "repo_id": "lucide-icons/lucide", "token_count": 259 }
46
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <circle cx="7.5" cy="7.5" r=".5" fill="currentColor" /> <circle cx="18.5" cy="5.5" r=".5" fill="currentColor" /> <circle cx="11.5" cy="11.5" r=".5" fill="currentColor" /> <circle cx="7.5" cy="16.5" r=".5" fill="currentColor" /> <circle cx="17.5" cy="14.5" r=".5" fill="currentColor" /> <path d="M3 3v16a2 2 0 0 0 2 2h16" /> </svg>
lucide-icons/lucide/icons/chart-scatter.svg
{ "file_path": "lucide-icons/lucide/icons/chart-scatter.svg", "repo_id": "lucide-icons/lucide", "token_count": 249 }
47
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z" /> <circle cx="12" cy="12" r="10" /> </svg>
lucide-icons/lucide/icons/compass.svg
{ "file_path": "lucide-icons/lucide/icons/compass.svg", "repo_id": "lucide-icons/lucide", "token_count": 172 }
48
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M22 7.7c0-.6-.4-1.2-.8-1.5l-6.3-3.9a1.72 1.72 0 0 0-1.7 0l-10.3 6c-.5.2-.9.8-.9 1.4v6.6c0 .5.4 1.2.8 1.5l6.3 3.9a1.72 1.72 0 0 0 1.7 0l10.3-6c.5-.3.9-1 .9-1.5Z" /> <path d="M10 21.9V14L2.1 9.1" /> <path d="m10 14 11.9-6.9" /> <path d="M14 19.8v-8.1" /> <path d="M18 17.5V9.4" /> </svg>
lucide-icons/lucide/icons/container.svg
{ "file_path": "lucide-icons/lucide/icons/container.svg", "repo_id": "lucide-icons/lucide", "token_count": 300 }
49
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M11 11.31c1.17.56 1.54 1.69 3.5 1.69 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1" /> <path d="M11.75 18c.35.5 1.45 1 2.75 1 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1" /> <path d="M2 10h4" /> <path d="M2 14h4" /> <path d="M2 18h4" /> <path d="M2 6h4" /> <path d="M7 3a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h4a1 1 0 0 0 1-1L10 4a1 1 0 0 0-1-1z" /> </svg>
lucide-icons/lucide/icons/dam.svg
{ "file_path": "lucide-icons/lucide/icons/dam.svg", "repo_id": "lucide-icons/lucide", "token_count": 305 }
50
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M15 2c-1.35 1.5-2.092 3-2.5 4.5L14 8" /> <path d="m17 6-2.891-2.891" /> <path d="M2 15c3.333-3 6.667-3 10-3" /> <path d="m2 2 20 20" /> <path d="m20 9 .891.891" /> <path d="M22 9c-1.5 1.35-3 2.092-4.5 2.5l-1-1" /> <path d="M3.109 14.109 4 15" /> <path d="m6.5 12.5 1 1" /> <path d="m7 18 2.891 2.891" /> <path d="M9 22c1.35-1.5 2.092-3 2.5-4.5L10 16" /> </svg>
lucide-icons/lucide/icons/dna-off.svg
{ "file_path": "lucide-icons/lucide/icons/dna-off.svg", "repo_id": "lucide-icons/lucide", "token_count": 327 }
51
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m2 2 8 8" /> <path d="m22 2-8 8" /> <ellipse cx="12" cy="9" rx="10" ry="5" /> <path d="M7 13.4v7.9" /> <path d="M12 14v8" /> <path d="M17 13.4v7.9" /> <path d="M2 9v8a10 5 0 0 0 20 0V9" /> </svg>
lucide-icons/lucide/icons/drum.svg
{ "file_path": "lucide-icons/lucide/icons/drum.svg", "repo_id": "lucide-icons/lucide", "token_count": 213 }
52
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <circle cx="11.5" cy="12.5" r="3.5" /> <path d="M3 8c0-3.5 2.5-6 6.5-6 5 0 4.83 3 7.5 5s5 2 5 6c0 4.5-2.5 6.5-7 6.5-2.5 0-2.5 2.5-6 2.5s-7-2-7-5.5c0-3 1.5-3 1.5-5C3.5 10 3 9 3 8Z" /> </svg>
lucide-icons/lucide/icons/egg-fried.svg
{ "file_path": "lucide-icons/lucide/icons/egg-fried.svg", "repo_id": "lucide-icons/lucide", "token_count": 225 }
53
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m15 20 3-3h2a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h2l3 3z" /> <path d="M6 8v1" /> <path d="M10 8v1" /> <path d="M14 8v1" /> <path d="M18 8v1" /> </svg>
lucide-icons/lucide/icons/ethernet-port.svg
{ "file_path": "lucide-icons/lucide/icons/ethernet-port.svg", "repo_id": "lucide-icons/lucide", "token_count": 207 }
54
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M16 16v4a2 2 0 0 1-2 2h-4a2 2 0 0 1-2-2V10c0-2-2-2-2-4" /> <path d="M7 2h11v4c0 2-2 2-2 4v1" /> <line x1="11" x2="18" y1="6" y2="6" /> <line x1="2" x2="22" y1="2" y2="22" /> </svg>
lucide-icons/lucide/icons/flashlight-off.svg
{ "file_path": "lucide-icons/lucide/icons/flashlight-off.svg", "repo_id": "lucide-icons/lucide", "token_count": 216 }
55
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <rect x="3" y="8" width="18" height="4" rx="1" /> <path d="M12 8v13" /> <path d="M19 12v7a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2v-7" /> <path d="M7.5 8a2.5 2.5 0 0 1 0-5A4.8 8 0 0 1 12 8a4.8 8 0 0 1 4.5-5 2.5 2.5 0 0 1 0 5" /> </svg>
lucide-icons/lucide/icons/gift.svg
{ "file_path": "lucide-icons/lucide/icons/gift.svg", "repo_id": "lucide-icons/lucide", "token_count": 227 }
56
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M15 22v-4a4.8 4.8 0 0 0-1-3.5c3 0 6-2 6-5.5.08-1.25-.27-2.48-1-3.5.28-1.15.28-2.35 0-3.5 0 0-1 0-3 1.5-2.64-.5-5.36-.5-8 0C6 2 5 2 5 2c-.3 1.15-.3 2.35 0 3.5A5.403 5.403 0 0 0 4 9c0 3.5 3 5.5 6 5.5-.39.49-.68 1.05-.85 1.65-.17.6-.22 1.23-.15 1.85v4" /> <path d="M9 18c-4.51 2-5-2-7-2" /> </svg>
lucide-icons/lucide/icons/github.svg
{ "file_path": "lucide-icons/lucide/icons/github.svg", "repo_id": "lucide-icons/lucide", "token_count": 294 }
57
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M4 12h8" /> <path d="M4 18V6" /> <path d="M12 18V6" /> <path d="M17 13v-3h4" /> <path d="M17 17.7c.4.2.8.3 1.3.3 1.5 0 2.7-1.1 2.7-2.5S19.8 13 18.3 13H17" /> </svg>
lucide-icons/lucide/icons/heading-5.svg
{ "file_path": "lucide-icons/lucide/icons/heading-5.svg", "repo_id": "lucide-icons/lucide", "token_count": 202 }
58
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <line x1="2" y1="2" x2="22" y2="22" /> <path d="M16.5 16.5 12 21l-7-7c-1.5-1.45-3-3.2-3-5.5a5.5 5.5 0 0 1 2.14-4.35" /> <path d="M8.76 3.1c1.15.22 2.13.78 3.24 1.9 1.5-1.5 2.74-2 4.5-2A5.5 5.5 0 0 1 22 8.5c0 2.12-1.3 3.78-2.67 5.17" /> </svg>
lucide-icons/lucide/icons/heart-off.svg
{ "file_path": "lucide-icons/lucide/icons/heart-off.svg", "repo_id": "lucide-icons/lucide", "token_count": 258 }
59
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <rect width="18" height="18" x="3" y="3" rx="2" ry="2" /> <circle cx="9" cy="9" r="2" /> <path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" /> </svg>
lucide-icons/lucide/icons/image.svg
{ "file_path": "lucide-icons/lucide/icons/image.svg", "repo_id": "lucide-icons/lucide", "token_count": 175 }
60
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="m14 5-3 3 2 7 8-8-7-2Z" /> <path d="m14 5-3 3-3-3 3-3 3 3Z" /> <path d="M9.5 6.5 4 12l3 6" /> <path d="M3 22v-2c0-1.1.9-2 2-2h4a2 2 0 0 1 2 2v2H3Z" /> </svg>
lucide-icons/lucide/icons/lamp-desk.svg
{ "file_path": "lucide-icons/lucide/icons/lamp-desk.svg", "repo_id": "lucide-icons/lucide", "token_count": 201 }
61
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <path d="M9 17H7A5 5 0 0 1 7 7" /> <path d="M15 7h2a5 5 0 0 1 4 8" /> <line x1="8" x2="12" y1="12" y2="12" /> <line x1="2" x2="22" y1="2" y2="22" /> </svg>
lucide-icons/lucide/icons/link-2-off.svg
{ "file_path": "lucide-icons/lucide/icons/link-2-off.svg", "repo_id": "lucide-icons/lucide", "token_count": 183 }
62
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" > <line x1="2" x2="5" y1="12" y2="12" /> <line x1="19" x2="22" y1="12" y2="12" /> <line x1="12" x2="12" y1="2" y2="5" /> <line x1="12" x2="12" y1="19" y2="22" /> <path d="M7.11 7.11C5.83 8.39 5 10.1 5 12c0 3.87 3.13 7 7 7 1.9 0 3.61-.83 4.89-2.11" /> <path d="M18.71 13.96c.19-.63.29-1.29.29-1.96 0-3.87-3.13-7-7-7-.67 0-1.33.1-1.96.29" /> <line x1="2" x2="22" y1="2" y2="22" /> </svg>
lucide-icons/lucide/icons/locate-off.svg
{ "file_path": "lucide-icons/lucide/icons/locate-off.svg", "repo_id": "lucide-icons/lucide", "token_count": 333 }
63