text
stringlengths
21
253k
id
stringlengths
25
123
metadata
dict
__index_level_0__
int64
0
181
import { type MetadataRoute } from "next"; import { siteUrl } from "~/config/site"; export default function robots(): MetadataRoute.Robots { return { rules: [ { userAgent: "*", allow: "/", disallow: ["/api/", `/dashboard`], }, ], sitemap: `${siteUrl}/sitemap.xml`, }; }
moinulmoin/chadnext/src/app/robots.ts
{ "file_path": "moinulmoin/chadnext/src/app/robots.ts", "repo_id": "moinulmoin/chadnext", "token_count": 143 }
100
"use client"; import { usePathname, useRouter } from "next/navigation"; import { Dialog, DialogContent, DialogHeader, DialogTitle, } from "~/components/ui/dialog"; import AuthForm from "./auth-form"; export default function LoginModal() { const router = useRouter(); const pathname = usePathname(); const IsOpen = pathname.includes("/login"); return ( <Dialog open={IsOpen} onOpenChange={() => router.back()}> <DialogContent className="w-full max-w-[400px] rounded-md"> <DialogHeader> <DialogTitle> <h2 className="font-semibold tracking-tight transition-colors"> Login </h2> </DialogTitle> </DialogHeader> <AuthForm /> </DialogContent> </Dialog> ); }
moinulmoin/chadnext/src/components/layout/login-modal.tsx
{ "file_path": "moinulmoin/chadnext/src/components/layout/login-modal.tsx", "repo_id": "moinulmoin/chadnext", "token_count": 319 }
101
import { Resend } from "resend"; export const resend = new Resend(process.env.RESEND_API_KEY);
moinulmoin/chadnext/src/lib/resend.ts
{ "file_path": "moinulmoin/chadnext/src/lib/resend.ts", "repo_id": "moinulmoin/chadnext", "token_count": 33 }
102
import GithubIcon from "@/components/icons/github-icon"; import LinkedInIcon from "@/components/icons/linkedin-icon"; import XIcon from "@/components/icons/x-icon"; import { Card, CardContent, CardHeader, CardTitle, CardFooter, } from "@/components/ui/card"; import Image from "next/image"; import Link from "next/link"; interface TeamProps { imageUrl: string; firstName: string; lastName: string; positions: string[]; socialNetworks: SocialNetworkProps[]; } interface SocialNetworkProps { name: string; url: string; } export const TeamSection = () => { const teamList: TeamProps[] = [ { imageUrl: "https://i.pravatar.cc/250?img=58", firstName: "Leo", lastName: "Miranda", positions: ["Vue Fronted Developer", "Creator Of This Website"], socialNetworks: [ { name: "LinkedIn", url: "https://www.linkedin.com/in/leopoldo-miranda/", }, { name: "Github", url: "https://github.com/leoMirandaa", }, { name: "X", url: "https://x.com/leo_mirand4", }, ], }, { imageUrl: "https://images.unsplash.com/photo-1534528741775-53994a69daeb?q=80&w=1528&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", firstName: "Elizabeth", lastName: "Moore", positions: ["UI/UX Designer"], socialNetworks: [ { name: "LinkedIn", url: "https://www.linkedin.com/in/leopoldo-miranda/", }, { name: "X", url: "https://x.com/leo_mirand4", }, ], }, { imageUrl: "https://images.unsplash.com/photo-1527980965255-d3b416303d12?q=80&w=1760&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", firstName: "David", lastName: "Diaz", positions: ["Machine Learning Engineer", "TensorFlow Tinkerer"], socialNetworks: [ { name: "LinkedIn", url: "https://www.linkedin.com/in/leopoldo-miranda/", }, { name: "Github", url: "https://github.com/leoMirandaa", }, ], }, { imageUrl: "https://images.unsplash.com/photo-1573497161161-c3e73707e25c?q=80&w=1587&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", firstName: "Sarah", lastName: "Robinson", positions: ["Cloud Native Developer", " Kubernetes Orchestrator"], socialNetworks: [ { name: "LinkedIn", url: "https://www.linkedin.com/in/leopoldo-miranda/", }, { name: "Github", url: "https://github.com/leoMirandaa", }, { name: "X", url: "https://x.com/leo_mirand4", }, ], }, { imageUrl: "https://images.unsplash.com/photo-1616805765352-beedbad46b2a?q=80&w=1887&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", firstName: "Michael", lastName: "Holland", positions: ["DevOps Engineer", "CI/CD Pipeline Mastermind"], socialNetworks: [ { name: "LinkedIn", url: "https://www.linkedin.com/in/leopoldo-miranda/", }, ], }, { imageUrl: "https://images.unsplash.com/photo-1573497019940-1c28c88b4f3e?q=80&w=1587&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", firstName: "Zoe", lastName: "Garcia", positions: ["JavaScript Evangelist", "Deno Champion"], socialNetworks: [ { name: "LinkedIn", url: "https://www.linkedin.com/in/leopoldo-miranda/", }, { name: "Github", url: "https://github.com/leoMirandaa", }, ], }, { imageUrl: "https://images.unsplash.com/photo-1633332755192-727a05c4013d?q=80&w=1480&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", firstName: "Evan", lastName: "James", positions: ["Backend Developer"], socialNetworks: [ { name: "LinkedIn", url: "https://www.linkedin.com/in/leopoldo-miranda/", }, { name: "Github", url: "https://github.com/leoMirandaa", }, { name: "X", url: "https://x.com/leo_mirand4", }, ], }, { imageUrl: "https://images.unsplash.com/photo-1573497019236-17f8177b81e8?q=80&w=1740&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3Dhttps://images.unsplash.com/photo-1573497019236-17f8177b81e8?q=80&w=1740&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D", firstName: "Pam", lastName: "Taylor", positions: ["Fullstack Developer", "UX Researcher"], socialNetworks: [ { name: "X", url: "https://x.com/leo_mirand4", }, ], }, ]; const socialIcon = (socialName: string) => { switch (socialName) { case "LinkedIn": return <LinkedInIcon />; case "Github": return <GithubIcon />; case "X": return <XIcon />; } }; return ( <section id="team" className="container lg:w-[75%] py-24 sm:py-32"> <div className="text-center mb-8"> <h2 className="text-lg text-primary text-center mb-2 tracking-wider"> Team </h2> <h2 className="text-3xl md:text-4xl text-center font-bold"> The Company Dream Team </h2> </div> <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-8"> {teamList.map( ( { imageUrl, firstName, lastName, positions, socialNetworks }, index ) => ( <Card key={index} className="bg-muted/60 dark:bg-card flex flex-col h-full overflow-hidden group/hoverimg" > <CardHeader className="p-0 gap-0"> <div className="h-full overflow-hidden"> <Image src={imageUrl} alt="" width={300} height={300} className="w-full aspect-square object-cover saturate-0 transition-all duration-200 ease-linear size-full group-hover/hoverimg:saturate-100 group-hover/hoverimg:scale-[1.01]" /> </div> <CardTitle className="py-6 pb-4 px-6"> {firstName} <span className="text-primary ml-2">{lastName}</span> </CardTitle> </CardHeader> {positions.map((position, index) => ( <CardContent key={index} className={`pb-0 text-muted-foreground ${ index === positions.length - 1 && "pb-6" }`} > {position} {index < positions.length - 1 && <span>,</span>} </CardContent> ))} <CardFooter className="space-x-4 mt-auto"> {socialNetworks.map(({ name, url }, index) => ( <Link key={index} href={url} target="_blank" className="hover:opacity-80 transition-all" > {socialIcon(name)} </Link> ))} </CardFooter> </Card> ) )} </div> </section> ); };
nobruf/shadcn-landing-page/components/layout/sections/team.tsx
{ "file_path": "nobruf/shadcn-landing-page/components/layout/sections/team.tsx", "repo_id": "nobruf/shadcn-landing-page", "token_count": 4309 }
103
"use client" import * as React from "react" import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area" import { cn } from "@/lib/utils" const ScrollArea = React.forwardRef< React.ElementRef<typeof ScrollAreaPrimitive.Root>, React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> >(({ className, children, ...props }, ref) => ( <ScrollAreaPrimitive.Root ref={ref} className={cn("relative overflow-hidden", className)} {...props} > <ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]"> {children} </ScrollAreaPrimitive.Viewport> <ScrollBar /> <ScrollAreaPrimitive.Corner /> </ScrollAreaPrimitive.Root> )) ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName const ScrollBar = React.forwardRef< React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>, React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar> >(({ className, orientation = "vertical", ...props }, ref) => ( <ScrollAreaPrimitive.ScrollAreaScrollbar ref={ref} orientation={orientation} className={cn( "flex touch-none select-none transition-colors", orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-[1px]", orientation === "horizontal" && "h-2.5 flex-col border-t border-t-transparent p-[1px]", className )} {...props} > <ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" /> </ScrollAreaPrimitive.ScrollAreaScrollbar> )) ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName export { ScrollArea, ScrollBar }
nobruf/shadcn-landing-page/components/ui/scroll-area.tsx
{ "file_path": "nobruf/shadcn-landing-page/components/ui/scroll-area.tsx", "repo_id": "nobruf/shadcn-landing-page", "token_count": 576 }
104
import Link from "next/link" import { notFound } from "next/navigation" import { allGuides } from "contentlayer/generated" import { getTableOfContents } from "@/lib/toc" import { Icons } from "@/components/icons" import { Mdx } from "@/components/mdx-components" import { DocsPageHeader } from "@/components/page-header" import { DashboardTableOfContents } from "@/components/toc" import "@/styles/mdx.css" import { Metadata } from "next" import { env } from "@/env.mjs" import { absoluteUrl, cn } from "@/lib/utils" import { buttonVariants } from "@/components/ui/button" interface GuidePageProps { params: { slug: string[] } } async function getGuideFromParams(params) { const slug = params?.slug?.join("/") const guide = allGuides.find((guide) => guide.slugAsParams === slug) if (!guide) { null } return guide } export async function generateMetadata({ params, }: GuidePageProps): Promise<Metadata> { const guide = await getGuideFromParams(params) if (!guide) { return {} } const url = env.NEXT_PUBLIC_APP_URL const ogUrl = new URL(`${url}/api/og`) ogUrl.searchParams.set("heading", guide.title) ogUrl.searchParams.set("type", "Guide") ogUrl.searchParams.set("mode", "dark") return { title: guide.title, description: guide.description, openGraph: { title: guide.title, description: guide.description, type: "article", url: absoluteUrl(guide.slug), images: [ { url: ogUrl.toString(), width: 1200, height: 630, alt: guide.title, }, ], }, twitter: { card: "summary_large_image", title: guide.title, description: guide.description, images: [ogUrl.toString()], }, } } export async function generateStaticParams(): Promise< GuidePageProps["params"][] > { return allGuides.map((guide) => ({ slug: guide.slugAsParams.split("/"), })) } export default async function GuidePage({ params }: GuidePageProps) { const guide = await getGuideFromParams(params) if (!guide) { notFound() } const toc = await getTableOfContents(guide.body.raw) return ( <main className="relative py-6 lg:grid lg:grid-cols-[1fr_300px] lg:gap-10 lg:py-10 xl:gap-20"> <div> <DocsPageHeader heading={guide.title} text={guide.description} /> <Mdx code={guide.body.code} /> <hr className="my-4" /> <div className="flex justify-center py-6 lg:py-10"> <Link href="/guides" className={cn(buttonVariants({ variant: "ghost" }))} > <Icons.chevronLeft className="mr-2 h-4 w-4" /> See all guides </Link> </div> </div> <div className="hidden text-sm lg:block"> <div className="sticky top-16 -mt-10 max-h-[calc(var(--vh)-4rem)] overflow-y-auto pt-10"> <DashboardTableOfContents toc={toc} /> </div> </div> </main> ) }
shadcn-ui/taxonomy/app/(docs)/guides/[...slug]/page.tsx
{ "file_path": "shadcn-ui/taxonomy/app/(docs)/guides/[...slug]/page.tsx", "repo_id": "shadcn-ui/taxonomy", "token_count": 1245 }
105
import { getServerSession } from "next-auth" import * as z from "zod" import { authOptions } from "@/lib/auth" import { db } from "@/lib/db" import { postPatchSchema } from "@/lib/validations/post" const routeContextSchema = z.object({ params: z.object({ postId: z.string(), }), }) export async function DELETE( req: Request, context: z.infer<typeof routeContextSchema> ) { try { // Validate the route params. const { params } = routeContextSchema.parse(context) // Check if the user has access to this post. if (!(await verifyCurrentUserHasAccessToPost(params.postId))) { return new Response(null, { status: 403 }) } // Delete the post. await db.post.delete({ where: { id: params.postId as string, }, }) return new Response(null, { status: 204 }) } catch (error) { if (error instanceof z.ZodError) { return new Response(JSON.stringify(error.issues), { status: 422 }) } return new Response(null, { status: 500 }) } } export async function PATCH( req: Request, context: z.infer<typeof routeContextSchema> ) { try { // Validate route params. const { params } = routeContextSchema.parse(context) // Check if the user has access to this post. if (!(await verifyCurrentUserHasAccessToPost(params.postId))) { return new Response(null, { status: 403 }) } // Get the request body and validate it. const json = await req.json() const body = postPatchSchema.parse(json) // Update the post. // TODO: Implement sanitization for content. await db.post.update({ where: { id: params.postId, }, data: { title: body.title, content: body.content, }, }) return new Response(null, { status: 200 }) } catch (error) { if (error instanceof z.ZodError) { return new Response(JSON.stringify(error.issues), { status: 422 }) } return new Response(null, { status: 500 }) } } async function verifyCurrentUserHasAccessToPost(postId: string) { const session = await getServerSession(authOptions) const count = await db.post.count({ where: { id: postId, authorId: session?.user.id, }, }) return count > 0 }
shadcn-ui/taxonomy/app/api/posts/[postId]/route.ts
{ "file_path": "shadcn-ui/taxonomy/app/api/posts/[postId]/route.ts", "repo_id": "shadcn-ui/taxonomy", "token_count": 840 }
106
import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card" import { Skeleton } from "@/components/ui/skeleton" export function CardSkeleton() { return ( <Card> <CardHeader className="gap-2"> <Skeleton className="h-5 w-1/5" /> <Skeleton className="h-4 w-4/5" /> </CardHeader> <CardContent className="h-10" /> <CardFooter> <Skeleton className="h-8 w-[120px]" /> </CardFooter> </Card> ) }
shadcn-ui/taxonomy/components/card-skeleton.tsx
{ "file_path": "shadcn-ui/taxonomy/components/card-skeleton.tsx", "repo_id": "shadcn-ui/taxonomy", "token_count": 210 }
107
"use client" import * as React from "react" import { cn } from "@/lib/utils" import { Input } from "@/components/ui/input" import { toast } from "@/components/ui/use-toast" interface DocsSearchProps extends React.HTMLAttributes<HTMLFormElement> {} export function DocsSearch({ className, ...props }: DocsSearchProps) { function onSubmit(event: React.SyntheticEvent) { event.preventDefault() return toast({ title: "Not implemented", description: "We're still working on the search.", }) } return ( <form onSubmit={onSubmit} className={cn("relative w-full", className)} {...props} > <Input type="search" placeholder="Search documentation..." className="h-8 w-full sm:w-64 sm:pr-12" /> <kbd className="pointer-events-none absolute right-1.5 top-1.5 hidden h-5 select-none items-center gap-1 rounded border bg-background px-1.5 font-mono text-[10px] font-medium text-muted-foreground opacity-100 sm:flex"> <span className="text-xs"></span>K </kbd> </form> ) }
shadcn-ui/taxonomy/components/search.tsx
{ "file_path": "shadcn-ui/taxonomy/components/search.tsx", "repo_id": "shadcn-ui/taxonomy", "token_count": 420 }
108
"use client" import * as React from "react" import * as CheckboxPrimitive from "@radix-ui/react-checkbox" import { Check } from "lucide-react" import { cn } from "@/lib/utils" const Checkbox = React.forwardRef< React.ElementRef<typeof CheckboxPrimitive.Root>, React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> >(({ className, ...props }, ref) => ( <CheckboxPrimitive.Root ref={ref} className={cn( "peer h-4 w-4 shrink-0 rounded-sm border border-input ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-primary", className )} {...props} > <CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-primary")} > <Check className="h-4 w-4" /> </CheckboxPrimitive.Indicator> </CheckboxPrimitive.Root> )) Checkbox.displayName = CheckboxPrimitive.Root.displayName export { Checkbox }
shadcn-ui/taxonomy/components/ui/checkbox.tsx
{ "file_path": "shadcn-ui/taxonomy/components/ui/checkbox.tsx", "repo_id": "shadcn-ui/taxonomy", "token_count": 365 }
109
"use client" import * as React from "react" import * as SeparatorPrimitive from "@radix-ui/react-separator" import { cn } from "@/lib/utils" const Separator = React.forwardRef< React.ElementRef<typeof SeparatorPrimitive.Root>, React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> >( ( { className, orientation = "horizontal", decorative = true, ...props }, ref ) => ( <SeparatorPrimitive.Root ref={ref} decorative={decorative} orientation={orientation} className={cn( "shrink-0 bg-border", orientation === "horizontal" ? "h-[1px] w-full" : "h-full w-[1px]", className )} {...props} /> ) ) Separator.displayName = SeparatorPrimitive.Root.displayName export { Separator }
shadcn-ui/taxonomy/components/ui/separator.tsx
{ "file_path": "shadcn-ui/taxonomy/components/ui/separator.tsx", "repo_id": "shadcn-ui/taxonomy", "token_count": 310 }
110
import { DashboardConfig } from "types" export const dashboardConfig: DashboardConfig = { mainNav: [ { title: "Documentation", href: "/docs", }, { title: "Support", href: "/support", disabled: true, }, ], sidebarNav: [ { title: "Posts", href: "/dashboard", icon: "post", }, { title: "Billing", href: "/dashboard/billing", icon: "billing", }, { title: "Settings", href: "/dashboard/settings", icon: "settings", }, ], }
shadcn-ui/taxonomy/config/dashboard.ts
{ "file_path": "shadcn-ui/taxonomy/config/dashboard.ts", "repo_id": "shadcn-ui/taxonomy", "token_count": 257 }
111
import * as z from "zod" export const userAuthSchema = z.object({ email: z.string().email(), })
shadcn-ui/taxonomy/lib/validations/auth.ts
{ "file_path": "shadcn-ui/taxonomy/lib/validations/auth.ts", "repo_id": "shadcn-ui/taxonomy", "token_count": 35 }
112
[data-rehype-pretty-code-fragment] code { @apply grid min-w-full break-words rounded-none border-0 bg-transparent p-0 text-sm text-black; counter-reset: line; box-decoration-break: clone; } [data-rehype-pretty-code-fragment] .line { @apply px-4 py-1; } [data-rehype-pretty-code-fragment] [data-line-numbers] > .line::before { counter-increment: line; content: counter(line); display: inline-block; width: 1rem; margin-right: 1rem; text-align: right; color: gray; } [data-rehype-pretty-code-fragment] .line--highlighted { @apply bg-slate-300 bg-opacity-10; } [data-rehype-pretty-code-fragment] .line-highlighted span { @apply relative; } [data-rehype-pretty-code-fragment] .word--highlighted { @apply rounded-md bg-slate-300 bg-opacity-10 p-1; } [data-rehype-pretty-code-title] { @apply mt-4 py-2 px-4 text-sm font-medium; } [data-rehype-pretty-code-title] + pre { @apply mt-0; }
shadcn-ui/taxonomy/styles/mdx.css
{ "file_path": "shadcn-ui/taxonomy/styles/mdx.css", "repo_id": "shadcn-ui/taxonomy", "token_count": 384 }
113
import { Button } from "@/registry/default/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { Input } from "@/registry/default/ui/input" import { Label } from "@/registry/default/ui/label" export const description = "A simple login form with email and password. The submit button says 'Sign in'." export const iframeHeight = "600px" export const containerClassName = "w-full h-screen flex items-center justify-center px-4" export default function LoginForm() { return ( <Card className="w-full max-w-sm"> <CardHeader> <CardTitle className="text-2xl">Login</CardTitle> <CardDescription> Enter your email below to login to your account. </CardDescription> </CardHeader> <CardContent className="grid gap-4"> <div className="grid gap-2"> <Label htmlFor="email">Email</Label> <Input id="email" type="email" placeholder="[email protected]" required /> </div> <div className="grid gap-2"> <Label htmlFor="password">Password</Label> <Input id="password" type="password" required /> </div> </CardContent> <CardFooter> <Button className="w-full">Sign in</Button> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/__registry__/default/block/authentication-01.tsx
{ "file_path": "shadcn-ui/ui/apps/www/__registry__/default/block/authentication-01.tsx", "repo_id": "shadcn-ui/ui", "token_count": 520 }
114
"use client" import { TrendingUp } from "lucide-react" import { CartesianGrid, Line, LineChart, XAxis } from "recharts" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/registry/default/ui/chart" export const description = "A multiple line chart" const chartData = [ { month: "January", desktop: 186, mobile: 80 }, { month: "February", desktop: 305, mobile: 200 }, { month: "March", desktop: 237, mobile: 120 }, { month: "April", desktop: 73, mobile: 190 }, { month: "May", desktop: 209, mobile: 130 }, { month: "June", desktop: 214, mobile: 140 }, ] const chartConfig = { desktop: { label: "Desktop", color: "hsl(var(--chart-1))", }, mobile: { label: "Mobile", color: "hsl(var(--chart-2))", }, } satisfies ChartConfig export default function Component() { return ( <Card> <CardHeader> <CardTitle>Line Chart - Multiple</CardTitle> <CardDescription>January - June 2024</CardDescription> </CardHeader> <CardContent> <ChartContainer config={chartConfig}> <LineChart accessibilityLayer data={chartData} margin={{ left: 12, right: 12, }} > <CartesianGrid vertical={false} /> <XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} tickFormatter={(value) => value.slice(0, 3)} /> <ChartTooltip cursor={false} content={<ChartTooltipContent />} /> <Line dataKey="desktop" type="monotone" stroke="var(--color-desktop)" strokeWidth={2} dot={false} /> <Line dataKey="mobile" type="monotone" stroke="var(--color-mobile)" strokeWidth={2} dot={false} /> </LineChart> </ChartContainer> </CardContent> <CardFooter> <div className="flex w-full items-start gap-2 text-sm"> <div className="grid gap-2"> <div className="flex items-center gap-2 font-medium leading-none"> Trending up by 5.2% this month <TrendingUp className="h-4 w-4" /> </div> <div className="flex items-center gap-2 leading-none text-muted-foreground"> Showing total visitors for the last 6 months </div> </div> </div> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/__registry__/default/block/chart-line-multiple.tsx
{ "file_path": "shadcn-ui/ui/apps/www/__registry__/default/block/chart-line-multiple.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1293 }
115
import Image from "next/image" import Link from "next/link" import { File, Home, LineChart, ListFilter, MoreHorizontal, Package, Package2, PanelLeft, PlusCircle, Search, Settings, ShoppingCart, Users2, } from "lucide-react" import { Badge } from "@/registry/default/ui/badge" import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/registry/default/ui/breadcrumb" import { Button } from "@/registry/default/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { DropdownMenu, DropdownMenuCheckboxItem, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, } from "@/registry/default/ui/dropdown-menu" import { Input } from "@/registry/default/ui/input" import { Sheet, SheetContent, SheetTrigger } from "@/registry/default/ui/sheet" import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/registry/default/ui/table" import { Tabs, TabsContent, TabsList, TabsTrigger, } from "@/registry/default/ui/tabs" import { Tooltip, TooltipContent, TooltipTrigger, } from "@/registry/default/ui/tooltip" export const description = "An products dashboard with a sidebar navigation. The sidebar has icon navigation. The content area has a breadcrumb and search in the header. It displays a list of products in a table with actions." export const iframeHeight = "938px" export const containerClassName = "w-full h-full" export default function Dashboard() { return ( <div className="flex min-h-screen w-full flex-col bg-muted/40"> <aside className="fixed inset-y-0 left-0 z-10 hidden w-14 flex-col border-r bg-background sm:flex"> <nav className="flex flex-col items-center gap-4 px-2 sm:py-5"> <Link href="#" className="group flex h-9 w-9 shrink-0 items-center justify-center gap-2 rounded-full bg-primary text-lg font-semibold text-primary-foreground md:h-8 md:w-8 md:text-base" > <Package2 className="h-4 w-4 transition-all group-hover:scale-110" /> <span className="sr-only">Acme Inc</span> </Link> <Tooltip> <TooltipTrigger asChild> <Link href="#" className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8" > <Home className="h-5 w-5" /> <span className="sr-only">Dashboard</span> </Link> </TooltipTrigger> <TooltipContent side="right">Dashboard</TooltipContent> </Tooltip> <Tooltip> <TooltipTrigger asChild> <Link href="#" className="flex h-9 w-9 items-center justify-center rounded-lg bg-accent text-accent-foreground transition-colors hover:text-foreground md:h-8 md:w-8" > <ShoppingCart className="h-5 w-5" /> <span className="sr-only">Orders</span> </Link> </TooltipTrigger> <TooltipContent side="right">Orders</TooltipContent> </Tooltip> <Tooltip> <TooltipTrigger asChild> <Link href="#" className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8" > <Package className="h-5 w-5" /> <span className="sr-only">Products</span> </Link> </TooltipTrigger> <TooltipContent side="right">Products</TooltipContent> </Tooltip> <Tooltip> <TooltipTrigger asChild> <Link href="#" className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8" > <Users2 className="h-5 w-5" /> <span className="sr-only">Customers</span> </Link> </TooltipTrigger> <TooltipContent side="right">Customers</TooltipContent> </Tooltip> <Tooltip> <TooltipTrigger asChild> <Link href="#" className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8" > <LineChart className="h-5 w-5" /> <span className="sr-only">Analytics</span> </Link> </TooltipTrigger> <TooltipContent side="right">Analytics</TooltipContent> </Tooltip> </nav> <nav className="mt-auto flex flex-col items-center gap-4 px-2 sm:py-5"> <Tooltip> <TooltipTrigger asChild> <Link href="#" className="flex h-9 w-9 items-center justify-center rounded-lg text-muted-foreground transition-colors hover:text-foreground md:h-8 md:w-8" > <Settings className="h-5 w-5" /> <span className="sr-only">Settings</span> </Link> </TooltipTrigger> <TooltipContent side="right">Settings</TooltipContent> </Tooltip> </nav> </aside> <div className="flex flex-col sm:gap-4 sm:py-4 sm:pl-14"> <header className="sticky top-0 z-30 flex h-14 items-center gap-4 border-b bg-background px-4 sm:static sm:h-auto sm:border-0 sm:bg-transparent sm:px-6"> <Sheet> <SheetTrigger asChild> <Button size="icon" variant="outline" className="sm:hidden"> <PanelLeft className="h-5 w-5" /> <span className="sr-only">Toggle Menu</span> </Button> </SheetTrigger> <SheetContent side="left" className="sm:max-w-xs"> <nav className="grid gap-6 text-lg font-medium"> <Link href="#" className="group flex h-10 w-10 shrink-0 items-center justify-center gap-2 rounded-full bg-primary text-lg font-semibold text-primary-foreground md:text-base" > <Package2 className="h-5 w-5 transition-all group-hover:scale-110" /> <span className="sr-only">Acme Inc</span> </Link> <Link href="#" className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground" > <Home className="h-5 w-5" /> Dashboard </Link> <Link href="#" className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground" > <ShoppingCart className="h-5 w-5" /> Orders </Link> <Link href="#" className="flex items-center gap-4 px-2.5 text-foreground" > <Package className="h-5 w-5" /> Products </Link> <Link href="#" className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground" > <Users2 className="h-5 w-5" /> Customers </Link> <Link href="#" className="flex items-center gap-4 px-2.5 text-muted-foreground hover:text-foreground" > <LineChart className="h-5 w-5" /> Settings </Link> </nav> </SheetContent> </Sheet> <Breadcrumb className="hidden md:flex"> <BreadcrumbList> <BreadcrumbItem> <BreadcrumbLink asChild> <Link href="#">Dashboard</Link> </BreadcrumbLink> </BreadcrumbItem> <BreadcrumbSeparator /> <BreadcrumbItem> <BreadcrumbLink asChild> <Link href="#">Products</Link> </BreadcrumbLink> </BreadcrumbItem> <BreadcrumbSeparator /> <BreadcrumbItem> <BreadcrumbPage>All Products</BreadcrumbPage> </BreadcrumbItem> </BreadcrumbList> </Breadcrumb> <div className="relative ml-auto flex-1 md:grow-0"> <Search className="absolute left-2.5 top-2.5 h-4 w-4 text-muted-foreground" /> <Input type="search" placeholder="Search..." className="w-full rounded-lg bg-background pl-8 md:w-[200px] lg:w-[336px]" /> </div> <DropdownMenu> <DropdownMenuTrigger asChild> <Button variant="outline" size="icon" className="overflow-hidden rounded-full" > <Image src="/placeholder-user.jpg" width={36} height={36} alt="Avatar" className="overflow-hidden rounded-full" /> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>My Account</DropdownMenuLabel> <DropdownMenuSeparator /> <DropdownMenuItem>Settings</DropdownMenuItem> <DropdownMenuItem>Support</DropdownMenuItem> <DropdownMenuSeparator /> <DropdownMenuItem>Logout</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </header> <main className="grid flex-1 items-start gap-4 p-4 sm:px-6 sm:py-0 md:gap-8"> <Tabs defaultValue="all"> <div className="flex items-center"> <TabsList> <TabsTrigger value="all">All</TabsTrigger> <TabsTrigger value="active">Active</TabsTrigger> <TabsTrigger value="draft">Draft</TabsTrigger> <TabsTrigger value="archived" className="hidden sm:flex"> Archived </TabsTrigger> </TabsList> <div className="ml-auto flex items-center gap-2"> <DropdownMenu> <DropdownMenuTrigger asChild> <Button variant="outline" size="sm" className="h-8 gap-1"> <ListFilter className="h-3.5 w-3.5" /> <span className="sr-only sm:not-sr-only sm:whitespace-nowrap"> Filter </span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>Filter by</DropdownMenuLabel> <DropdownMenuSeparator /> <DropdownMenuCheckboxItem checked> Active </DropdownMenuCheckboxItem> <DropdownMenuCheckboxItem>Draft</DropdownMenuCheckboxItem> <DropdownMenuCheckboxItem> Archived </DropdownMenuCheckboxItem> </DropdownMenuContent> </DropdownMenu> <Button size="sm" variant="outline" className="h-8 gap-1"> <File className="h-3.5 w-3.5" /> <span className="sr-only sm:not-sr-only sm:whitespace-nowrap"> Export </span> </Button> <Button size="sm" className="h-8 gap-1"> <PlusCircle className="h-3.5 w-3.5" /> <span className="sr-only sm:not-sr-only sm:whitespace-nowrap"> Add Product </span> </Button> </div> </div> <TabsContent value="all"> <Card x-chunk="dashboard-06-chunk-0"> <CardHeader> <CardTitle>Products</CardTitle> <CardDescription> Manage your products and view their sales performance. </CardDescription> </CardHeader> <CardContent> <Table> <TableHeader> <TableRow> <TableHead className="hidden w-[100px] sm:table-cell"> <span className="sr-only">Image</span> </TableHead> <TableHead>Name</TableHead> <TableHead>Status</TableHead> <TableHead className="hidden md:table-cell"> Price </TableHead> <TableHead className="hidden md:table-cell"> Total Sales </TableHead> <TableHead className="hidden md:table-cell"> Created at </TableHead> <TableHead> <span className="sr-only">Actions</span> </TableHead> </TableRow> </TableHeader> <TableBody> <TableRow> <TableCell className="hidden sm:table-cell"> <Image alt="Product image" className="aspect-square rounded-md object-cover" height="64" src="/placeholder.svg" width="64" /> </TableCell> <TableCell className="font-medium"> Laser Lemonade Machine </TableCell> <TableCell> <Badge variant="outline">Draft</Badge> </TableCell> <TableCell className="hidden md:table-cell"> $499.99 </TableCell> <TableCell className="hidden md:table-cell"> 25 </TableCell> <TableCell className="hidden md:table-cell"> 2023-07-12 10:42 AM </TableCell> <TableCell> <DropdownMenu> <DropdownMenuTrigger asChild> <Button aria-haspopup="true" size="icon" variant="ghost" > <MoreHorizontal className="h-4 w-4" /> <span className="sr-only">Toggle menu</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>Actions</DropdownMenuLabel> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Delete</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </TableCell> </TableRow> <TableRow> <TableCell className="hidden sm:table-cell"> <Image alt="Product image" className="aspect-square rounded-md object-cover" height="64" src="/placeholder.svg" width="64" /> </TableCell> <TableCell className="font-medium"> Hypernova Headphones </TableCell> <TableCell> <Badge variant="outline">Active</Badge> </TableCell> <TableCell className="hidden md:table-cell"> $129.99 </TableCell> <TableCell className="hidden md:table-cell"> 100 </TableCell> <TableCell className="hidden md:table-cell"> 2023-10-18 03:21 PM </TableCell> <TableCell> <DropdownMenu> <DropdownMenuTrigger asChild> <Button aria-haspopup="true" size="icon" variant="ghost" > <MoreHorizontal className="h-4 w-4" /> <span className="sr-only">Toggle menu</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>Actions</DropdownMenuLabel> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Delete</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </TableCell> </TableRow> <TableRow> <TableCell className="hidden sm:table-cell"> <Image alt="Product image" className="aspect-square rounded-md object-cover" height="64" src="/placeholder.svg" width="64" /> </TableCell> <TableCell className="font-medium"> AeroGlow Desk Lamp </TableCell> <TableCell> <Badge variant="outline">Active</Badge> </TableCell> <TableCell className="hidden md:table-cell"> $39.99 </TableCell> <TableCell className="hidden md:table-cell"> 50 </TableCell> <TableCell className="hidden md:table-cell"> 2023-11-29 08:15 AM </TableCell> <TableCell> <DropdownMenu> <DropdownMenuTrigger asChild> <Button aria-haspopup="true" size="icon" variant="ghost" > <MoreHorizontal className="h-4 w-4" /> <span className="sr-only">Toggle menu</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>Actions</DropdownMenuLabel> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Delete</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </TableCell> </TableRow> <TableRow> <TableCell className="hidden sm:table-cell"> <Image alt="Product image" className="aspect-square rounded-md object-cover" height="64" src="/placeholder.svg" width="64" /> </TableCell> <TableCell className="font-medium"> TechTonic Energy Drink </TableCell> <TableCell> <Badge variant="secondary">Draft</Badge> </TableCell> <TableCell className="hidden md:table-cell"> $2.99 </TableCell> <TableCell className="hidden md:table-cell"> 0 </TableCell> <TableCell className="hidden md:table-cell"> 2023-12-25 11:59 PM </TableCell> <TableCell> <DropdownMenu> <DropdownMenuTrigger asChild> <Button aria-haspopup="true" size="icon" variant="ghost" > <MoreHorizontal className="h-4 w-4" /> <span className="sr-only">Toggle menu</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>Actions</DropdownMenuLabel> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Delete</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </TableCell> </TableRow> <TableRow> <TableCell className="hidden sm:table-cell"> <Image alt="Product image" className="aspect-square rounded-md object-cover" height="64" src="/placeholder.svg" width="64" /> </TableCell> <TableCell className="font-medium"> Gamer Gear Pro Controller </TableCell> <TableCell> <Badge variant="outline">Active</Badge> </TableCell> <TableCell className="hidden md:table-cell"> $59.99 </TableCell> <TableCell className="hidden md:table-cell"> 75 </TableCell> <TableCell className="hidden md:table-cell"> 2024-01-01 12:00 AM </TableCell> <TableCell> <DropdownMenu> <DropdownMenuTrigger asChild> <Button aria-haspopup="true" size="icon" variant="ghost" > <MoreHorizontal className="h-4 w-4" /> <span className="sr-only">Toggle menu</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>Actions</DropdownMenuLabel> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Delete</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </TableCell> </TableRow> <TableRow> <TableCell className="hidden sm:table-cell"> <Image alt="Product image" className="aspect-square rounded-md object-cover" height="64" src="/placeholder.svg" width="64" /> </TableCell> <TableCell className="font-medium"> Luminous VR Headset </TableCell> <TableCell> <Badge variant="outline">Active</Badge> </TableCell> <TableCell className="hidden md:table-cell"> $199.99 </TableCell> <TableCell className="hidden md:table-cell"> 30 </TableCell> <TableCell className="hidden md:table-cell"> 2024-02-14 02:14 PM </TableCell> <TableCell> <DropdownMenu> <DropdownMenuTrigger asChild> <Button aria-haspopup="true" size="icon" variant="ghost" > <MoreHorizontal className="h-4 w-4" /> <span className="sr-only">Toggle menu</span> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end"> <DropdownMenuLabel>Actions</DropdownMenuLabel> <DropdownMenuItem>Edit</DropdownMenuItem> <DropdownMenuItem>Delete</DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> </TableCell> </TableRow> </TableBody> </Table> </CardContent> <CardFooter> <div className="text-xs text-muted-foreground"> Showing <strong>1-10</strong> of <strong>32</strong>{" "} products </div> </CardFooter> </Card> </TabsContent> </Tabs> </main> </div> </div> ) }
shadcn-ui/ui/apps/www/__registry__/default/block/dashboard-06.tsx
{ "file_path": "shadcn-ui/ui/apps/www/__registry__/default/block/dashboard-06.tsx", "repo_id": "shadcn-ui/ui", "token_count": 16830 }
116
"use client" import { TrendingUp } from "lucide-react" import { CartesianGrid, Dot, Line, LineChart } from "recharts" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/registry/new-york/ui/chart" export const description = "A line chart with dots and colors" const chartData = [ { browser: "chrome", visitors: 275, fill: "var(--color-chrome)" }, { browser: "safari", visitors: 200, fill: "var(--color-safari)" }, { browser: "firefox", visitors: 187, fill: "var(--color-firefox)" }, { browser: "edge", visitors: 173, fill: "var(--color-edge)" }, { browser: "other", visitors: 90, fill: "var(--color-other)" }, ] const chartConfig = { visitors: { label: "Visitors", color: "hsl(var(--chart-2))", }, chrome: { label: "Chrome", color: "hsl(var(--chart-1))", }, safari: { label: "Safari", color: "hsl(var(--chart-2))", }, firefox: { label: "Firefox", color: "hsl(var(--chart-3))", }, edge: { label: "Edge", color: "hsl(var(--chart-4))", }, other: { label: "Other", color: "hsl(var(--chart-5))", }, } satisfies ChartConfig export default function Component() { return ( <Card> <CardHeader> <CardTitle>Line Chart - Dots Colors</CardTitle> <CardDescription>January - June 2024</CardDescription> </CardHeader> <CardContent> <ChartContainer config={chartConfig}> <LineChart accessibilityLayer data={chartData} margin={{ top: 24, left: 24, right: 24, }} > <CartesianGrid vertical={false} /> <ChartTooltip cursor={false} content={ <ChartTooltipContent indicator="line" nameKey="visitors" hideLabel /> } /> <Line dataKey="visitors" type="natural" stroke="var(--color-visitors)" strokeWidth={2} dot={({ payload, ...props }) => { return ( <Dot key={payload.browser} r={5} cx={props.cx} cy={props.cy} fill={payload.fill} stroke={payload.fill} /> ) }} /> </LineChart> </ChartContainer> </CardContent> <CardFooter className="flex-col items-start gap-2 text-sm"> <div className="flex gap-2 font-medium leading-none"> Trending up by 5.2% this month <TrendingUp className="h-4 w-4" /> </div> <div className="leading-none text-muted-foreground"> Showing total visitors for the last 6 months </div> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/__registry__/new-york/block/chart-line-dots-colors.tsx
{ "file_path": "shadcn-ui/ui/apps/www/__registry__/new-york/block/chart-line-dots-colors.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1547 }
117
"use client" import { Pie, PieChart } from "recharts" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" import { ChartConfig, ChartContainer, ChartLegend, ChartLegendContent, } from "@/registry/new-york/ui/chart" export const description = "A pie chart with a legend" const chartData = [ { browser: "chrome", visitors: 275, fill: "var(--color-chrome)" }, { browser: "safari", visitors: 200, fill: "var(--color-safari)" }, { browser: "firefox", visitors: 187, fill: "var(--color-firefox)" }, { browser: "edge", visitors: 173, fill: "var(--color-edge)" }, { browser: "other", visitors: 90, fill: "var(--color-other)" }, ] const chartConfig = { visitors: { label: "Visitors", }, chrome: { label: "Chrome", color: "hsl(var(--chart-1))", }, safari: { label: "Safari", color: "hsl(var(--chart-2))", }, firefox: { label: "Firefox", color: "hsl(var(--chart-3))", }, edge: { label: "Edge", color: "hsl(var(--chart-4))", }, other: { label: "Other", color: "hsl(var(--chart-5))", }, } satisfies ChartConfig export default function Component() { return ( <Card className="flex flex-col"> <CardHeader className="items-center pb-0"> <CardTitle>Pie Chart - Legend</CardTitle> <CardDescription>January - June 2024</CardDescription> </CardHeader> <CardContent className="flex-1 pb-0"> <ChartContainer config={chartConfig} className="mx-auto aspect-square max-h-[300px]" > <PieChart> <Pie data={chartData} dataKey="visitors" /> <ChartLegend content={<ChartLegendContent nameKey="browser" />} className="-translate-y-2 flex-wrap gap-2 [&>*]:basis-1/4 [&>*]:justify-center" /> </PieChart> </ChartContainer> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/__registry__/new-york/block/chart-pie-legend.tsx
{ "file_path": "shadcn-ui/ui/apps/www/__registry__/new-york/block/chart-pie-legend.tsx", "repo_id": "shadcn-ui/ui", "token_count": 828 }
118
"use client" import { Bar, BarChart, XAxis } from "recharts" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/registry/new-york/ui/chart" export const description = "A stacked bar chart with a legend" const chartData = [ { date: "2024-07-15", running: 450, swimming: 300 }, { date: "2024-07-16", running: 380, swimming: 420 }, { date: "2024-07-17", running: 520, swimming: 120 }, { date: "2024-07-18", running: 140, swimming: 550 }, { date: "2024-07-19", running: 600, swimming: 350 }, { date: "2024-07-20", running: 480, swimming: 400 }, ] const chartConfig = { running: { label: "Running", color: "hsl(var(--chart-1))", }, swimming: { label: "Swimming", color: "hsl(var(--chart-2))", }, } satisfies ChartConfig export default function Component() { return ( <Card> <CardHeader> <CardTitle>Tooltip - No Label</CardTitle> <CardDescription>Tooltip with no label.</CardDescription> </CardHeader> <CardContent> <ChartContainer config={chartConfig}> <BarChart accessibilityLayer data={chartData}> <XAxis dataKey="date" tickLine={false} tickMargin={10} axisLine={false} tickFormatter={(value) => { return new Date(value).toLocaleDateString("en-US", { weekday: "short", }) }} /> <Bar dataKey="running" stackId="a" fill="var(--color-running)" radius={[0, 0, 4, 4]} /> <Bar dataKey="swimming" stackId="a" fill="var(--color-swimming)" radius={[4, 4, 0, 0]} /> <ChartTooltip content={<ChartTooltipContent hideIndicator hideLabel />} cursor={false} defaultIndex={1} /> </BarChart> </ChartContainer> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/__registry__/new-york/block/chart-tooltip-label-none.tsx
{ "file_path": "shadcn-ui/ui/apps/www/__registry__/new-york/block/chart-tooltip-label-none.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1061 }
119
export { default as ChartAreaDefault } from "@/registry/new-york/block/chart-area-default" export { default as ChartAreaLinear } from "@/registry/new-york/block/chart-area-linear" export { default as ChartAreaStep } from "@/registry/new-york/block/chart-area-step" export { default as ChartAreaLegend } from "@/registry/new-york/block/chart-area-legend" export { default as ChartAreaStacked } from "@/registry/new-york/block/chart-area-stacked" export { default as ChartAreaStackedExpand } from "@/registry/new-york/block/chart-area-stacked-expand" export { default as ChartAreaIcons } from "@/registry/new-york/block/chart-area-icons" export { default as ChartAreaGradient } from "@/registry/new-york/block/chart-area-gradient" export { default as ChartAreaAxes } from "@/registry/new-york/block/chart-area-axes" export { default as ChartAreaInteractive } from "@/registry/new-york/block/chart-area-interactive" export { default as ChartBarDefault } from "@/registry/new-york/block/chart-bar-default" export { default as ChartBarHorizontal } from "@/registry/new-york/block/chart-bar-horizontal" export { default as ChartBarMultiple } from "@/registry/new-york/block/chart-bar-multiple" export { default as ChartBarStacked } from "@/registry/new-york/block/chart-bar-stacked" export { default as ChartBarLabel } from "@/registry/new-york/block/chart-bar-label" export { default as ChartBarLabelCustom } from "@/registry/new-york/block/chart-bar-label-custom" export { default as ChartBarMixed } from "@/registry/new-york/block/chart-bar-mixed" export { default as ChartBarActive } from "@/registry/new-york/block/chart-bar-active" export { default as ChartBarNegative } from "@/registry/new-york/block/chart-bar-negative" export { default as ChartBarInteractive } from "@/registry/new-york/block/chart-bar-interactive" export { default as ChartLineDefault } from "@/registry/new-york/block/chart-line-default" export { default as ChartLineLinear } from "@/registry/new-york/block/chart-line-linear" export { default as ChartLineStep } from "@/registry/new-york/block/chart-line-step" export { default as ChartLineMultiple } from "@/registry/new-york/block/chart-line-multiple" export { default as ChartLineDots } from "@/registry/new-york/block/chart-line-dots" export { default as ChartLineDotsCustom } from "@/registry/new-york/block/chart-line-dots-custom" export { default as ChartLineDotsColors } from "@/registry/new-york/block/chart-line-dots-colors" export { default as ChartLineLabel } from "@/registry/new-york/block/chart-line-label" export { default as ChartLineLabelCustom } from "@/registry/new-york/block/chart-line-label-custom" export { default as ChartLineInteractive } from "@/registry/new-york/block/chart-line-interactive" export { default as ChartPieSimple } from "@/registry/new-york/block/chart-pie-simple" export { default as ChartPieSeparatorNone } from "@/registry/new-york/block/chart-pie-separator-none" export { default as ChartPieLabel } from "@/registry/new-york/block/chart-pie-label" export { default as ChartPieLabelCustom } from "@/registry/new-york/block/chart-pie-label-custom" export { default as ChartPieLabelList } from "@/registry/new-york/block/chart-pie-label-list" export { default as ChartPieLegend } from "@/registry/new-york/block/chart-pie-legend" export { default as ChartPieDonut } from "@/registry/new-york/block/chart-pie-donut" export { default as ChartPieDonutActive } from "@/registry/new-york/block/chart-pie-donut-active" export { default as ChartPieDonutText } from "@/registry/new-york/block/chart-pie-donut-text" export { default as ChartPieStacked } from "@/registry/new-york/block/chart-pie-stacked" export { default as ChartPieInteractive } from "@/registry/new-york/block/chart-pie-interactive" export { default as ChartRadarDefault } from "@/registry/new-york/block/chart-radar-default" export { default as ChartRadarDots } from "@/registry/new-york/block/chart-radar-dots" export { default as ChartRadarLinesOnly } from "@/registry/new-york/block/chart-radar-lines-only" export { default as ChartRadarLabelCustom } from "@/registry/new-york/block/chart-radar-label-custom" export { default as ChartRadarGridCustom } from "@/registry/new-york/block/chart-radar-grid-custom" export { default as ChartRadarGridNone } from "@/registry/new-york/block/chart-radar-grid-none" export { default as ChartRadarGridCircle } from "@/registry/new-york/block/chart-radar-grid-circle" export { default as ChartRadarGridCircleNoLines } from "@/registry/new-york/block/chart-radar-grid-circle-no-lines" export { default as ChartRadarGridCircleFill } from "@/registry/new-york/block/chart-radar-grid-circle-fill" export { default as ChartRadarGridFill } from "@/registry/new-york/block/chart-radar-grid-fill" export { default as ChartRadarMultiple } from "@/registry/new-york/block/chart-radar-multiple" export { default as ChartRadarLegend } from "@/registry/new-york/block/chart-radar-legend" export { default as ChartRadarIcons } from "@/registry/new-york/block/chart-radar-icons" export { default as ChartRadarRadius } from "@/registry/new-york/block/chart-radar-radius" export { default as ChartRadialSimple } from "@/registry/new-york/block/chart-radial-simple" export { default as ChartRadialLabel } from "@/registry/new-york/block/chart-radial-label" export { default as ChartRadialGrid } from "@/registry/new-york/block/chart-radial-grid" export { default as ChartRadialText } from "@/registry/new-york/block/chart-radial-text" export { default as ChartRadialShape } from "@/registry/new-york/block/chart-radial-shape" export { default as ChartRadialStacked } from "@/registry/new-york/block/chart-radial-stacked" export { default as ChartTooltipDefault } from "@/registry/new-york/block/chart-tooltip-default" export { default as ChartTooltipIndicatorLine } from "@/registry/new-york/block/chart-tooltip-indicator-line" export { default as ChartTooltipIndicatorNone } from "@/registry/new-york/block/chart-tooltip-indicator-none" export { default as ChartTooltipLabelCustom } from "@/registry/new-york/block/chart-tooltip-label-custom" export { default as ChartTooltipLabelFormatter } from "@/registry/new-york/block/chart-tooltip-label-formatter" export { default as ChartTooltipLabelNone } from "@/registry/new-york/block/chart-tooltip-label-none" export { default as ChartTooltipFormatter } from "@/registry/new-york/block/chart-tooltip-formatter" export { default as ChartTooltipIcons } from "@/registry/new-york/block/chart-tooltip-icons" export { default as ChartTooltipAdvanced } from "@/registry/new-york/block/chart-tooltip-advanced"
shadcn-ui/ui/apps/www/app/(app)/charts/charts.tsx
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/charts/charts.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2172 }
120
"use client" import { Avatar, AvatarFallback, AvatarImage, } from "@/registry/new-york/ui/avatar" import { Button } from "@/registry/new-york/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" import { Input } from "@/registry/new-york/ui/input" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/registry/new-york/ui/select" import { Separator } from "@/registry/new-york/ui/separator" export function DemoShareDocument() { return ( <Card> <CardHeader> <CardTitle>Share this document</CardTitle> <CardDescription> Anyone with the link can view this document. </CardDescription> </CardHeader> <CardContent> <div className="flex space-x-2"> <Input 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" /> <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]"> <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" /> <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]"> <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" /> <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]"> <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/app/(app)/examples/cards/components/share-document.tsx
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/cards/components/share-document.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2254 }
121
"use client" import { zodResolver } from "@hookform/resolvers/zod" import { useForm } from "react-hook-form" import { z } from "zod" import { toast } from "@/registry/new-york/hooks/use-toast" import { Button } from "@/registry/new-york/ui/button" import { Checkbox } from "@/registry/new-york/ui/checkbox" import { Form, FormControl, FormDescription, FormField, FormItem, FormLabel, FormMessage, } from "@/registry/new-york/ui/form" const items = [ { id: "recents", label: "Recents", }, { id: "home", label: "Home", }, { id: "applications", label: "Applications", }, { id: "desktop", label: "Desktop", }, { id: "downloads", label: "Downloads", }, { id: "documents", label: "Documents", }, ] as const const displayFormSchema = z.object({ items: z.array(z.string()).refine((value) => value.some((item) => item), { message: "You have to select at least one item.", }), }) type DisplayFormValues = z.infer<typeof displayFormSchema> // This can come from your database or API. const defaultValues: Partial<DisplayFormValues> = { items: ["recents", "home"], } export function DisplayForm() { const form = useForm<DisplayFormValues>({ resolver: zodResolver(displayFormSchema), defaultValues, }) function onSubmit(data: DisplayFormValues) { 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="space-y-8"> <FormField control={form.control} name="items" render={() => ( <FormItem> <div className="mb-4"> <FormLabel className="text-base">Sidebar</FormLabel> <FormDescription> Select the items you want to display in the sidebar. </FormDescription> </div> {items.map((item) => ( <FormField key={item.id} control={form.control} name="items" render={({ field }) => { return ( <FormItem key={item.id} className="flex flex-row items-start space-x-3 space-y-0" > <FormControl> <Checkbox checked={field.value?.includes(item.id)} onCheckedChange={(checked) => { return checked ? field.onChange([...field.value, item.id]) : field.onChange( field.value?.filter( (value) => value !== item.id ) ) }} /> </FormControl> <FormLabel className="font-normal"> {item.label} </FormLabel> </FormItem> ) }} /> ))} <FormMessage /> </FormItem> )} /> <Button type="submit">Update display</Button> </form> </Form> ) }
shadcn-ui/ui/apps/www/app/(app)/examples/forms/display/display-form.tsx
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/forms/display/display-form.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1964 }
122
import Image from "next/image" import { PlusCircledIcon } from "@radix-ui/react-icons" import { cn } from "@/lib/utils" import { ContextMenu, ContextMenuContent, ContextMenuItem, ContextMenuSeparator, ContextMenuSub, ContextMenuSubContent, ContextMenuSubTrigger, ContextMenuTrigger, } from "@/registry/new-york/ui/context-menu" import { Album } from "../data/albums" import { playlists } from "../data/playlists" interface AlbumArtworkProps extends React.HTMLAttributes<HTMLDivElement> { album: Album aspectRatio?: "portrait" | "square" width?: number height?: number } export function AlbumArtwork({ album, aspectRatio = "portrait", width, height, className, ...props }: AlbumArtworkProps) { return ( <div className={cn("space-y-3", className)} {...props}> <ContextMenu> <ContextMenuTrigger> <div className="overflow-hidden rounded-md"> <Image src={album.cover} alt={album.name} width={width} height={height} className={cn( "h-auto w-auto object-cover transition-all hover:scale-105", aspectRatio === "portrait" ? "aspect-[3/4]" : "aspect-square" )} /> </div> </ContextMenuTrigger> <ContextMenuContent className="w-40"> <ContextMenuItem>Add to Library</ContextMenuItem> <ContextMenuSub> <ContextMenuSubTrigger>Add to Playlist</ContextMenuSubTrigger> <ContextMenuSubContent className="w-48"> <ContextMenuItem> <PlusCircledIcon className="mr-2 h-4 w-4" /> New Playlist </ContextMenuItem> <ContextMenuSeparator /> {playlists.map((playlist) => ( <ContextMenuItem key={playlist}> <svg xmlns="http://www.w3.org/2000/svg" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" className="mr-2 h-4 w-4" viewBox="0 0 24 24" > <path d="M21 15V6M18.5 18a2.5 2.5 0 1 0 0-5 2.5 2.5 0 0 0 0 5ZM12 12H3M16 6H3M12 18H3" /> </svg> {playlist} </ContextMenuItem> ))} </ContextMenuSubContent> </ContextMenuSub> <ContextMenuSeparator /> <ContextMenuItem>Play Next</ContextMenuItem> <ContextMenuItem>Play Later</ContextMenuItem> <ContextMenuItem>Create Station</ContextMenuItem> <ContextMenuSeparator /> <ContextMenuItem>Like</ContextMenuItem> <ContextMenuItem>Share</ContextMenuItem> </ContextMenuContent> </ContextMenu> <div className="space-y-1 text-sm"> <h3 className="font-medium leading-none">{album.name}</h3> <p className="text-xs text-muted-foreground">{album.artist}</p> </div> </div> ) }
shadcn-ui/ui/apps/www/app/(app)/examples/music/components/album-artwork.tsx
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/music/components/album-artwork.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1554 }
123
export const types = ["GPT-3", "Codex"] as const export type ModelType = (typeof types)[number] export interface Model<Type = string> { id: string name: string description: string strengths?: string type: Type } export const models: Model<ModelType>[] = [ { id: "c305f976-8e38-42b1-9fb7-d21b2e34f0da", name: "text-davinci-003", description: "Most capable GPT-3 model. Can do any task the other models can do, often with higher quality, longer output and better instruction-following. Also supports inserting completions within text.", type: "GPT-3", strengths: "Complex intent, cause and effect, creative generation, search, summarization for audience", }, { id: "464a47c3-7ab5-44d7-b669-f9cb5a9e8465", name: "text-curie-001", description: "Very capable, but faster and lower cost than Davinci.", type: "GPT-3", strengths: "Language translation, complex classification, sentiment, summarization", }, { id: "ac0797b0-7e31-43b6-a494-da7e2ab43445", name: "text-babbage-001", description: "Capable of straightforward tasks, very fast, and lower cost.", type: "GPT-3", strengths: "Moderate classification, semantic search", }, { id: "be638fb1-973b-4471-a49c-290325085802", name: "text-ada-001", description: "Capable of very simple tasks, usually the fastest model in the GPT-3 series, and lowest cost.", type: "GPT-3", strengths: "Parsing text, simple classification, address correction, keywords", }, { id: "b43c0ea9-5ad4-456a-ae29-26cd77b6d0fb", name: "code-davinci-002", description: "Most capable Codex model. Particularly good at translating natural language to code. In addition to completing code, also supports inserting completions within code.", type: "Codex", }, { id: "bbd57291-4622-4a21-9eed-dd6bd786fdd1", name: "code-cushman-001", description: "Almost as capable as Davinci Codex, but slightly faster. This speed advantage may make it preferable for real-time applications.", type: "Codex", strengths: "Real-time application where low-latency is preferable", }, ]
shadcn-ui/ui/apps/www/app/(app)/examples/playground/data/models.ts
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/playground/data/models.ts", "repo_id": "shadcn-ui/ui", "token_count": 792 }
124
import { promises as fs } from "fs" import path from "path" import { Metadata } from "next" import Image from "next/image" import { z } from "zod" import { columns } from "./components/columns" import { DataTable } from "./components/data-table" import { UserNav } from "./components/user-nav" import { taskSchema } from "./data/schema" export const metadata: Metadata = { title: "Tasks", description: "A task and issue tracker build using Tanstack Table.", } // Simulate a database read for tasks. async function getTasks() { const data = await fs.readFile( path.join(process.cwd(), "app/(app)/examples/tasks/data/tasks.json") ) const tasks = JSON.parse(data.toString()) return z.array(taskSchema).parse(tasks) } export default async function TaskPage() { const tasks = await getTasks() return ( <> <div className="md:hidden"> <Image src="/examples/tasks-light.png" width={1280} height={998} alt="Playground" className="block dark:hidden" /> <Image src="/examples/tasks-dark.png" width={1280} height={998} alt="Playground" className="hidden dark:block" /> </div> <div className="hidden h-full flex-1 flex-col space-y-8 p-8 md:flex"> <div className="flex items-center justify-between space-y-2"> <div> <h2 className="text-2xl font-bold tracking-tight">Welcome back!</h2> <p className="text-muted-foreground"> Here&apos;s a list of your tasks for this month! </p> </div> <div className="flex items-center space-x-2"> <UserNav /> </div> </div> <DataTable data={tasks} columns={columns} /> </div> </> ) }
shadcn-ui/ui/apps/www/app/(app)/examples/tasks/page.tsx
{ "file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/tasks/page.tsx", "repo_id": "shadcn-ui/ui", "token_count": 800 }
125
import { getBlock } from "@/lib/blocks" import { BlockPreview } from "@/components/block-preview" import { styles } from "@/registry/registry-styles" export async function BlockDisplay({ name }: { name: string }) { const blocks = await Promise.all( styles.map(async (style) => { const block = await getBlock(name, style.name) const hasLiftMode = block?.chunks ? block?.chunks?.length > 0 : false // Cannot (and don't need to) pass to the client. delete block?.component delete block?.chunks return { ...block, hasLiftMode, } }) ) if (!blocks?.length) { return null } return blocks.map((block) => ( <BlockPreview key={`${block.style}-${block.name}`} block={block} /> )) }
shadcn-ui/ui/apps/www/components/block-display.tsx
{ "file_path": "shadcn-ui/ui/apps/www/components/block-display.tsx", "repo_id": "shadcn-ui/ui", "token_count": 290 }
126
"use client" import * as React from "react" import { Index } from "@/__registry__" import { cn } from "@/lib/utils" import { useConfig } from "@/hooks/use-config" import { CopyButton } from "@/components/copy-button" import { Icons } from "@/components/icons" import { StyleSwitcher } from "@/components/style-switcher" import { ThemeWrapper } from "@/components/theme-wrapper" import { V0Button } from "@/components/v0-button" import { Tabs, TabsContent, TabsList, TabsTrigger, } from "@/registry/new-york/ui/tabs" import { styles } from "@/registry/registry-styles" interface ComponentPreviewProps extends React.HTMLAttributes<HTMLDivElement> { name: string extractClassname?: boolean extractedClassNames?: string align?: "center" | "start" | "end" description?: string hideCode?: boolean } export function ComponentPreview({ name, children, className, extractClassname, extractedClassNames, align = "center", description, hideCode = false, ...props }: ComponentPreviewProps) { const [config] = useConfig() const index = styles.findIndex((style) => style.name === config.style) const Codes = React.Children.toArray(children) as React.ReactElement[] const Code = Codes[index] const Preview = React.useMemo(() => { const Component = Index[config.style][name]?.component if (!Component) { return ( <p className="text-sm text-muted-foreground"> Component{" "} <code className="relative rounded bg-muted px-[0.3rem] py-[0.2rem] font-mono text-sm"> {name} </code>{" "} not found in registry. </p> ) } return <Component /> }, [name, config.style]) const codeString = React.useMemo(() => { if ( typeof Code?.props["data-rehype-pretty-code-fragment"] !== "undefined" ) { const [Button] = React.Children.toArray( Code.props.children ) as React.ReactElement[] return Button?.props?.value || Button?.props?.__rawString__ || null } }, [Code]) return ( <div className={cn("group relative my-4 flex flex-col space-y-2", className)} {...props} > <Tabs defaultValue="preview" className="relative mr-auto w-full"> <div className="flex items-center justify-between pb-3"> {!hideCode && ( <TabsList className="w-full justify-start rounded-none border-b 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 border"> <div className="flex items-center justify-between p-4"> <StyleSwitcher /> <div className="flex items-center gap-2"> {config.style === "default" && description ? ( <V0Button block={{ code: codeString, name, style: config.style, description, }} /> ) : null} <CopyButton value={codeString} variant="outline" className="h-7 w-7 text-foreground opacity-100 hover:bg-muted hover:text-foreground [&_svg]:h-3.5 [&_svg]:w-3.5" /> </div> </div> <ThemeWrapper defaultTheme="zinc"> <div className={cn( "preview flex min-h-[350px] w-full justify-center p-10", { "items-center": align === "center", "items-start": align === "start", "items-end": align === "end", } )} > <React.Suspense fallback={ <div className="flex w-full items-center justify-center text-sm text-muted-foreground"> <Icons.spinner className="mr-2 h-4 w-4 animate-spin" /> Loading... </div> } > {Preview} </React.Suspense> </div> </ThemeWrapper> </TabsContent> <TabsContent value="code"> <div className="flex flex-col space-y-4"> <div className="w-full rounded-md [&_pre]:my-0 [&_pre]:max-h-[350px] [&_pre]:overflow-auto"> {Code} </div> </div> </TabsContent> </Tabs> </div> ) }
shadcn-ui/ui/apps/www/components/component-preview.tsx
{ "file_path": "shadcn-ui/ui/apps/www/components/component-preview.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2513 }
127
"use client" import Link from "next/link" import { usePathname } from "next/navigation" import { SidebarNavItem } from "types/nav" import { type DocsConfig } from "@/config/docs" import { cn } from "@/lib/utils" export interface DocsSidebarNavProps { config: DocsConfig } export function DocsSidebarNav({ config }: DocsSidebarNavProps) { const pathname = usePathname() const items = pathname?.startsWith("/charts") ? config.chartsNav : config.sidebarNav return items.length ? ( <div className="w-full"> {items.map((item, index) => ( <div key={index} className={cn("pb-4")}> <h4 className="mb-1 rounded-md px-2 py-1 text-sm font-semibold"> {item.title} </h4> {item?.items?.length && ( <DocsSidebarNavItems items={item.items} pathname={pathname} /> )} </div> ))} </div> ) : null } interface DocsSidebarNavItemsProps { items: SidebarNavItem[] pathname: string | null } export function DocsSidebarNavItems({ items, pathname, }: DocsSidebarNavItemsProps) { return items?.length ? ( <div className="grid grid-flow-row auto-rows-max text-sm"> {items.map((item, index) => item.href && !item.disabled ? ( <Link key={index} href={item.href} className={cn( "group flex w-full items-center rounded-md border border-transparent px-2 py-1 hover:underline", item.disabled && "cursor-not-allowed opacity-60", pathname === item.href ? "font-medium text-foreground" : "text-muted-foreground" )} target={item.external ? "_blank" : ""} rel={item.external ? "noreferrer" : ""} > {item.title} {item.label && ( <span className="ml-2 rounded-md bg-[#adfa1d] px-1.5 py-0.5 text-xs leading-none text-[#000000] no-underline group-hover:no-underline"> {item.label} </span> )} </Link> ) : ( <span key={index} className={cn( "flex w-full cursor-not-allowed items-center rounded-md p-2 text-muted-foreground hover:underline", item.disabled && "cursor-not-allowed opacity-60" )} > {item.title} {item.label && ( <span className="ml-2 rounded-md bg-muted px-1.5 py-0.5 text-xs leading-none text-muted-foreground no-underline group-hover:no-underline"> {item.label} </span> )} </span> ) )} </div> ) : null }
shadcn-ui/ui/apps/www/components/sidebar-nav.tsx
{ "file_path": "shadcn-ui/ui/apps/www/components/sidebar-nav.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1326 }
128
import { useAtom } from "jotai" import { atomWithStorage } from "jotai/utils" import { THEMES, Theme } from "@/lib/themes" type ThemesConfig = { activeTheme: Theme } const configAtom = atomWithStorage<ThemesConfig>("themes:config", { activeTheme: THEMES[0], }) export function useThemesConfig() { const [themesConfig, setThemesConfig] = useAtom(configAtom) return { themesConfig, setThemesConfig } }
shadcn-ui/ui/apps/www/hooks/use-themes-config.ts
{ "file_path": "shadcn-ui/ui/apps/www/hooks/use-themes-config.ts", "repo_id": "shadcn-ui/ui", "token_count": 141 }
129
import { createContentlayerPlugin } from "next-contentlayer2" /** @type {import('next').NextConfig} */ const nextConfig = { reactStrictMode: true, swcMinify: true, images: { remotePatterns: [ { protocol: "https", hostname: "avatars.githubusercontent.com", }, { protocol: "https", hostname: "images.unsplash.com", }, ], }, redirects() { return [ { source: "/components", destination: "/docs/components/accordion", permanent: true, }, { source: "/docs/components", destination: "/docs/components/accordion", permanent: true, }, { source: "/examples", destination: "/examples/mail", permanent: false, }, { source: "/docs/primitives/:path*", destination: "/docs/components/:path*", permanent: true, }, { source: "/figma", destination: "/docs/figma", permanent: true, }, { source: "/docs/forms", destination: "/docs/components/form", permanent: false, }, { source: "/docs/forms/react-hook-form", destination: "/docs/components/form", permanent: false, }, ] }, } const withContentlayer = createContentlayerPlugin({ // Additional Contentlayer config options }) export default withContentlayer(nextConfig)
shadcn-ui/ui/apps/www/next.config.mjs
{ "file_path": "shadcn-ui/ui/apps/www/next.config.mjs", "repo_id": "shadcn-ui/ui", "token_count": 649 }
130
import Link from "next/link" 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" export const description = "A login form with email and password. There's an option to login with Google and a link to sign up if you don't have an account." export const iframeHeight = "600px" export const containerClassName = "w-full h-screen flex items-center justify-center px-4" export default function LoginForm() { return ( <Card className="mx-auto max-w-sm"> <CardHeader> <CardTitle className="text-2xl">Login</CardTitle> <CardDescription> Enter your email below to login to your account </CardDescription> </CardHeader> <CardContent> <div className="grid gap-4"> <div className="grid gap-2"> <Label htmlFor="email">Email</Label> <Input id="email" type="email" placeholder="[email protected]" required /> </div> <div className="grid gap-2"> <div className="flex items-center"> <Label htmlFor="password">Password</Label> <Link href="#" className="ml-auto inline-block text-sm underline"> Forgot your password? </Link> </div> <Input id="password" type="password" required /> </div> <Button type="submit" className="w-full"> Login </Button> <Button variant="outline" className="w-full"> Login with Google </Button> </div> <div className="mt-4 text-center text-sm"> Don&apos;t have an account?{" "} <Link href="#" className="underline"> Sign up </Link> </div> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/authentication-02.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/authentication-02.tsx", "repo_id": "shadcn-ui/ui", "token_count": 915 }
131
"use client" import * as React from "react" import { Bar, BarChart, CartesianGrid, XAxis } from "recharts" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/registry/default/ui/chart" export const description = "An interactive bar 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 = { views: { label: "Page Views", }, desktop: { label: "Desktop", color: "hsl(var(--chart-1))", }, mobile: { label: "Mobile", color: "hsl(var(--chart-2))", }, } satisfies ChartConfig export default function Component() { const [activeChart, setActiveChart] = React.useState<keyof typeof chartConfig>("desktop") const total = React.useMemo( () => ({ desktop: chartData.reduce((acc, curr) => acc + curr.desktop, 0), mobile: chartData.reduce((acc, curr) => acc + curr.mobile, 0), }), [] ) return ( <Card> <CardHeader className="flex flex-col items-stretch space-y-0 border-b p-0 sm:flex-row"> <div className="flex flex-1 flex-col justify-center gap-1 px-6 py-5 sm:py-6"> <CardTitle>Bar Chart - Interactive</CardTitle> <CardDescription> Showing total visitors for the last 3 months </CardDescription> </div> <div className="flex"> {["desktop", "mobile"].map((key) => { const chart = key as keyof typeof chartConfig return ( <button key={chart} data-active={activeChart === chart} className="relative z-30 flex flex-1 flex-col justify-center gap-1 border-t px-6 py-4 text-left even:border-l data-[active=true]:bg-muted/50 sm:border-l sm:border-t-0 sm:px-8 sm:py-6" onClick={() => setActiveChart(chart)} > <span className="text-xs text-muted-foreground"> {chartConfig[chart].label} </span> <span className="text-lg font-bold leading-none sm:text-3xl"> {total[key as keyof typeof total].toLocaleString()} </span> </button> ) })} </div> </CardHeader> <CardContent className="px-2 sm:p-6"> <ChartContainer config={chartConfig} className="aspect-auto h-[250px] w-full" > <BarChart accessibilityLayer data={chartData} margin={{ left: 12, right: 12, }} > <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 content={ <ChartTooltipContent className="w-[150px]" nameKey="views" labelFormatter={(value) => { return new Date(value).toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric", }) }} /> } /> <Bar dataKey={activeChart} fill={`var(--color-${activeChart})`} /> </BarChart> </ChartContainer> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/chart-bar-interactive.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/chart-bar-interactive.tsx", "repo_id": "shadcn-ui/ui", "token_count": 3883 }
132
"use client" import { TrendingUp } from "lucide-react" import { CartesianGrid, Line, LineChart, XAxis } from "recharts" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/registry/default/ui/chart" export const description = "A line chart with step" const chartData = [ { month: "January", desktop: 186 }, { month: "February", desktop: 305 }, { month: "March", desktop: 237 }, { month: "April", desktop: 73 }, { month: "May", desktop: 209 }, { month: "June", desktop: 214 }, ] const chartConfig = { desktop: { label: "Desktop", color: "hsl(var(--chart-1))", }, } satisfies ChartConfig export default function Component() { return ( <Card> <CardHeader> <CardTitle>Line Chart - Step</CardTitle> <CardDescription>January - June 2024</CardDescription> </CardHeader> <CardContent> <ChartContainer config={chartConfig}> <LineChart accessibilityLayer data={chartData} margin={{ left: 12, right: 12, }} > <CartesianGrid vertical={false} /> <XAxis dataKey="month" tickLine={false} axisLine={false} tickMargin={8} tickFormatter={(value) => value.slice(0, 3)} /> <ChartTooltip cursor={false} content={<ChartTooltipContent hideLabel />} /> <Line dataKey="desktop" type="step" stroke="var(--color-desktop)" strokeWidth={2} dot={false} /> </LineChart> </ChartContainer> </CardContent> <CardFooter className="flex-col items-start gap-2 text-sm"> <div className="flex gap-2 font-medium leading-none"> Trending up by 5.2% this month <TrendingUp className="h-4 w-4" /> </div> <div className="leading-none text-muted-foreground"> Showing total visitors for the last 6 months </div> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/chart-line-step.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/chart-line-step.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1059 }
133
"use client" import { Bar, BarChart, XAxis } from "recharts" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { ChartConfig, ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/registry/default/ui/chart" export const description = "A stacked bar chart with a legend" const chartData = [ { date: "2024-07-15", running: 450, swimming: 300 }, { date: "2024-07-16", running: 380, swimming: 420 }, { date: "2024-07-17", running: 520, swimming: 120 }, { date: "2024-07-18", running: 140, swimming: 550 }, { date: "2024-07-19", running: 600, swimming: 350 }, { date: "2024-07-20", running: 480, swimming: 400 }, ] const chartConfig = { running: { label: "Running", color: "hsl(var(--chart-1))", }, swimming: { label: "Swimming", color: "hsl(var(--chart-2))", }, } satisfies ChartConfig export default function Component() { return ( <Card> <CardHeader> <CardTitle>Tooltip - Advanced</CardTitle> <CardDescription> Tooltip with custom formatter and total. </CardDescription> </CardHeader> <CardContent> <ChartContainer config={chartConfig}> <BarChart accessibilityLayer data={chartData}> <XAxis dataKey="date" tickLine={false} tickMargin={10} axisLine={false} tickFormatter={(value) => { return new Date(value).toLocaleDateString("en-US", { weekday: "short", }) }} /> <Bar dataKey="running" stackId="a" fill="var(--color-running)" radius={[0, 0, 4, 4]} /> <Bar dataKey="swimming" stackId="a" fill="var(--color-swimming)" radius={[4, 4, 0, 0]} /> <ChartTooltip content={ <ChartTooltipContent hideLabel className="w-[180px]" formatter={(value, name, item, index) => ( <> <div className="h-2.5 w-2.5 shrink-0 rounded-[2px] bg-[--color-bg]" style={ { "--color-bg": `var(--color-${name})`, } as React.CSSProperties } /> {chartConfig[name as keyof typeof chartConfig]?.label || name} <div className="ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground"> {value} <span className="font-normal text-muted-foreground"> kcal </span> </div> {/* Add this after the last item */} {index === 1 && ( <div className="mt-1.5 flex basis-full items-center border-t pt-1.5 text-xs font-medium text-foreground"> Total <div className="ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground"> {item.payload.running + item.payload.swimming} <span className="font-normal text-muted-foreground"> kcal </span> </div> </div> )} </> )} /> } cursor={false} defaultIndex={1} /> </BarChart> </ChartContainer> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/chart-tooltip-advanced.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/chart-tooltip-advanced.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2220 }
134
"use client" import { Area, AreaChart, XAxis, YAxis } from "recharts" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { ChartContainer, ChartTooltip, ChartTooltipContent, } from "@/registry/default/ui/chart" export default function Component() { return ( <Card className="max-w-xs" x-chunk="charts-01-chunk-7"> <CardHeader className="space-y-0 pb-0"> <CardDescription>Time in Bed</CardDescription> <CardTitle className="flex items-baseline gap-1 text-4xl tabular-nums"> 8 <span className="font-sans text-sm font-normal tracking-normal text-muted-foreground"> hr </span> 35 <span className="font-sans text-sm font-normal tracking-normal text-muted-foreground"> min </span> </CardTitle> </CardHeader> <CardContent className="p-0"> <ChartContainer config={{ time: { label: "Time", color: "hsl(var(--chart-2))", }, }} > <AreaChart accessibilityLayer data={[ { date: "2024-01-01", time: 8.5, }, { date: "2024-01-02", time: 7.2, }, { date: "2024-01-03", time: 8.1, }, { date: "2024-01-04", time: 6.2, }, { date: "2024-01-05", time: 5.2, }, { date: "2024-01-06", time: 8.1, }, { date: "2024-01-07", time: 7.0, }, ]} margin={{ left: 0, right: 0, top: 0, bottom: 0, }} > <XAxis dataKey="date" hide /> <YAxis domain={["dataMin - 5", "dataMax + 2"]} hide /> <defs> <linearGradient id="fillTime" x1="0" y1="0" x2="0" y2="1"> <stop offset="5%" stopColor="var(--color-time)" stopOpacity={0.8} /> <stop offset="95%" stopColor="var(--color-time)" stopOpacity={0.1} /> </linearGradient> </defs> <Area dataKey="time" type="natural" fill="url(#fillTime)" fillOpacity={0.4} stroke="var(--color-time)" /> <ChartTooltip cursor={false} content={<ChartTooltipContent hideLabel />} formatter={(value) => ( <div className="flex min-w-[120px] items-center text-xs text-muted-foreground"> Time in bed <div className="ml-auto flex items-baseline gap-0.5 font-mono font-medium tabular-nums text-foreground"> {value} <span className="font-normal text-muted-foreground"> hr </span> </div> </div> )} /> </AreaChart> </ChartContainer> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/charts-01-chunk-7.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/charts-01-chunk-7.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2160 }
135
"use client" import { Button } from "@/registry/default/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { Input } from "@/registry/default/ui/input" export default function Component() { return ( <Card x-chunk="dashboard-04-chunk-1"> <CardHeader> <CardTitle>Store Name</CardTitle> <CardDescription> Used to identify your store in the marketplace. </CardDescription> </CardHeader> <CardContent> <form> <Input placeholder="Store Name" /> </form> </CardContent> <CardFooter className="border-t px-6 py-4"> <Button>Save</Button> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/dashboard-04-chunk-1.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-04-chunk-1.tsx", "repo_id": "shadcn-ui/ui", "token_count": 323 }
136
"use client" import { Button } from "@/registry/default/ui/button" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/default/ui/card" export default function Component() { return ( <Card x-chunk="dashboard-07-chunk-5"> <CardHeader> <CardTitle>Archive Product</CardTitle> <CardDescription> Lipsum dolor sit amet, consectetur adipiscing elit. </CardDescription> </CardHeader> <CardContent> <div></div> <Button size="sm" variant="secondary"> Archive Product </Button> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/block/dashboard-07-chunk-5.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-07-chunk-5.tsx", "repo_id": "shadcn-ui/ui", "token_count": 275 }
137
import { AlertCircle } from "lucide-react" import { Alert, AlertDescription, AlertTitle, } from "@/registry/default/ui/alert" export default function AlertDestructive() { return ( <Alert variant="destructive"> <AlertCircle className="h-4 w-4" /> <AlertTitle>Error</AlertTitle> <AlertDescription> Your session has expired. Please log in again. </AlertDescription> </Alert> ) }
shadcn-ui/ui/apps/www/registry/default/example/alert-destructive.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/alert-destructive.tsx", "repo_id": "shadcn-ui/ui", "token_count": 159 }
138
import { Button } from "@/registry/default/ui/button" export default function ButtonDestructive() { return <Button variant="destructive">Destructive</Button> }
shadcn-ui/ui/apps/www/registry/default/example/button-destructive.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/button-destructive.tsx", "repo_id": "shadcn-ui/ui", "token_count": 46 }
139
"use client" import { Button } from "@/registry/default/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/default/ui/card" import { Label } from "@/registry/default/ui/label" import { Switch } from "@/registry/default/ui/switch" export function CardsCookieSettings() { return ( <Card> <CardHeader> <CardTitle>Cookie Settings</CardTitle> <CardDescription>Manage your cookie settings here.</CardDescription> </CardHeader> <CardContent className="grid gap-6"> <div className="flex items-center justify-between space-x-4"> <Label htmlFor="necessary" className="flex flex-col space-y-1"> <span>Strictly Necessary</span> <span className="text-xs font-normal leading-snug text-muted-foreground"> These cookies are essential in order to use the website and use its features. </span> </Label> <Switch id="necessary" defaultChecked aria-label="Necessary" /> </div> <div className="flex items-center justify-between space-x-4"> <Label htmlFor="functional" className="flex flex-col space-y-1"> <span>Functional Cookies</span> <span className="text-xs font-normal leading-snug text-muted-foreground"> These cookies allow the website to provide personalized functionality. </span> </Label> <Switch id="functional" aria-label="Functional" /> </div> <div className="flex items-center justify-between space-x-4"> <Label htmlFor="performance" className="flex flex-col space-y-1"> <span>Performance Cookies</span> <span className="text-xs font-normal leading-snug text-muted-foreground"> These cookies help to improve the performance of the website. </span> </Label> <Switch id="performance" aria-label="Performance" /> </div> </CardContent> <CardFooter> <Button variant="outline" className="w-full"> Save preferences </Button> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/registry/default/example/cards/cookie-settings.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/cards/cookie-settings.tsx", "repo_id": "shadcn-ui/ui", "token_count": 932 }
140
"use client" import * as React from "react" import { useMediaQuery } from "@/hooks/use-media-query" import { Button } from "@/registry/default/ui/button" import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/registry/default/ui/command" import { Drawer, DrawerContent, DrawerTrigger, } from "@/registry/default/ui/drawer" import { Popover, PopoverContent, PopoverTrigger, } from "@/registry/default/ui/popover" type Status = { value: string label: string } const statuses: Status[] = [ { value: "backlog", label: "Backlog", }, { value: "todo", label: "Todo", }, { value: "in progress", label: "In Progress", }, { value: "done", label: "Done", }, { value: "canceled", label: "Canceled", }, ] export default function ComboBoxResponsive() { const [open, setOpen] = React.useState(false) const isDesktop = useMediaQuery("(min-width: 768px)") const [selectedStatus, setSelectedStatus] = React.useState<Status | null>( null ) if (isDesktop) { return ( <Popover open={open} onOpenChange={setOpen}> <PopoverTrigger asChild> <Button variant="outline" className="w-[150px] justify-start"> {selectedStatus ? <>{selectedStatus.label}</> : <>+ Set status</>} </Button> </PopoverTrigger> <PopoverContent className="w-[200px] p-0" align="start"> <StatusList setOpen={setOpen} setSelectedStatus={setSelectedStatus} /> </PopoverContent> </Popover> ) } return ( <Drawer open={open} onOpenChange={setOpen}> <DrawerTrigger asChild> <Button variant="outline" className="w-[150px] justify-start"> {selectedStatus ? <>{selectedStatus.label}</> : <>+ Set status</>} </Button> </DrawerTrigger> <DrawerContent> <div className="mt-4 border-t"> <StatusList setOpen={setOpen} setSelectedStatus={setSelectedStatus} /> </div> </DrawerContent> </Drawer> ) } function StatusList({ setOpen, setSelectedStatus, }: { setOpen: (open: boolean) => void setSelectedStatus: (status: Status | null) => void }) { return ( <Command> <CommandInput placeholder="Filter status..." /> <CommandList> <CommandEmpty>No results found.</CommandEmpty> <CommandGroup> {statuses.map((status) => ( <CommandItem key={status.value} value={status.value} onSelect={(value) => { setSelectedStatus( statuses.find((priority) => priority.value === value) || null ) setOpen(false) }} > {status.label} </CommandItem> ))} </CommandGroup> </CommandList> </Command> ) }
shadcn-ui/ui/apps/www/registry/default/example/combobox-responsive.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/combobox-responsive.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1267 }
141
import { CalendarDays } from "lucide-react" import { Avatar, AvatarFallback, AvatarImage, } from "@/registry/default/ui/avatar" import { Button } from "@/registry/default/ui/button" import { HoverCard, HoverCardContent, HoverCardTrigger, } from "@/registry/default/ui/hover-card" export default function HoverCardDemo() { return ( <HoverCard> <HoverCardTrigger asChild> <Button variant="link">@nextjs</Button> </HoverCardTrigger> <HoverCardContent className="w-80"> <div className="flex justify-between space-x-4"> <Avatar> <AvatarImage src="https://github.com/vercel.png" /> <AvatarFallback>VC</AvatarFallback> </Avatar> <div className="space-y-1"> <h4 className="text-sm font-semibold">@nextjs</h4> <p className="text-sm"> The React Framework created and maintained by @vercel. </p> <div className="flex items-center pt-2"> <CalendarDays className="mr-2 h-4 w-4 opacity-70" />{" "} <span className="text-xs text-muted-foreground"> Joined December 2021 </span> </div> </div> </div> </HoverCardContent> </HoverCard> ) }
shadcn-ui/ui/apps/www/registry/default/example/hover-card-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/hover-card-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 606 }
142
"use client" import * as React from "react" import Link from "next/link" import { cn } from "@/lib/utils" import { Icons } from "@/components/icons" import { NavigationMenu, NavigationMenuContent, NavigationMenuItem, NavigationMenuLink, NavigationMenuList, NavigationMenuTrigger, navigationMenuTriggerStyle, } from "@/registry/default/ui/navigation-menu" const components: { title: string; href: string; description: string }[] = [ { title: "Alert Dialog", href: "/docs/primitives/alert-dialog", description: "A modal dialog that interrupts the user with important content and expects a response.", }, { title: "Hover Card", href: "/docs/primitives/hover-card", description: "For sighted users to preview content available behind a link.", }, { title: "Progress", href: "/docs/primitives/progress", description: "Displays an indicator showing the completion progress of a task, typically displayed as a progress bar.", }, { title: "Scroll-area", href: "/docs/primitives/scroll-area", description: "Visually or semantically separates content.", }, { title: "Tabs", href: "/docs/primitives/tabs", description: "A set of layered sections of contentknown as tab panelsthat are displayed one at a time.", }, { title: "Tooltip", href: "/docs/primitives/tooltip", description: "A popup that displays information related to an element when the element receives keyboard focus or the mouse hovers over it.", }, ] export default function NavigationMenuDemo() { return ( <NavigationMenu> <NavigationMenuList> <NavigationMenuItem> <NavigationMenuTrigger>Getting started</NavigationMenuTrigger> <NavigationMenuContent> <ul className="grid gap-3 p-6 md:w-[400px] lg:w-[500px] lg:grid-cols-[.75fr_1fr]"> <li className="row-span-3"> <NavigationMenuLink asChild> <a className="flex h-full w-full select-none flex-col justify-end rounded-md bg-gradient-to-b from-muted/50 to-muted p-6 no-underline outline-none focus:shadow-md" href="/" > <Icons.logo className="h-6 w-6" /> <div className="mb-2 mt-4 text-lg font-medium"> shadcn/ui </div> <p className="text-sm leading-tight text-muted-foreground"> Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source. </p> </a> </NavigationMenuLink> </li> <ListItem href="/docs" title="Introduction"> Re-usable components built using Radix UI and Tailwind CSS. </ListItem> <ListItem href="/docs/installation" title="Installation"> How to install dependencies and structure your app. </ListItem> <ListItem href="/docs/primitives/typography" title="Typography"> Styles for headings, paragraphs, lists...etc </ListItem> </ul> </NavigationMenuContent> </NavigationMenuItem> <NavigationMenuItem> <NavigationMenuTrigger>Components</NavigationMenuTrigger> <NavigationMenuContent> <ul className="grid w-[400px] gap-3 p-4 md:w-[500px] md:grid-cols-2 lg:w-[600px] "> {components.map((component) => ( <ListItem key={component.title} title={component.title} href={component.href} > {component.description} </ListItem> ))} </ul> </NavigationMenuContent> </NavigationMenuItem> <NavigationMenuItem> <Link href="/docs" legacyBehavior passHref> <NavigationMenuLink className={navigationMenuTriggerStyle()}> Documentation </NavigationMenuLink> </Link> </NavigationMenuItem> </NavigationMenuList> </NavigationMenu> ) } const ListItem = React.forwardRef< React.ElementRef<"a">, React.ComponentPropsWithoutRef<"a"> >(({ className, title, children, ...props }, ref) => { return ( <li> <NavigationMenuLink asChild> <a ref={ref} className={cn( "block select-none space-y-1 rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground", className )} {...props} > <div className="text-sm font-medium leading-none">{title}</div> <p className="line-clamp-2 text-sm leading-snug text-muted-foreground"> {children} </p> </a> </NavigationMenuLink> </li> ) }) ListItem.displayName = "ListItem"
shadcn-ui/ui/apps/www/registry/default/example/navigation-menu-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/navigation-menu-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2308 }
143
import { Button } from "@/registry/default/ui/button" import { Input } from "@/registry/default/ui/input" import { Label } from "@/registry/default/ui/label" import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle, SheetTrigger, } from "@/registry/default/ui/sheet" export default function SheetDemo() { return ( <Sheet> <SheetTrigger asChild> <Button variant="outline">Open</Button> </SheetTrigger> <SheetContent> <SheetHeader> <SheetTitle>Edit profile</SheetTitle> <SheetDescription> Make changes to your profile here. Click save when you're done. </SheetDescription> </SheetHeader> <div className="grid gap-4 py-4"> <div className="grid grid-cols-4 items-center gap-4"> <Label htmlFor="name" className="text-right"> Name </Label> <Input id="name" value="Pedro Duarte" className="col-span-3" /> </div> <div className="grid grid-cols-4 items-center gap-4"> <Label htmlFor="username" className="text-right"> Username </Label> <Input id="username" value="@peduarte" className="col-span-3" /> </div> </div> <SheetFooter> <SheetClose asChild> <Button type="submit">Save changes</Button> </SheetClose> </SheetFooter> </SheetContent> </Sheet> ) }
shadcn-ui/ui/apps/www/registry/default/example/sheet-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/sheet-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 693 }
144
"use client" import { useToast } from "@/registry/default/hooks/use-toast" import { Button } from "@/registry/default/ui/button" import { ToastAction } from "@/registry/default/ui/toast" export default function ToastDemo() { const { toast } = useToast() return ( <Button variant="outline" onClick={() => { toast({ title: "Scheduled: Catch up ", description: "Friday, February 10, 2023 at 5:57 PM", action: ( <ToastAction altText="Goto schedule to undo">Undo</ToastAction> ), }) }} > Add to calendar </Button> ) }
shadcn-ui/ui/apps/www/registry/default/example/toast-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/toast-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 273 }
145
import { Italic } from "lucide-react" import { Toggle } from "@/registry/default/ui/toggle" export default function ToggleWithText() { return ( <Toggle aria-label="Toggle italic"> <Italic className="mr-2 h-4 w-4" /> Italic </Toggle> ) }
shadcn-ui/ui/apps/www/registry/default/example/toggle-with-text.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/example/toggle-with-text.tsx", "repo_id": "shadcn-ui/ui", "token_count": 108 }
146
import * as React from "react" const MOBILE_BREAKPOINT = 768 export function useIsMobile() { const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined) React.useEffect(() => { const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`) const onChange = () => { setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) } mql.addEventListener("change", onChange) setIsMobile(window.innerWidth < MOBILE_BREAKPOINT) return () => mql.removeEventListener("change", onChange) }, []) return isMobile }
shadcn-ui/ui/apps/www/registry/default/hooks/use-mobile.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/hooks/use-mobile.tsx", "repo_id": "shadcn-ui/ui", "token_count": 210 }
147
"use client" import * as CollapsiblePrimitive from "@radix-ui/react-collapsible" const Collapsible = CollapsiblePrimitive.Root const CollapsibleTrigger = CollapsiblePrimitive.CollapsibleTrigger const CollapsibleContent = CollapsiblePrimitive.CollapsibleContent export { Collapsible, CollapsibleTrigger, CollapsibleContent }
shadcn-ui/ui/apps/www/registry/default/ui/collapsible.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/ui/collapsible.tsx", "repo_id": "shadcn-ui/ui", "token_count": 96 }
148
"use client" import * as React from "react" import * as RadioGroupPrimitive from "@radix-ui/react-radio-group" import { Circle } from "lucide-react" import { cn } from "@/lib/utils" const RadioGroup = React.forwardRef< React.ElementRef<typeof RadioGroupPrimitive.Root>, React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root> >(({ className, ...props }, ref) => { return ( <RadioGroupPrimitive.Root className={cn("grid gap-2", className)} {...props} ref={ref} /> ) }) RadioGroup.displayName = RadioGroupPrimitive.Root.displayName const RadioGroupItem = React.forwardRef< React.ElementRef<typeof RadioGroupPrimitive.Item>, React.ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item> >(({ className, ...props }, ref) => { return ( <RadioGroupPrimitive.Item ref={ref} className={cn( "aspect-square h-4 w-4 rounded-full border border-primary text-primary ring-offset-background focus:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className )} {...props} > <RadioGroupPrimitive.Indicator className="flex items-center justify-center"> <Circle className="h-2.5 w-2.5 fill-current text-current" /> </RadioGroupPrimitive.Indicator> </RadioGroupPrimitive.Item> ) }) RadioGroupItem.displayName = RadioGroupPrimitive.Item.displayName export { RadioGroup, RadioGroupItem }
shadcn-ui/ui/apps/www/registry/default/ui/radio-group.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/ui/radio-group.tsx", "repo_id": "shadcn-ui/ui", "token_count": 530 }
149
"use client" import * as React from "react" import * as TogglePrimitive from "@radix-ui/react-toggle" import { cva, type VariantProps } from "class-variance-authority" import { cn } from "@/lib/utils" const toggleVariants = cva( "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground", { variants: { variant: { default: "bg-transparent", outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground", }, size: { default: "h-10 px-3", sm: "h-9 px-2.5", lg: "h-11 px-5", }, }, defaultVariants: { variant: "default", size: "default", }, } ) const Toggle = React.forwardRef< React.ElementRef<typeof TogglePrimitive.Root>, React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants> >(({ className, variant, size, ...props }, ref) => ( <TogglePrimitive.Root ref={ref} className={cn(toggleVariants({ variant, size, className }))} {...props} /> )) Toggle.displayName = TogglePrimitive.Root.displayName export { Toggle, toggleVariants }
shadcn-ui/ui/apps/www/registry/default/ui/toggle.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/default/ui/toggle.tsx", "repo_id": "shadcn-ui/ui", "token_count": 556 }
150
"use client" import { TrendingUp } from "lucide-react" import { Label, PolarGrid, PolarRadiusAxis, RadialBar, RadialBarChart, } from "recharts" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" import { ChartConfig, ChartContainer } from "@/registry/new-york/ui/chart" export const description = "A radial chart with a custom shape" const chartData = [ { browser: "safari", visitors: 1260, fill: "var(--color-safari)" }, ] const chartConfig = { visitors: { label: "Visitors", }, safari: { label: "Safari", color: "hsl(var(--chart-2))", }, } satisfies ChartConfig export default function Component() { return ( <Card className="flex flex-col"> <CardHeader className="items-center pb-0"> <CardTitle>Radial Chart - Shape</CardTitle> <CardDescription>January - June 2024</CardDescription> </CardHeader> <CardContent className="flex-1 pb-0"> <ChartContainer config={chartConfig} className="mx-auto aspect-square max-h-[250px]" > <RadialBarChart data={chartData} endAngle={100} innerRadius={80} outerRadius={140} > <PolarGrid gridType="circle" radialLines={false} stroke="none" className="first:fill-muted last:fill-background" polarRadius={[86, 74]} /> <RadialBar dataKey="visitors" background /> <PolarRadiusAxis tick={false} tickLine={false} axisLine={false}> <Label content={({ viewBox }) => { if (viewBox && "cx" in viewBox && "cy" in viewBox) { return ( <text x={viewBox.cx} y={viewBox.cy} textAnchor="middle" dominantBaseline="middle" > <tspan x={viewBox.cx} y={viewBox.cy} className="fill-foreground text-4xl font-bold" > {chartData[0].visitors.toLocaleString()} </tspan> <tspan x={viewBox.cx} y={(viewBox.cy || 0) + 24} className="fill-muted-foreground" > Visitors </tspan> </text> ) } }} /> </PolarRadiusAxis> </RadialBarChart> </ChartContainer> </CardContent> <CardFooter className="flex-col gap-2 text-sm"> <div className="flex items-center gap-2 font-medium leading-none"> Trending up by 5.2% this month <TrendingUp className="h-4 w-4" /> </div> <div className="leading-none text-muted-foreground"> Showing total visitors for the last 6 months </div> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/registry/new-york/block/chart-radial-shape.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/block/chart-radial-shape.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1773 }
151
"use client" import { Bar, BarChart, Rectangle, XAxis } from "recharts" import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/registry/new-york//ui/card" import { ChartContainer } from "@/registry/new-york//ui/chart" export default function Component() { return ( <Card className="max-w-xs" x-chunk="charts-01-chunk-3"> <CardHeader className="p-4 pb-0"> <CardTitle>Walking Distance</CardTitle> <CardDescription> Over the last 7 days, your distance walked and run was 12.5 miles per day. </CardDescription> </CardHeader> <CardContent className="flex flex-row items-baseline gap-4 p-4 pt-0"> <div className="flex items-baseline gap-1 text-3xl font-bold tabular-nums leading-none"> 12.5 <span className="text-sm font-normal text-muted-foreground"> miles/day </span> </div> <ChartContainer config={{ steps: { label: "Steps", color: "hsl(var(--chart-1))", }, }} className="ml-auto w-[72px]" > <BarChart accessibilityLayer margin={{ left: 0, right: 0, top: 0, bottom: 0, }} data={[ { date: "2024-01-01", steps: 2000, }, { date: "2024-01-02", steps: 2100, }, { date: "2024-01-03", steps: 2200, }, { date: "2024-01-04", steps: 1300, }, { date: "2024-01-05", steps: 1400, }, { date: "2024-01-06", steps: 2500, }, { date: "2024-01-07", steps: 1600, }, ]} > <Bar dataKey="steps" fill="var(--color-steps)" radius={2} fillOpacity={0.2} activeIndex={6} activeBar={<Rectangle fillOpacity={0.8} />} /> <XAxis dataKey="date" tickLine={false} axisLine={false} tickMargin={4} hide /> </BarChart> </ChartContainer> </CardContent> </Card> ) }
shadcn-ui/ui/apps/www/registry/new-york/block/charts-01-chunk-3.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/block/charts-01-chunk-3.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1564 }
152
"use client" import { Bird, Rabbit, Turtle } from "lucide-react" import { Input } from "@/registry/new-york/ui/input" import { Label } from "@/registry/new-york/ui/label" import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "@/registry/new-york/ui/select" import { Textarea } from "@/registry/new-york/ui/textarea" export default function Component() { return ( <div className="relative hidden flex-col items-start gap-8 md:flex" x-chunk="dashboard-03-chunk-0" > <form className="grid w-full items-start gap-6"> <fieldset className="grid gap-6 rounded-lg border p-4"> <legend className="-ml-1 px-1 text-sm font-medium">Settings</legend> <div className="grid gap-3"> <Label htmlFor="model">Model</Label> <Select> <SelectTrigger id="model" className="items-start [&_[data-description]]:hidden" > <SelectValue placeholder="Select a model" /> </SelectTrigger> <SelectContent> <SelectItem value="genesis"> <div className="flex items-start gap-3 text-muted-foreground"> <Rabbit className="size-5" /> <div className="grid gap-0.5"> <p> Neural{" "} <span className="font-medium text-foreground"> Genesis </span> </p> <p className="text-xs" data-description> Our fastest model for general use cases. </p> </div> </div> </SelectItem> <SelectItem value="explorer"> <div className="flex items-start gap-3 text-muted-foreground"> <Bird className="size-5" /> <div className="grid gap-0.5"> <p> Neural{" "} <span className="font-medium text-foreground"> Explorer </span> </p> <p className="text-xs" data-description> Performance and speed for efficiency. </p> </div> </div> </SelectItem> <SelectItem value="quantum"> <div className="flex items-start gap-3 text-muted-foreground"> <Turtle className="size-5" /> <div className="grid gap-0.5"> <p> Neural{" "} <span className="font-medium text-foreground"> Quantum </span> </p> <p className="text-xs" data-description> The most powerful model for complex computations. </p> </div> </div> </SelectItem> </SelectContent> </Select> </div> <div className="grid gap-3"> <Label htmlFor="temperature">Temperature</Label> <Input id="temperature" type="number" placeholder="0.4" /> </div> <div className="grid grid-cols-2 gap-4"> <div className="grid gap-3"> <Label htmlFor="top-p">Top P</Label> <Input id="top-p" type="number" placeholder="0.7" /> </div> <div className="grid gap-3"> <Label htmlFor="top-k">Top K</Label> <Input id="top-k" type="number" placeholder="0.0" /> </div> </div> </fieldset> <fieldset className="grid gap-6 rounded-lg border p-4"> <legend className="-ml-1 px-1 text-sm font-medium">Messages</legend> <div className="grid gap-3"> <Label htmlFor="role">Role</Label> <Select defaultValue="system"> <SelectTrigger> <SelectValue placeholder="Select a role" /> </SelectTrigger> <SelectContent> <SelectItem value="system">System</SelectItem> <SelectItem value="user">User</SelectItem> <SelectItem value="assistant">Assistant</SelectItem> </SelectContent> </Select> </div> <div className="grid gap-3"> <Label htmlFor="content">Content</Label> <Textarea id="content" placeholder="You are a..." className="min-h-[9.5rem]" /> </div> </fieldset> </form> </div> ) }
shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-03-chunk-0.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-03-chunk-0.tsx", "repo_id": "shadcn-ui/ui", "token_count": 2733 }
153
"use client" import * as React from "react" import { ChevronsUpDown, Plus } from "lucide-react" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuTrigger, } from "@/registry/new-york/ui/dropdown-menu" export function TeamSwitcher({ teams, }: { teams: { name: string logo: React.ElementType plan: string }[] }) { const [activeTeam, setActiveTeam] = React.useState(teams[0]) return ( <DropdownMenu> <DropdownMenuTrigger className="w-full rounded-md ring-ring hover:bg-accent hover:text-accent-foreground focus-visible:outline-none focus-visible:ring-2 data-[state=open]:bg-accent"> <div className="flex items-center gap-1.5 overflow-hidden px-2 py-1.5 text-left text-sm transition-all"> <div className="flex h-5 w-5 items-center justify-center rounded-sm bg-primary text-primary-foreground"> <activeTeam.logo className="h-3.5 w-3.5 shrink-0" /> </div> <div className="line-clamp-1 flex-1 pr-2 font-medium"> {activeTeam.name} </div> <ChevronsUpDown className="ml-auto h-4 w-4 text-muted-foreground/50" /> </div> </DropdownMenuTrigger> <DropdownMenuContent className="w-64" align="start" side="right" sideOffset={4} > <DropdownMenuLabel className="text-xs text-muted-foreground"> Teams </DropdownMenuLabel> {teams.map((team, index) => ( <DropdownMenuItem key={team.name} onClick={() => setActiveTeam(team)} className="items-start gap-2 px-1.5" > <div className="flex h-8 w-8 items-center justify-center rounded-sm bg-primary text-primary-foreground"> <team.logo className="h-5 w-5 shrink-0" /> </div> <div className="grid flex-1 leading-tight"> <div className="line-clamp-1 font-medium">{team.name}</div> <div className="overflow-hidden text-xs text-muted-foreground"> <div className="line-clamp-1">{team.plan}</div> </div> </div> <DropdownMenuShortcut className="self-center"> {index + 1} </DropdownMenuShortcut> </DropdownMenuItem> ))} <DropdownMenuSeparator /> <DropdownMenuItem className="gap-2 px-1.5"> <div className="flex h-8 w-8 items-center justify-center rounded-md border bg-background"> <Plus className="h-5 w-5" /> </div> <div className="font-medium text-muted-foreground">Add workspace</div> </DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> ) }
shadcn-ui/ui/apps/www/registry/new-york/block/sidebar-01/components/team-switcher.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/block/sidebar-01/components/team-switcher.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1287 }
154
import Link from "next/link" import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from "@/registry/new-york/ui/breadcrumb" export default function BreadcrumbCollapsed() { return ( <Breadcrumb> <BreadcrumbList> <BreadcrumbItem> <BreadcrumbLink asChild> <Link href="/">Home</Link> </BreadcrumbLink> </BreadcrumbItem> <BreadcrumbSeparator /> <BreadcrumbItem> <BreadcrumbEllipsis /> </BreadcrumbItem> <BreadcrumbSeparator /> <BreadcrumbItem> <BreadcrumbLink asChild> <Link href="/docs/components">Components</Link> </BreadcrumbLink> </BreadcrumbItem> <BreadcrumbSeparator /> <BreadcrumbItem> <BreadcrumbPage>Breadcrumb</BreadcrumbPage> </BreadcrumbItem> </BreadcrumbList> </Breadcrumb> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/breadcrumb-ellipsis.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/breadcrumb-ellipsis.tsx", "repo_id": "shadcn-ui/ui", "token_count": 488 }
155
import { BellIcon, CheckIcon } from "@radix-ui/react-icons" import { cn } from "@/lib/utils" import { Button } from "@/registry/new-york/ui/button" import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, } from "@/registry/new-york/ui/card" import { Switch } from "@/registry/new-york/ui/switch" const notifications = [ { title: "Your call has been confirmed.", description: "1 hour ago", }, { title: "You have a new message!", description: "1 hour ago", }, { title: "Your subscription is expiring soon!", description: "2 hours ago", }, ] type CardProps = React.ComponentProps<typeof Card> export default function CardDemo({ className, ...props }: CardProps) { return ( <Card className={cn("w-[380px]", className)} {...props}> <CardHeader> <CardTitle>Notifications</CardTitle> <CardDescription>You have 3 unread messages.</CardDescription> </CardHeader> <CardContent className="grid gap-4"> <div className=" flex items-center space-x-4 rounded-md border p-4"> <BellIcon /> <div className="flex-1 space-y-1"> <p className="text-sm font-medium leading-none"> Push Notifications </p> <p className="text-sm text-muted-foreground"> Send notifications to device. </p> </div> <Switch /> </div> <div> {notifications.map((notification, index) => ( <div key={index} className="mb-4 grid grid-cols-[25px_1fr] items-start pb-4 last:mb-0 last:pb-0" > <span className="flex h-2 w-2 translate-y-1 rounded-full bg-sky-500" /> <div className="space-y-1"> <p className="text-sm font-medium leading-none"> {notification.title} </p> <p className="text-sm text-muted-foreground"> {notification.description} </p> </div> </div> ))} </div> </CardContent> <CardFooter> <Button className="w-full"> <CheckIcon className="mr-2 h-4 w-4" /> Mark all as read </Button> </CardFooter> </Card> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/card-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/card-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1098 }
156
import * as React from "react" import { Card, CardContent } from "@/registry/new-york/ui/card" import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "@/registry/new-york/ui/carousel" export default function CarouselDemo() { return ( <Carousel className="w-full max-w-xs"> <CarouselContent> {Array.from({ length: 5 }).map((_, index) => ( <CarouselItem key={index}> <div className="p-1"> <Card> <CardContent className="flex aspect-square items-center justify-center p-6"> <span className="text-4xl font-semibold">{index + 1}</span> </CardContent> </Card> </div> </CarouselItem> ))} </CarouselContent> <CarouselPrevious /> <CarouselNext /> </Carousel> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/carousel-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/carousel-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 412 }
157
"use client" import * as React from "react" import { CaretSortIcon } from "@radix-ui/react-icons" import { Button } from "@/registry/new-york/ui/button" import { Collapsible, CollapsibleContent, CollapsibleTrigger, } from "@/registry/new-york/ui/collapsible" export default function CollapsibleDemo() { const [isOpen, setIsOpen] = React.useState(false) return ( <Collapsible open={isOpen} onOpenChange={setIsOpen} className="w-[350px] space-y-2" > <div className="flex items-center justify-between space-x-4 px-4"> <h4 className="text-sm font-semibold"> @peduarte starred 3 repositories </h4> <CollapsibleTrigger asChild> <Button variant="ghost" size="sm"> <CaretSortIcon className="h-4 w-4" /> <span className="sr-only">Toggle</span> </Button> </CollapsibleTrigger> </div> <div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm"> @radix-ui/primitives </div> <CollapsibleContent className="space-y-2"> <div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm"> @radix-ui/colors </div> <div className="rounded-md border px-4 py-2 font-mono text-sm shadow-sm"> @stitches/react </div> </CollapsibleContent> </Collapsible> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/collapsible-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/collapsible-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 625 }
158
import * as React from "react" import { MinusIcon, PlusIcon } from "@radix-ui/react-icons" import { Bar, BarChart, ResponsiveContainer } from "recharts" import { Button } from "@/registry/new-york/ui/button" import { Drawer, DrawerClose, DrawerContent, DrawerDescription, DrawerFooter, DrawerHeader, DrawerTitle, DrawerTrigger, } from "@/registry/new-york/ui/drawer" const data = [ { goal: 400, }, { goal: 300, }, { goal: 200, }, { goal: 300, }, { goal: 200, }, { goal: 278, }, { goal: 189, }, { goal: 239, }, { goal: 300, }, { goal: 200, }, { goal: 278, }, { goal: 189, }, { goal: 349, }, ] export default function DrawerDemo() { const [goal, setGoal] = React.useState(350) function onClick(adjustment: number) { setGoal(Math.max(200, Math.min(400, goal + adjustment))) } return ( <Drawer> <DrawerTrigger asChild> <Button variant="outline">Open Drawer</Button> </DrawerTrigger> <DrawerContent> <div className="mx-auto w-full max-w-sm"> <DrawerHeader> <DrawerTitle>Move Goal</DrawerTitle> <DrawerDescription>Set your daily activity goal.</DrawerDescription> </DrawerHeader> <div className="p-4 pb-0"> <div className="flex items-center justify-center space-x-2"> <Button variant="outline" size="icon" className="h-8 w-8 shrink-0 rounded-full" onClick={() => onClick(-10)} disabled={goal <= 200} > <MinusIcon className="h-4 w-4" /> <span className="sr-only">Decrease</span> </Button> <div className="flex-1 text-center"> <div className="text-7xl font-bold tracking-tighter"> {goal} </div> <div className="text-[0.70rem] uppercase text-muted-foreground"> Calories/day </div> </div> <Button variant="outline" size="icon" className="h-8 w-8 shrink-0 rounded-full" onClick={() => onClick(10)} disabled={goal >= 400} > <PlusIcon className="h-4 w-4" /> <span className="sr-only">Increase</span> </Button> </div> <div className="mt-3 h-[120px]"> <ResponsiveContainer width="100%" height="100%"> <BarChart data={data}> <Bar dataKey="goal" style={ { fill: "hsl(var(--foreground))", opacity: 0.9, } as React.CSSProperties } /> </BarChart> </ResponsiveContainer> </div> </div> <DrawerFooter> <Button>Submit</Button> <DrawerClose asChild> <Button variant="outline">Cancel</Button> </DrawerClose> </DrawerFooter> </div> </DrawerContent> </Drawer> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/drawer-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/drawer-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1810 }
159
import { Input } from "@/registry/new-york/ui/input" import { Label } from "@/registry/new-york/ui/label" export default function InputWithLabel() { return ( <div className="grid w-full max-w-sm items-center gap-1.5"> <Label htmlFor="email">Email</Label> <Input type="email" id="email" placeholder="Email" /> </div> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/input-with-label.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/input-with-label.tsx", "repo_id": "shadcn-ui/ui", "token_count": 131 }
160
import * as React from "react" import Image from "next/image" import { ScrollArea, ScrollBar } from "@/registry/new-york/ui/scroll-area" export interface Artwork { artist: string art: string } export const works: Artwork[] = [ { artist: "Ornella Binni", art: "https://images.unsplash.com/photo-1465869185982-5a1a7522cbcb?auto=format&fit=crop&w=300&q=80", }, { artist: "Tom Byrom", art: "https://images.unsplash.com/photo-1548516173-3cabfa4607e9?auto=format&fit=crop&w=300&q=80", }, { artist: "Vladimir Malyavko", art: "https://images.unsplash.com/photo-1494337480532-3725c85fd2ab?auto=format&fit=crop&w=300&q=80", }, ] export default function ScrollAreaHorizontalDemo() { return ( <ScrollArea className="w-96 whitespace-nowrap rounded-md border"> <div className="flex w-max space-x-4 p-4"> {works.map((artwork) => ( <figure key={artwork.artist} className="shrink-0"> <div className="overflow-hidden rounded-md"> <Image src={artwork.art} alt={`Photo by ${artwork.artist}`} className="aspect-[3/4] h-fit w-fit object-cover" width={300} height={400} /> </div> <figcaption className="pt-2 text-xs text-muted-foreground"> Photo by{" "} <span className="font-semibold text-foreground"> {artwork.artist} </span> </figcaption> </figure> ))} </div> <ScrollBar orientation="horizontal" /> </ScrollArea> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/scroll-area-horizontal-demo.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/scroll-area-horizontal-demo.tsx", "repo_id": "shadcn-ui/ui", "token_count": 791 }
161
import { Textarea } from "@/registry/new-york/ui/textarea" export default function TextareaDisabled() { return <Textarea placeholder="Type your message here." disabled /> }
shadcn-ui/ui/apps/www/registry/new-york/example/textarea-disabled.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/textarea-disabled.tsx", "repo_id": "shadcn-ui/ui", "token_count": 50 }
162
import { FontBoldIcon, FontItalicIcon, UnderlineIcon, } from "@radix-ui/react-icons" import { ToggleGroup, ToggleGroupItem, } from "@/registry/new-york/ui/toggle-group" export default function ToggleGroupDemo() { return ( <ToggleGroup type="single"> <ToggleGroupItem value="bold" aria-label="Toggle bold"> <FontBoldIcon className="h-4 w-4" /> </ToggleGroupItem> <ToggleGroupItem value="italic" aria-label="Toggle italic"> <FontItalicIcon className="h-4 w-4" /> </ToggleGroupItem> <ToggleGroupItem value="strikethrough" aria-label="Toggle strikethrough"> <UnderlineIcon className="h-4 w-4" /> </ToggleGroupItem> </ToggleGroup> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/toggle-group-single.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/toggle-group-single.tsx", "repo_id": "shadcn-ui/ui", "token_count": 300 }
163
export default function TypographyList() { return ( <ul className="my-6 ml-6 list-disc [&>li]:mt-2"> <li>1st level of puns: 5 gold coins</li> <li>2nd level of jokes: 10 gold coins</li> <li>3rd level of one-liners : 20 gold coins</li> </ul> ) }
shadcn-ui/ui/apps/www/registry/new-york/example/typography-list.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/typography-list.tsx", "repo_id": "shadcn-ui/ui", "token_count": 117 }
164
"use client" import * as React from "react" import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons" import { DayPicker } from "react-day-picker" import { cn } from "@/lib/utils" import { buttonVariants } from "@/registry/new-york/ui/button" export type CalendarProps = React.ComponentProps<typeof DayPicker> function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) { return ( <DayPicker showOutsideDays={showOutsideDays} className={cn("p-3", className)} classNames={{ months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0", month: "space-y-4", caption: "flex justify-center pt-1 relative items-center", caption_label: "text-sm font-medium", nav: "space-x-1 flex items-center", nav_button: cn( buttonVariants({ variant: "outline" }), "h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100" ), nav_button_previous: "absolute left-1", nav_button_next: "absolute right-1", table: "w-full border-collapse space-y-1", head_row: "flex", head_cell: "text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]", row: "flex w-full mt-2", cell: cn( "relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md", props.mode === "range" ? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" : "[&:has([aria-selected])]:rounded-md" ), day: cn( buttonVariants({ variant: "ghost" }), "h-8 w-8 p-0 font-normal aria-selected:opacity-100" ), day_range_start: "day-range-start", day_range_end: "day-range-end", day_selected: "bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground", day_today: "bg-accent text-accent-foreground", day_outside: "day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30", day_disabled: "text-muted-foreground opacity-50", day_range_middle: "aria-selected:bg-accent aria-selected:text-accent-foreground", day_hidden: "invisible", ...classNames, }} components={{ IconLeft: ({ ...props }) => <ChevronLeftIcon className="h-4 w-4" />, IconRight: ({ ...props }) => <ChevronRightIcon className="h-4 w-4" />, }} {...props} /> ) } Calendar.displayName = "Calendar" export { Calendar }
shadcn-ui/ui/apps/www/registry/new-york/ui/calendar.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/ui/calendar.tsx", "repo_id": "shadcn-ui/ui", "token_count": 1280 }
165
"use client" import * as React from "react" import { CheckIcon, ChevronRightIcon, DotFilledIcon, } from "@radix-ui/react-icons" import * as MenubarPrimitive from "@radix-ui/react-menubar" import { cn } from "@/lib/utils" const MenubarMenu = MenubarPrimitive.Menu const MenubarGroup = MenubarPrimitive.Group const MenubarPortal = MenubarPrimitive.Portal const MenubarSub = MenubarPrimitive.Sub const MenubarRadioGroup = MenubarPrimitive.RadioGroup const Menubar = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.Root>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Root> >(({ className, ...props }, ref) => ( <MenubarPrimitive.Root ref={ref} className={cn( "flex h-9 items-center space-x-1 rounded-md border bg-background p-1 shadow-sm", className )} {...props} /> )) Menubar.displayName = MenubarPrimitive.Root.displayName const MenubarTrigger = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.Trigger>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Trigger> >(({ className, ...props }, ref) => ( <MenubarPrimitive.Trigger ref={ref} className={cn( "flex cursor-default select-none items-center rounded-sm px-3 py-1 text-sm font-medium outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground", className )} {...props} /> )) MenubarTrigger.displayName = MenubarPrimitive.Trigger.displayName const MenubarSubTrigger = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.SubTrigger>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubTrigger> & { inset?: boolean } >(({ className, inset, children, ...props }, ref) => ( <MenubarPrimitive.SubTrigger ref={ref} className={cn( "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground", inset && "pl-8", className )} {...props} > {children} <ChevronRightIcon className="ml-auto h-4 w-4" /> </MenubarPrimitive.SubTrigger> )) MenubarSubTrigger.displayName = MenubarPrimitive.SubTrigger.displayName const MenubarSubContent = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.SubContent>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.SubContent> >(({ className, ...props }, ref) => ( <MenubarPrimitive.SubContent ref={ref} className={cn( "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className )} {...props} /> )) MenubarSubContent.displayName = MenubarPrimitive.SubContent.displayName const MenubarContent = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.Content>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Content> >( ( { className, align = "start", alignOffset = -4, sideOffset = 8, ...props }, ref ) => ( <MenubarPrimitive.Portal> <MenubarPrimitive.Content ref={ref} align={align} alignOffset={alignOffset} sideOffset={sideOffset} className={cn( "z-50 min-w-[12rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className )} {...props} /> </MenubarPrimitive.Portal> ) ) MenubarContent.displayName = MenubarPrimitive.Content.displayName const MenubarItem = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.Item>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Item> & { inset?: boolean } >(({ className, inset, ...props }, ref) => ( <MenubarPrimitive.Item ref={ref} className={cn( "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", inset && "pl-8", className )} {...props} /> )) MenubarItem.displayName = MenubarPrimitive.Item.displayName const MenubarCheckboxItem = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.CheckboxItem>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.CheckboxItem> >(({ className, children, checked, ...props }, ref) => ( <MenubarPrimitive.CheckboxItem ref={ref} className={cn( "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className )} checked={checked} {...props} > <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <MenubarPrimitive.ItemIndicator> <CheckIcon className="h-4 w-4" /> </MenubarPrimitive.ItemIndicator> </span> {children} </MenubarPrimitive.CheckboxItem> )) MenubarCheckboxItem.displayName = MenubarPrimitive.CheckboxItem.displayName const MenubarRadioItem = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.RadioItem>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.RadioItem> >(({ className, children, ...props }, ref) => ( <MenubarPrimitive.RadioItem ref={ref} className={cn( "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className )} {...props} > <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <MenubarPrimitive.ItemIndicator> <DotFilledIcon className="h-4 w-4 fill-current" /> </MenubarPrimitive.ItemIndicator> </span> {children} </MenubarPrimitive.RadioItem> )) MenubarRadioItem.displayName = MenubarPrimitive.RadioItem.displayName const MenubarLabel = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.Label>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Label> & { inset?: boolean } >(({ className, inset, ...props }, ref) => ( <MenubarPrimitive.Label ref={ref} className={cn( "px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className )} {...props} /> )) MenubarLabel.displayName = MenubarPrimitive.Label.displayName const MenubarSeparator = React.forwardRef< React.ElementRef<typeof MenubarPrimitive.Separator>, React.ComponentPropsWithoutRef<typeof MenubarPrimitive.Separator> >(({ className, ...props }, ref) => ( <MenubarPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} /> )) MenubarSeparator.displayName = MenubarPrimitive.Separator.displayName const MenubarShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => { return ( <span className={cn( "ml-auto text-xs tracking-widest text-muted-foreground", className )} {...props} /> ) } MenubarShortcut.displayname = "MenubarShortcut" export { Menubar, MenubarMenu, MenubarTrigger, MenubarContent, MenubarItem, MenubarSeparator, MenubarLabel, MenubarCheckboxItem, MenubarRadioGroup, MenubarRadioItem, MenubarPortal, MenubarSubContent, MenubarSubTrigger, MenubarGroup, MenubarSub, MenubarShortcut, }
shadcn-ui/ui/apps/www/registry/new-york/ui/menubar.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/ui/menubar.tsx", "repo_id": "shadcn-ui/ui", "token_count": 3124 }
166
"use client" import * as React from "react" import * as TabsPrimitive from "@radix-ui/react-tabs" import { cn } from "@/lib/utils" const Tabs = TabsPrimitive.Root const TabsList = React.forwardRef< React.ElementRef<typeof TabsPrimitive.List>, React.ComponentPropsWithoutRef<typeof TabsPrimitive.List> >(({ className, ...props }, ref) => ( <TabsPrimitive.List ref={ref} className={cn( "inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground", className )} {...props} /> )) TabsList.displayName = TabsPrimitive.List.displayName const TabsTrigger = React.forwardRef< React.ElementRef<typeof TabsPrimitive.Trigger>, React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger> >(({ className, ...props }, ref) => ( <TabsPrimitive.Trigger ref={ref} className={cn( "inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow", className )} {...props} /> )) TabsTrigger.displayName = TabsPrimitive.Trigger.displayName const TabsContent = React.forwardRef< React.ElementRef<typeof TabsPrimitive.Content>, React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content> >(({ className, ...props }, ref) => ( <TabsPrimitive.Content ref={ref} className={cn( "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2", className )} {...props} /> )) TabsContent.displayName = TabsPrimitive.Content.displayName export { Tabs, TabsList, TabsTrigger, TabsContent }
shadcn-ui/ui/apps/www/registry/new-york/ui/tabs.tsx
{ "file_path": "shadcn-ui/ui/apps/www/registry/new-york/ui/tabs.tsx", "repo_id": "shadcn-ui/ui", "token_count": 678 }
167
import { Registry } from "@/registry/schema" export const ui: Registry = [ { name: "accordion", type: "registry:ui", dependencies: ["@radix-ui/react-accordion"], files: ["ui/accordion.tsx"], tailwind: { config: { theme: { extend: { keyframes: { "accordion-down": { from: { height: "0" }, to: { height: "var(--radix-accordion-content-height)" }, }, "accordion-up": { from: { height: "var(--radix-accordion-content-height)" }, to: { height: "0" }, }, }, animation: { "accordion-down": "accordion-down 0.2s ease-out", "accordion-up": "accordion-up 0.2s ease-out", }, }, }, }, }, }, { name: "alert", type: "registry:ui", files: ["ui/alert.tsx"], }, { name: "alert-dialog", type: "registry:ui", dependencies: ["@radix-ui/react-alert-dialog"], registryDependencies: ["button"], files: ["ui/alert-dialog.tsx"], }, { name: "aspect-ratio", type: "registry:ui", dependencies: ["@radix-ui/react-aspect-ratio"], files: ["ui/aspect-ratio.tsx"], }, { name: "avatar", type: "registry:ui", dependencies: ["@radix-ui/react-avatar"], files: ["ui/avatar.tsx"], }, { name: "badge", type: "registry:ui", files: ["ui/badge.tsx"], }, { name: "breadcrumb", type: "registry:ui", dependencies: ["@radix-ui/react-slot"], files: ["ui/breadcrumb.tsx"], }, { name: "button", type: "registry:ui", dependencies: ["@radix-ui/react-slot"], files: ["ui/button.tsx"], }, { name: "calendar", type: "registry:ui", dependencies: ["[email protected]", "date-fns"], registryDependencies: ["button"], files: ["ui/calendar.tsx"], }, { name: "card", type: "registry:ui", files: ["ui/card.tsx"], }, { name: "carousel", type: "registry:ui", files: ["ui/carousel.tsx"], registryDependencies: ["button"], dependencies: ["embla-carousel-react"], }, { name: "chart", type: "registry:ui", files: ["ui/chart.tsx"], registryDependencies: ["card"], dependencies: ["recharts", "lucide-react"], }, { name: "checkbox", type: "registry:ui", dependencies: ["@radix-ui/react-checkbox"], files: ["ui/checkbox.tsx"], }, { name: "collapsible", type: "registry:ui", dependencies: ["@radix-ui/react-collapsible"], files: ["ui/collapsible.tsx"], }, { name: "command", type: "registry:ui", dependencies: ["[email protected]"], registryDependencies: ["dialog"], files: ["ui/command.tsx"], }, { name: "context-menu", type: "registry:ui", dependencies: ["@radix-ui/react-context-menu"], files: ["ui/context-menu.tsx"], }, { name: "dialog", type: "registry:ui", dependencies: ["@radix-ui/react-dialog"], files: ["ui/dialog.tsx"], }, { name: "drawer", type: "registry:ui", dependencies: ["vaul", "@radix-ui/react-dialog"], files: ["ui/drawer.tsx"], }, { name: "dropdown-menu", type: "registry:ui", dependencies: ["@radix-ui/react-dropdown-menu"], files: ["ui/dropdown-menu.tsx"], }, { name: "form", type: "registry:ui", dependencies: [ "@radix-ui/react-label", "@radix-ui/react-slot", "@hookform/resolvers", "zod", "react-hook-form", ], registryDependencies: ["button", "label"], files: ["ui/form.tsx"], }, { name: "hover-card", type: "registry:ui", dependencies: ["@radix-ui/react-hover-card"], files: ["ui/hover-card.tsx"], }, { name: "input", type: "registry:ui", files: ["ui/input.tsx"], }, { name: "input-otp", type: "registry:ui", dependencies: ["input-otp"], files: ["ui/input-otp.tsx"], }, { name: "label", type: "registry:ui", dependencies: ["@radix-ui/react-label"], files: ["ui/label.tsx"], }, { name: "menubar", type: "registry:ui", dependencies: ["@radix-ui/react-menubar"], files: ["ui/menubar.tsx"], }, { name: "navigation-menu", type: "registry:ui", dependencies: ["@radix-ui/react-navigation-menu"], files: ["ui/navigation-menu.tsx"], }, { name: "pagination", type: "registry:ui", registryDependencies: ["button"], files: ["ui/pagination.tsx"], }, { name: "popover", type: "registry:ui", dependencies: ["@radix-ui/react-popover"], files: ["ui/popover.tsx"], }, { name: "progress", type: "registry:ui", dependencies: ["@radix-ui/react-progress"], files: ["ui/progress.tsx"], }, { name: "radio-group", type: "registry:ui", dependencies: ["@radix-ui/react-radio-group"], files: ["ui/radio-group.tsx"], }, { name: "resizable", type: "registry:ui", dependencies: ["react-resizable-panels"], files: ["ui/resizable.tsx"], }, { name: "scroll-area", type: "registry:ui", dependencies: ["@radix-ui/react-scroll-area"], files: ["ui/scroll-area.tsx"], }, { name: "select", type: "registry:ui", dependencies: ["@radix-ui/react-select"], files: ["ui/select.tsx"], }, { name: "separator", type: "registry:ui", dependencies: ["@radix-ui/react-separator"], files: ["ui/separator.tsx"], }, { name: "sheet", type: "registry:ui", dependencies: ["@radix-ui/react-dialog"], files: ["ui/sheet.tsx"], }, { name: "skeleton", type: "registry:ui", files: ["ui/skeleton.tsx"], }, { name: "slider", type: "registry:ui", dependencies: ["@radix-ui/react-slider"], files: ["ui/slider.tsx"], }, { name: "sonner", type: "registry:ui", dependencies: ["sonner", "next-themes"], files: ["ui/sonner.tsx"], }, { name: "switch", type: "registry:ui", dependencies: ["@radix-ui/react-switch"], files: ["ui/switch.tsx"], }, { name: "table", type: "registry:ui", files: ["ui/table.tsx"], }, { name: "tabs", type: "registry:ui", dependencies: ["@radix-ui/react-tabs"], files: ["ui/tabs.tsx"], }, { name: "textarea", type: "registry:ui", files: ["ui/textarea.tsx"], }, { name: "toast", type: "registry:ui", dependencies: ["@radix-ui/react-toast"], files: [ { path: "ui/toast.tsx", type: "registry:ui", }, { path: "hooks/use-toast.ts", type: "registry:hook", }, { path: "ui/toaster.tsx", type: "registry:ui", }, ], }, { name: "toggle", type: "registry:ui", dependencies: ["@radix-ui/react-toggle"], files: ["ui/toggle.tsx"], }, { name: "toggle-group", type: "registry:ui", dependencies: ["@radix-ui/react-toggle-group"], registryDependencies: ["toggle"], files: ["ui/toggle-group.tsx"], }, { name: "tooltip", type: "registry:ui", dependencies: ["@radix-ui/react-tooltip"], files: ["ui/tooltip.tsx"], }, ]
shadcn-ui/ui/apps/www/registry/registry-ui.ts
{ "file_path": "shadcn-ui/ui/apps/www/registry/registry-ui.ts", "repo_id": "shadcn-ui/ui", "token_count": 3415 }
168
import { existsSync, promises as fs } from "fs" import path from "path" import { DEPRECATED_MESSAGE } from "@/src/deprecated" import { getConfig } from "@/src/utils/get-config" import { getPackageManager } from "@/src/utils/get-package-manager" import { handleError } from "@/src/utils/handle-error" import { logger } from "@/src/utils/logger" import { fetchTree, getItemTargetPath, getRegistryBaseColor, getRegistryIndex, resolveTree, } from "@/src/utils/registry" import { transform } from "@/src/utils/transformers" import chalk from "chalk" import { Command } from "commander" import { execa } from "execa" import ora from "ora" import prompts from "prompts" import { z } from "zod" const addOptionsSchema = z.object({ components: z.array(z.string()).optional(), yes: z.boolean(), overwrite: z.boolean(), cwd: z.string(), all: z.boolean(), path: z.string().optional(), }) export const add = new Command() .name("add") .description("add a component to your project") .argument("[components...]", "the components to add") .option("-y, --yes", "skip confirmation prompt.", true) .option("-o, --overwrite", "overwrite existing files.", false) .option( "-c, --cwd <cwd>", "the working directory. defaults to the current directory.", process.cwd() ) .option("-a, --all", "add all available components", false) .option("-p, --path <path>", "the path to add the component to.") .action(async (components, opts) => { try { console.log(DEPRECATED_MESSAGE) const options = addOptionsSchema.parse({ components, ...opts, }) const cwd = path.resolve(options.cwd) if (!existsSync(cwd)) { logger.error(`The path ${cwd} does not exist. Please try again.`) process.exit(1) } const config = await getConfig(cwd) if (!config) { logger.warn( `Configuration is missing. Please run ${chalk.green( `init` )} to create a components.json file.` ) process.exit(1) } const registryIndex = await getRegistryIndex() let selectedComponents = options.all ? registryIndex.map((entry) => entry.name) : options.components if (!options.components?.length && !options.all) { const { components } = await prompts({ type: "multiselect", name: "components", message: "Which components would you like to add?", hint: "Space to select. A to toggle all. Enter to submit.", instructions: false, choices: registryIndex.map((entry) => ({ title: entry.name, value: entry.name, selected: options.all ? true : options.components?.includes(entry.name), })), }) selectedComponents = components } if (!selectedComponents?.length) { logger.warn("No components selected. Exiting.") process.exit(0) } const tree = await resolveTree(registryIndex, selectedComponents) const payload = await fetchTree(config.style, tree) const baseColor = await getRegistryBaseColor(config.tailwind.baseColor) if (!payload.length) { logger.warn("Selected components not found. Exiting.") process.exit(0) } if (!options.yes) { const { proceed } = await prompts({ type: "confirm", name: "proceed", message: `Ready to install components and dependencies. Proceed?`, initial: true, }) if (!proceed) { process.exit(0) } } const spinner = ora(`Installing components...`).start() for (const item of payload) { spinner.text = `Installing ${item.name}...` const targetDir = await getItemTargetPath( config, item, options.path ? path.resolve(cwd, options.path) : undefined ) if (!targetDir) { continue } if (!existsSync(targetDir)) { await fs.mkdir(targetDir, { recursive: true }) } const existingComponent = item.files.filter((file) => existsSync(path.resolve(targetDir, file.name)) ) if (existingComponent.length && !options.overwrite) { if (selectedComponents.includes(item.name)) { spinner.stop() const { overwrite } = await prompts({ type: "confirm", name: "overwrite", message: `Component ${item.name} already exists. Would you like to overwrite?`, initial: false, }) if (!overwrite) { logger.info( `Skipped ${item.name}. To overwrite, run with the ${chalk.green( "--overwrite" )} flag.` ) continue } spinner.start(`Installing ${item.name}...`) } else { continue } } for (const file of item.files) { let filePath = path.resolve(targetDir, file.name) // Run transformers. const content = await transform({ filename: file.name, raw: file.content, config, baseColor, }) if (!config.tsx) { filePath = filePath.replace(/\.tsx$/, ".jsx") filePath = filePath.replace(/\.ts$/, ".js") } await fs.writeFile(filePath, content) } const packageManager = await getPackageManager(cwd) // Install dependencies. if (item.dependencies?.length) { await execa( packageManager, [ packageManager === "npm" ? "install" : "add", ...item.dependencies, ], { cwd, } ) } // Install devDependencies. if (item.devDependencies?.length) { await execa( packageManager, [ packageManager === "npm" ? "install" : "add", "-D", ...item.devDependencies, ], { cwd, } ) } } spinner.succeed(`Done.`) } catch (error) { handleError(error) } })
shadcn-ui/ui/packages/cli/src/commands/add.ts
{ "file_path": "shadcn-ui/ui/packages/cli/src/commands/add.ts", "repo_id": "shadcn-ui/ui", "token_count": 2918 }
169
import { registryBaseColorSchema } from "@/src/utils/registry/schema" import { Transformer } from "@/src/utils/transformers" import { ScriptKind, SyntaxKind } from "ts-morph" import { z } from "zod" export const transformCssVars: Transformer = async ({ sourceFile, config, baseColor, }) => { // No transform if using css variables. if (config.tailwind?.cssVariables || !baseColor?.inlineColors) { return sourceFile } // Find jsx attributes with the name className. // const openingElements = sourceFile.getDescendantsOfKind(SyntaxKind.JsxElement) // console.log(openingElements) // const jsxAttributes = sourceFile // .getDescendantsOfKind(SyntaxKind.JsxAttribute) // .filter((node) => node.getName() === "className") // for (const jsxAttribute of jsxAttributes) { // const value = jsxAttribute.getInitializer()?.getText() // if (value) { // const valueWithColorMapping = applyColorMapping( // value.replace(/"/g, ""), // baseColor.inlineColors // ) // jsxAttribute.setInitializer(`"${valueWithColorMapping}"`) // } // } sourceFile.getDescendantsOfKind(SyntaxKind.StringLiteral).forEach((node) => { const value = node.getText() if (value) { const valueWithColorMapping = applyColorMapping( value.replace(/"/g, ""), baseColor.inlineColors ) node.replaceWithText(`"${valueWithColorMapping.trim()}"`) } }) return sourceFile } // export default function transformer(file: FileInfo, api: API) { // const j = api.jscodeshift.withParser("tsx") // // Replace bg-background with "bg-white dark:bg-slate-950" // const $j = j(file.source) // return $j // .find(j.JSXAttribute, { // name: { // name: "className", // }, // }) // .forEach((path) => { // const { node } = path // if (node?.value?.type) { // if (node.value.type === "StringLiteral") { // node.value.value = applyColorMapping(node.value.value) // console.log(node.value.value) // } // if ( // node.value.type === "JSXExpressionContainer" && // node.value.expression.type === "CallExpression" // ) { // const callee = node.value.expression.callee // if (callee.type === "Identifier" && callee.name === "cn") { // node.value.expression.arguments.forEach((arg) => { // if (arg.type === "StringLiteral") { // arg.value = applyColorMapping(arg.value) // } // if ( // arg.type === "LogicalExpression" && // arg.right.type === "StringLiteral" // ) { // arg.right.value = applyColorMapping(arg.right.value) // } // }) // } // } // } // }) // .toSource() // } // // export function splitClassName(input: string): (string | null)[] { // // const parts = input.split(":") // // const classNames = parts.map((part) => { // // const match = part.match(/^\[?(.+)\]$/) // // if (match) { // // return match[1] // // } else { // // return null // // } // // }) // // return classNames // // } // Splits a className into variant-name-alpha. // eg. hover:bg-primary-100 -> [hover, bg-primary, 100] export function splitClassName(className: string): (string | null)[] { if (!className.includes("/") && !className.includes(":")) { return [null, className, null] } const parts: (string | null)[] = [] // First we split to find the alpha. let [rest, alpha] = className.split("/") // Check if rest has a colon. if (!rest.includes(":")) { return [null, rest, alpha] } // Next we split the rest by the colon. const split = rest.split(":") // We take the last item from the split as the name. const name = split.pop() // We glue back the rest of the split. const variant = split.join(":") // Finally we push the variant, name and alpha. parts.push(variant ?? null, name ?? null, alpha ?? null) return parts } const PREFIXES = ["bg-", "text-", "border-", "ring-offset-", "ring-"] export function applyColorMapping( input: string, mapping: z.infer<typeof registryBaseColorSchema>["inlineColors"] ) { // Handle border classes. if (input.includes(" border ")) { input = input.replace(" border ", " border border-border ") } // Build color mappings. const classNames = input.split(" ") const lightMode = new Set<string>() const darkMode = new Set<string>() for (let className of classNames) { const [variant, value, modifier] = splitClassName(className) const prefix = PREFIXES.find((prefix) => value?.startsWith(prefix)) if (!prefix) { if (!lightMode.has(className)) { lightMode.add(className) } continue } const needle = value?.replace(prefix, "") if (needle && needle in mapping.light) { lightMode.add( [variant, `${prefix}${mapping.light[needle]}`] .filter(Boolean) .join(":") + (modifier ? `/${modifier}` : "") ) darkMode.add( ["dark", variant, `${prefix}${mapping.dark[needle]}`] .filter(Boolean) .join(":") + (modifier ? `/${modifier}` : "") ) continue } if (!lightMode.has(className)) { lightMode.add(className) } } return [...Array.from(lightMode), ...Array.from(darkMode)].join(" ").trim() }
shadcn-ui/ui/packages/cli/src/utils/transformers/transform-css-vars.ts
{ "file_path": "shadcn-ui/ui/packages/cli/src/utils/transformers/transform-css-vars.ts", "repo_id": "shadcn-ui/ui", "token_count": 2262 }
170
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction import type { NextApiRequest, NextApiResponse } from 'next' type Data = { name: string } export default function handler( req: NextApiRequest, res: NextApiResponse<Data> ) { res.status(200).json({ name: 'John Doe' }) }
shadcn-ui/ui/packages/cli/test/fixtures/next-pages/pages/api/hello.ts
{ "file_path": "shadcn-ui/ui/packages/cli/test/fixtures/next-pages/pages/api/hello.ts", "repo_id": "shadcn-ui/ui", "token_count": 106 }
171
@tailwind base; @tailwind components; @tailwind utilities; :root { --foreground-rgb: 0, 0, 0; --background-start-rgb: 214, 219, 220; --background-end-rgb: 255, 255, 255; } @media (prefers-color-scheme: dark) { :root { --foreground-rgb: 255, 255, 255; --background-start-rgb: 0, 0, 0; --background-end-rgb: 0, 0, 0; } } body { color: rgb(var(--foreground-rgb)); background: linear-gradient( to bottom, transparent, rgb(var(--background-end-rgb)) ) rgb(var(--background-start-rgb)); }
shadcn-ui/ui/packages/cli/test/fixtures/next/app/globals.css
{ "file_path": "shadcn-ui/ui/packages/cli/test/fixtures/next/app/globals.css", "repo_id": "shadcn-ui/ui", "token_count": 237 }
172
import { expect, test } from "vitest" import { transform } from "../../src/utils/transformers" test("transform import", async () => { expect( await transform({ filename: "test.ts", raw: `import * as React from "react" import { Foo } from "bar" import { Button } from "@/registry/new-york/ui/button" import { Label} from "ui/label" import { Box } from "@/registry/new-york/box" import { cn } from "@/lib/utils" `, config: { tsx: true, tailwind: { baseColor: "neutral", cssVariables: true, }, aliases: { components: "@/components", utils: "@/lib/utils", }, }, }) ).toMatchSnapshot() expect( await transform({ filename: "test.ts", raw: `import * as React from "react" import { Foo } from "bar" import { Button } from "@/registry/new-york/ui/button" import { Label} from "ui/label" import { Box } from "@/registry/new-york/box" import { cn, foo, bar } from "@/lib/utils" import { bar } from "@/lib/utils/bar" `, config: { tsx: true, aliases: { components: "~/src/components", utils: "~/lib", }, }, }) ).toMatchSnapshot() expect( await transform({ filename: "test.ts", raw: `import * as React from "react" import { Foo } from "bar" import { Button } from "@/registry/new-york/ui/button" import { Label} from "ui/label" import { Box } from "@/registry/new-york/box" import { cn } from "@/lib/utils" import { bar } from "@/lib/utils/bar" `, config: { tsx: true, aliases: { components: "~/src/components", utils: "~/src/utils", }, }, }) ).toMatchSnapshot() expect( await transform({ filename: "test.ts", raw: `import * as React from "react" import { Foo } from "bar" import { Button } from "@/registry/new-york/ui/button" import { Label} from "ui/label" import { Box } from "@/registry/new-york/box" import { cn } from "@/lib/utils" import { bar } from "@/lib/utils/bar" `, config: { tsx: true, aliases: { components: "~/src/components", utils: "~/src/utils", ui: "~/src/components", }, }, }) ).toMatchSnapshot() expect( await transform({ filename: "test.ts", raw: `import * as React from "react" import { Foo } from "bar" import { Button } from "@/registry/new-york/ui/button" import { Label} from "ui/label" import { Box } from "@/registry/new-york/box" import { cn } from "@/lib/utils" import { bar } from "@/lib/utils/bar" `, config: { tsx: true, aliases: { components: "~/src/components", utils: "~/src/utils", ui: "~/src/ui", }, }, }) ).toMatchSnapshot() })
shadcn-ui/ui/packages/cli/test/utils/transform-import.test.ts
{ "file_path": "shadcn-ui/ui/packages/cli/test/utils/transform-import.test.ts", "repo_id": "shadcn-ui/ui", "token_count": 1364 }
173
import { type Config } from "@/src/utils/get-config" import { handleError } from "@/src/utils/handle-error" import { logger } from "@/src/utils/logger" import { registryResolveItemsTree } from "@/src/utils/registry" import { spinner } from "@/src/utils/spinner" import { updateCssVars } from "@/src/utils/updaters/update-css-vars" import { updateDependencies } from "@/src/utils/updaters/update-dependencies" import { updateFiles } from "@/src/utils/updaters/update-files" import { updateTailwindConfig } from "@/src/utils/updaters/update-tailwind-config" export async function addComponents( components: string[], config: Config, options: { overwrite?: boolean silent?: boolean isNewProject?: boolean } ) { options = { overwrite: false, silent: false, isNewProject: false, ...options, } const registrySpinner = spinner(`Checking registry.`, { silent: options.silent, })?.start() const tree = await registryResolveItemsTree(components, config) if (!tree) { registrySpinner?.fail() return handleError(new Error("Failed to fetch components from registry.")) } registrySpinner?.succeed() await updateTailwindConfig(tree.tailwind?.config, config, { silent: options.silent, }) await updateCssVars(tree.cssVars, config, { cleanupDefaultNextStyles: options.isNewProject, silent: options.silent, }) await updateDependencies(tree.dependencies, config, { silent: options.silent, }) await updateFiles(tree.files, config, { overwrite: options.overwrite, silent: options.silent, }) if (tree.docs) { logger.info(tree.docs) } }
shadcn-ui/ui/packages/shadcn/src/utils/add-components.ts
{ "file_path": "shadcn-ui/ui/packages/shadcn/src/utils/add-components.ts", "repo_id": "shadcn-ui/ui", "token_count": 560 }
174
import { promises as fs } from "fs" import { tmpdir } from "os" import path from "path" import { Config } from "@/src/utils/get-config" import { registryBaseColorSchema } from "@/src/utils/registry/schema" import { transformCssVars } from "@/src/utils/transformers/transform-css-vars" import { transformImport } from "@/src/utils/transformers/transform-import" import { transformJsx } from "@/src/utils/transformers/transform-jsx" import { transformRsc } from "@/src/utils/transformers/transform-rsc" import { Project, ScriptKind, type SourceFile } from "ts-morph" import { z } from "zod" import { transformTwPrefixes } from "./transform-tw-prefix" export type TransformOpts = { filename: string raw: string config: Config baseColor?: z.infer<typeof registryBaseColorSchema> transformJsx?: boolean } export type Transformer<Output = SourceFile> = ( opts: TransformOpts & { sourceFile: SourceFile } ) => Promise<Output> const project = new Project({ compilerOptions: {}, }) async function createTempSourceFile(filename: string) { const dir = await fs.mkdtemp(path.join(tmpdir(), "shadcn-")) return path.join(dir, filename) } export async function transform( opts: TransformOpts, transformers: Transformer[] = [ transformImport, transformRsc, transformCssVars, transformTwPrefixes, ] ) { const tempFile = await createTempSourceFile(opts.filename) const sourceFile = project.createSourceFile(tempFile, opts.raw, { scriptKind: ScriptKind.TSX, }) for (const transformer of transformers) { transformer({ sourceFile, ...opts }) } if (opts.transformJsx) { return await transformJsx({ sourceFile, ...opts, }) } return sourceFile.getText() }
shadcn-ui/ui/packages/shadcn/src/utils/transformers/index.ts
{ "file_path": "shadcn-ui/ui/packages/shadcn/src/utils/transformers/index.ts", "repo_id": "shadcn-ui/ui", "token_count": 572 }
175
body { background-color: red; }
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages-src/src/other.css
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages-src/src/other.css", "repo_id": "shadcn-ui/ui", "token_count": 13 }
176
body { background-color: red; }
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages/pages/other.css
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/next-pages/pages/other.css", "repo_id": "shadcn-ui/ui", "token_count": 13 }
177
// learn more: https://fly.io/docs/reference/configuration/#services-http_checks import type { LoaderFunctionArgs } from "@remix-run/node"; import { prisma } from "~/db.server"; export const loader = async ({ request }: LoaderFunctionArgs) => { const host = request.headers.get("X-Forwarded-Host") ?? request.headers.get("host"); try { const url = new URL("/", `http://${host}`); // if we can connect to the database and make a simple query // and make a HEAD request to ourselves, then we're good. await Promise.all([ prisma.user.count(), fetch(url.toString(), { method: "HEAD" }).then((r) => { if (!r.ok) return Promise.reject(r); }), ]); return new Response("OK"); } catch (error: unknown) { console.log("healthcheck ", { error }); return new Response("ERROR", { status: 500 }); } };
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/healthcheck.tsx
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/routes/healthcheck.tsx", "repo_id": "shadcn-ui/ui", "token_count": 303 }
178
// eslint-disable-next-line @typescript-eslint/no-var-requires const path = require("path"); /** @type {import("eslint").Linter.Config} */ const config = { overrides: [ { extends: [ "plugin:@typescript-eslint/recommended-requiring-type-checking", ], files: ["*.ts", "*.tsx"], parserOptions: { project: path.join(__dirname, "tsconfig.json"), }, }, ], parser: "@typescript-eslint/parser", parserOptions: { project: path.join(__dirname, "tsconfig.json"), }, plugins: ["@typescript-eslint"], extends: ["next/core-web-vitals", "plugin:@typescript-eslint/recommended"], rules: { "@typescript-eslint/consistent-type-imports": [ "warn", { prefer: "type-imports", fixStyle: "inline-type-imports", }, ], "@typescript-eslint/no-unused-vars": ["warn", { argsIgnorePattern: "^_" }], }, }; module.exports = config;
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/t3-pages/.eslintrc.cjs
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/t3-pages/.eslintrc.cjs", "repo_id": "shadcn-ui/ui", "token_count": 406 }
179
#root { max-width: 1280px; margin: 0 auto; padding: 2rem; text-align: center; } .logo { height: 6em; padding: 1.5em; will-change: filter; transition: filter 300ms; } .logo:hover { filter: drop-shadow(0 0 2em #646cffaa); } .logo.react:hover { filter: drop-shadow(0 0 2em #61dafbaa); } @keyframes logo-spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @media (prefers-reduced-motion: no-preference) { a:nth-of-type(2) .logo { animation: logo-spin infinite 20s linear; } } .card { padding: 2em; } .read-the-docs { color: #888; }
shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/vite/src/App.css
{ "file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/vite/src/App.css", "repo_id": "shadcn-ui/ui", "token_count": 269 }
180
import * as React from "react" import Link from "next/link" import { NavItem } from "@/types/nav" import { siteConfig } from "@/config/site" import { cn } from "@/lib/utils" import { Icons } from "@/components/icons" interface MainNavProps { items?: NavItem[] } export function MainNav({ items }: MainNavProps) { return ( <div className="flex gap-6 md:gap-10"> <Link href="/" className="flex items-center space-x-2"> <Icons.logo className="h-6 w-6" /> <span className="inline-block font-bold">{siteConfig.name}</span> </Link> {items?.length ? ( <nav className="flex gap-6"> {items?.map( (item, index) => item.href && ( <Link key={index} href={item.href} className={cn( "flex items-center text-sm font-medium text-muted-foreground", item.disabled && "cursor-not-allowed opacity-80" )} > {item.title} </Link> ) )} </nav> ) : null} </div> ) }
shadcn-ui/ui/templates/next-template/components/main-nav.tsx
{ "file_path": "shadcn-ui/ui/templates/next-template/components/main-nav.tsx", "repo_id": "shadcn-ui/ui", "token_count": 599 }
181
dist/* .cache public node_modules *.esm.js
DarkInventor/easy-ui/.eslintignore
{ "file_path": "DarkInventor/easy-ui/.eslintignore", "repo_id": "DarkInventor/easy-ui", "token_count": 17 }
0
"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" import GlitchText from "@/components/easyui/glitch-text" function GlitchTextComponent() { 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">Glitch Text</CardTitle> <CardDescription className="text-balance text-lg text-muted-foreground">Glitch text animation with typing effect.</CardDescription> </div> <Tabs defaultValue="preview" className="relative mr-auto w-full z-0"> <div className="flex items-center justify-between pb-3"> <TabsList className="w-full justify-start rounded-none bg-transparent p-0 z-50"> <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 */} <GlitchText text='Easy UI is Awesome' textSize='40px' fontWeight="600" /> </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/glitch-text.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"> {`"use client" import React, { useEffect, useState } from "react" interface GlitchTextProps { text: string; textSize: string; className?: string; fontWeight?: React.CSSProperties["fontWeight"]; } export default function GlitchText({ text, textSize, className = "", fontWeight = "normal", }: GlitchTextProps) { const [displayedText, setDisplayedText] = useState("") useEffect(() => { let currentIndex = 0; const fullText = text; const typingInterval = setInterval(() => { if (currentIndex <= fullText.length) { setDisplayedText(fullText.slice(0, currentIndex)); currentIndex++; } else { clearInterval(typingInterval); } }, 100); return () => clearInterval(typingInterval); }, [text]); return ( <div className={\`glitch-wrapper \${className} dark:text-white text-black\`} style={{ fontSize: textSize, fontWeight }} > <div className="glitch" data-text={displayedText}> {displayedText} </div> <style jsx>{\` .glitch-wrapper { width: 100%; height: 100vh; display: flex; align-items: center; justify-content: center; text-align: center; background-color: transparent; } .glitch { position: relative; letter-spacing: 3px; z-index: 1; } .glitch:before, .glitch:after { display: block; content: attr(data-text); position: absolute; top: 0; left: 0; opacity: 0.8; } .glitch:before { animation: glitch-it 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both infinite; color: #00ffff; z-index: -1; } .glitch:after { animation: glitch-it 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) reverse both infinite; color: #ff00ff; z-index: -2; } @keyframes glitch-it { 0% { transform: translate(0); } 20% { transform: translate(-2px, 2px); } 40% { transform: translate(-2px, -2px); } 60% { transform: translate(2px, 2px); } 80% { transform: translate(2px, -2px); } to { transform: translate(0); } } \`}</style> </div> ) }`} </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"> {` import GlitchEffect from '@/components/easyui/glitch-effect'; import React from 'react' function Home() { return ( <GlitchEffect text='Easy UI is Awesome' textSize='100px' fontWeight="500" /> ) } 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 GlitchTextComponent
DarkInventor/easy-ui/app/(docs)/glitch-text-component/page.tsx
{ "file_path": "DarkInventor/easy-ui/app/(docs)/glitch-text-component/page.tsx", "repo_id": "DarkInventor/easy-ui", "token_count": 5823 }
1
import Link from 'next/link' import { allPosts } from 'contentlayer/generated' // @ts-ignore export default function RelatedPosts({ currentPost }) { const relatedPosts = allPosts .filter(p => p._id !== currentPost._id && p.tags.some(tag => currentPost.tags.includes(tag))) .slice(0, 3) if (relatedPosts.length === 0) return null return ( <div className="mt-8"> <h2>Related Posts</h2> <ul> {relatedPosts.map(post => ( <li key={post._id}> <Link href={`/posts/${post._raw.flattenedPath}`}>{post.title}</Link> </li> ))} </ul> </div> ) }
DarkInventor/easy-ui/app/posts/[slug]/RelatedPosts.tsx
{ "file_path": "DarkInventor/easy-ui/app/posts/[slug]/RelatedPosts.tsx", "repo_id": "DarkInventor/easy-ui", "token_count": 270 }
2
"use client" import React from "react" import { AnimatePresence, MotionConfig, motion, type Transition, } from "framer-motion" import { Plus, X } from "lucide-react" const transition: Transition = { type: "spring", bounce: 0, duration: 0.4 } const Context = React.createContext<{ status: string setStatus: React.Dispatch<React.SetStateAction<string>> }>({ status: "", setStatus: () => null }) interface ActionItem { link: string icon: React.ReactNode name: string } interface InnerContentProps { actions: ActionItem[] } function InnerContent({ actions }: InnerContentProps) { const ctx = React.useContext(Context) const isOpen = ctx.status === "open" const isHovered = ctx.status === "hovered" return ( <AnimatePresence> {isOpen || isHovered ? ( <motion.div layoutId="container" style={{ borderRadius: 22 }} className="dark:bg-gray-900 bg-[#f7f6ef] tracking-tight text-[#6b6967] shadow-mixed ring-2 ring-black/[8%] dark:text-white dark:border dark:border-gray-800" > <div className="flex w-full items-center justify-between py-2.5 pl-5 pr-2.5 "> <motion.span layoutId="label" className="relative"> Create New </motion.span> <div className="relative "> <AnimatePresence> {isHovered && ( <motion.p initial={{ opacity: 0, x: 10 }} animate={{ opacity: 1, x: 0 }} exit={{ opacity: 0, x: 10 }} className="absolute -left-11 top-0.5 text-sm text-[#6b6967]/70" > Close </motion.p> )} </AnimatePresence> <motion.button layout onClick={() => ctx.setStatus("idle")} initial={{ opacity: 0, x: -20, y: 10 }} animate={{ opacity: 1, x: 0, y: 0 }} exit={{ opacity: 0, x: -20, y: 10 }} transition={{ ...transition, delay: 0.15 }} whileTap={{ scale: 0.9, transition: { ...transition, duration: 0.2 }, }} onHoverStart={() => ctx.setStatus("hovered")} onHoverEnd={() => ctx.setStatus("open")} className="size-6 flex items-center justify-center rounded-full bg-[#b8b6af] dark:bg-transparent" > <X strokeWidth={4} className="size-4 text-tight text-[#fafafa]" /> </motion.button> </div> </div> <motion.div initial={{ opacity: 0 }} animate={ isHovered ? { opacity: 1, scaleX: 0.95, scaleY: 0.92 } : { opacity: 1 } } exit={{ opacity: 0 }} className="flex flex-col gap-2.5 rounded-[22px] bg-[#fafafa] p-2.5 shadow-[0_-3px_3px_-1.5px_rgba(0,0,0,0.08)] ring-1 ring-black/[8%] dark:bg-black dark:text-white dark:border dark:border-gray-800" > <div className="grid grid-cols-3 gap-2.5 text-[#b8b6af]"> {actions.map((item, index) => ( <button key={index} onClick={() => { window.open(item.link, "_blank") ctx.setStatus("idle") }} className="size-24 grid cursor-pointer place-items-center rounded-2xl bg-[#fefefe] transition duration-500 ease-in-out hover:bg-[#f6f4f0] dark:hover:bg-gray-700 hover:duration-200 active:scale-90 dark:bg-black dark:shadow-xl dark:text-white dark:border dark:border-gray-900" > <div className="flex flex-col items-center gap-2 "> {item.icon} <p className="text-[#6b6967]">{item.name}</p> </div> </button> ))} </div> </motion.div> </motion.div> ) : ( <motion.button layoutId="container" onClick={() => ctx.setStatus("open")} whileTap={{ scale: 0.95 }} style={{ borderRadius: 22 }} className="flex items-center gap-1.5 bg-[#fafafa] px-5 py-2.5 tracking-tight text-[#202020] shadow-mixed ring-1 ring-black/[8%] transition-[box-shadow,background-color] hover:bg-[#e0deda] active:shadow-none dark:bg-black dark:text-white dark:border dark:border-gray-700 dark:hover:bg-gray-800" > {/* <motion.div layout initial={{ opacity: 0 }} animate={{ opacity: 1 }} exit={{ opacity: 0 }} transition={{ ...transition, delay: 0.05 }} > */} <Plus strokeWidth={1} /> Create New {/* </motion.div> */} </motion.button> )} </AnimatePresence> ) } interface CreateNewComponentProps { actions: ActionItem[] } export default function CreateNewComponent({ actions, }: CreateNewComponentProps) { const [status, setStatus] = React.useState("idle") React.useEffect(() => { function handleEscape(e: KeyboardEvent) { if (e.key === "Escape") { setStatus("idle") } } window.addEventListener("keydown", handleEscape) return () => window.removeEventListener("keydown", handleEscape) }, [setStatus]) return ( <Context.Provider value={{ status, setStatus }}> <MotionConfig transition={transition}> <main className="relative flex h-auto items-center justify-center bg-[#fdfdfc] font-medium dark:bg-black"> <InnerContent actions={actions} /> </main> </MotionConfig> </Context.Provider> ) }
DarkInventor/easy-ui/components/easyui/create-new.tsx
{ "file_path": "DarkInventor/easy-ui/components/easyui/create-new.tsx", "repo_id": "DarkInventor/easy-ui", "token_count": 2905 }
3
"use client"; import { cn } from "@/lib/utils"; import { CSSProperties, ReactElement, ReactNode, useEffect, useRef, useState, } from "react"; interface MousePosition { x: number; y: number; } function useMousePosition(): MousePosition { const [mousePosition, setMousePosition] = useState<MousePosition>({ x: 0, y: 0, }); useEffect(() => { const handleMouseMove = (event: globalThis.MouseEvent) => { setMousePosition({ x: event.clientX, y: event.clientY }); }; window.addEventListener("mousemove", handleMouseMove); return () => { window.removeEventListener("mousemove", handleMouseMove); }; }, []); return mousePosition; } interface MagicContainerProps { children?: ReactNode; className?: any; } const MagicContainer = ({ children, className }: MagicContainerProps) => { const containerRef = useRef<HTMLDivElement>(null); const mousePosition = useMousePosition(); const mouse = useRef<{ x: number; y: number }>({ x: 0, y: 0 }); const containerSize = useRef<{ w: number; h: number }>({ w: 0, h: 0 }); const [boxes, setBoxes] = useState<Array<HTMLElement>>([]); useEffect(() => { init(); containerRef.current && setBoxes( Array.from(containerRef.current.children).map( (el) => el as HTMLElement, ), ); }, []); useEffect(() => { init(); window.addEventListener("resize", init); return () => { window.removeEventListener("resize", init); }; }, [setBoxes]); useEffect(() => { onMouseMove(); }, [mousePosition]); const init = () => { if (containerRef.current) { containerSize.current.w = containerRef.current.offsetWidth; containerSize.current.h = containerRef.current.offsetHeight; } }; const onMouseMove = () => { if (containerRef.current) { const rect = containerRef.current.getBoundingClientRect(); const { w, h } = containerSize.current; const x = mousePosition.x - rect.left; const y = mousePosition.y - rect.top; const inside = x < w && x > 0 && y < h && y > 0; mouse.current.x = x; mouse.current.y = y; boxes.forEach((box) => { const boxX = -(box.getBoundingClientRect().left - rect.left) + mouse.current.x; const boxY = -(box.getBoundingClientRect().top - rect.top) + mouse.current.y; box.style.setProperty("--mouse-x", `${boxX}px`); box.style.setProperty("--mouse-y", `${boxY}px`); if (inside) { box.style.setProperty("--opacity", `1`); } else { box.style.setProperty("--opacity", `0`); } }); } }; return ( <div className={cn("h-full w-full", className)} ref={containerRef}> {children} </div> ); }; interface MagicCardProps { /** * @default <div /> * @type ReactElement * @description * The component to be rendered as the card * */ as?: ReactElement; /** * @default "" * @type string * @description * The className of the card */ className?: string; /** * @default "" * @type ReactNode * @description * The children of the card * */ children?: ReactNode; /** * @default 600 * @type number * @description * The size of the spotlight effect in pixels * */ size?: number; /** * @default true * @type boolean * @description * Whether to show the spotlight * */ spotlight?: boolean; /** * @default "rgba(255,255,255,0.03)" * @type string * @description * The color of the spotlight * */ spotlightColor?: string; /** * @default true * @type boolean * @description * Whether to isolate the card which is being hovered * */ isolated?: boolean; /** * @default "rgba(255,255,255,0.03)" * @type string * @description * The background of the card * */ background?: string; [key: string]: any; } const MagicCard: React.FC<MagicCardProps> = ({ className, children, size = 600, spotlight = true, borderColor = "hsl(0 0% 98%)", isolated = true, ...props }) => { return ( <div style={ { "--mask-size": `${size}px`, "--border-color": `${borderColor}`, } as CSSProperties } className={cn( "relative z-0 h-full w-full rounded-2xl p-6", "bg-gray-300 dark:bg-gray-700", "bg-[radial-gradient(var(--mask-size)_circle_at_var(--mouse-x)_var(--mouse-y),var(--border-color),transparent_100%)]", className, )} {...props} > {children} {/* Background */} <div className={ "absolute inset-[1px] -z-20 rounded-2xl bg-white dark:bg-black/95" } /> </div> ); }; export { MagicCard, MagicContainer };
DarkInventor/easy-ui/components/magicui/magic-card.tsx
{ "file_path": "DarkInventor/easy-ui/components/magicui/magic-card.tsx", "repo_id": "DarkInventor/easy-ui", "token_count": 1946 }
4
"use client" import * as React from "react" import * as AvatarPrimitive from "@radix-ui/react-avatar" import { cn } from "@/lib/utils" const Avatar = React.forwardRef< React.ElementRef<typeof AvatarPrimitive.Root>, React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> >(({ className, ...props }, ref) => ( <AvatarPrimitive.Root ref={ref} className={cn( "relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full", className )} {...props} /> )) Avatar.displayName = AvatarPrimitive.Root.displayName const AvatarImage = React.forwardRef< React.ElementRef<typeof AvatarPrimitive.Image>, React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> >(({ className, ...props }, ref) => ( <AvatarPrimitive.Image ref={ref} className={cn("aspect-square h-full w-full", className)} {...props} /> )) AvatarImage.displayName = AvatarPrimitive.Image.displayName const AvatarFallback = React.forwardRef< React.ElementRef<typeof AvatarPrimitive.Fallback>, React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> >(({ className, ...props }, ref) => ( <AvatarPrimitive.Fallback ref={ref} className={cn( "flex h-full w-full items-center justify-center rounded-full bg-muted", className )} {...props} /> )) AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName export { Avatar, AvatarImage, AvatarFallback }
DarkInventor/easy-ui/components/ui/avatar.tsx
{ "file_path": "DarkInventor/easy-ui/components/ui/avatar.tsx", "repo_id": "DarkInventor/easy-ui", "token_count": 503 }
5
export type SiteConfig = typeof siteConfig export const siteConfig = { name: "Easy UI", description: "Beautifully designed website templates built with React and Tailwind CSS.", mainNav: [ { title: "Features", href: "/", }, { title: "Pricing", href: "/", }, { title: "Blog", href: "/", }, { title: "Documentation", href: "/", } ], links: { twitter: "https://twitter.com/kathanmehtaa", github: "https://github.com/DarkInventor/easy-ui", docs: "https://ui.shadcn.com", }, }
DarkInventor/easy-ui/config/site.ts
{ "file_path": "DarkInventor/easy-ui/config/site.ts", "repo_id": "DarkInventor/easy-ui", "token_count": 252 }
6
export interface NavItem { title: string href?: string disabled?: boolean external?: boolean }
DarkInventor/easy-ui/types/nav.ts
{ "file_path": "DarkInventor/easy-ui/types/nav.ts", "repo_id": "DarkInventor/easy-ui", "token_count": 28 }
7
"use client"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Form, FormControl, FormField, FormItem, FormMessage, } from "@/components/ui/form"; import { z } from "zod"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import { useMutation } from "@tanstack/react-query"; import { joinEarlyAccessAction } from "@/server/actions/early-access"; import { Icons } from "@/components/icons"; import { toast } from "sonner"; const formSchema = z.object({ name: z.string().min(2, { message: "Name must be at least 2 characters.", }), email: z.string().email({ message: "Please enter a valid email address.", }), }); export function EarlyAccessForm() { const form = useForm<z.infer<typeof formSchema>>({ resolver: zodResolver(formSchema), defaultValues: { name: "", email: "", }, }); const { isPending, mutate } = useMutation({ mutationFn: () => joinEarlyAccessAction({ email: form.getValues().email, name: form.getValues().name, }), onSuccess: () => { form.reset(); toast.success(`Thanks for joining early access! `, { description: `We'll keep you updated on our progress.`, }); }, onError: () => { toast.error(`Failed to join early access. `, { description: `Please try again later.`, }); }, }); function onSubmit() { mutate(); } return ( <Form {...form}> <form onSubmit={form.handleSubmit(onSubmit)} className="w-full space-y-2" > <FormField control={form.control} name="name" render={({ field }) => ( <FormItem> <FormControl> <Input placeholder="Name" className="h-12 bg-background" {...field} /> </FormControl> <FormMessage /> </FormItem> )} /> <FormField control={form.control} name="email" render={({ field }) => ( <FormItem> <FormControl> <Input placeholder="Email" className="h-12 bg-background" {...field} /> </FormControl> <FormMessage /> </FormItem> )} /> <div className="flex w-full justify-end"> <Button disabled={isPending} type="submit" className="h-12 w-full gap-2" size="lg" > {isPending ? ( <Icons.loader className="h-4 w-4" /> ) : null} <span>Join Early Access</span> </Button> </div> </form> </Form> ); }
alifarooq9/rapidlaunch/apps/www/src/app/(app)/_components/early-access-form.tsx
{ "file_path": "alifarooq9/rapidlaunch/apps/www/src/app/(app)/_components/early-access-form.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 2195 }
8
"use client" import * as React from "react" import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu" import { Check, ChevronRight, Circle } from "lucide-react" import { cn } from "@/lib/utils" const DropdownMenu = DropdownMenuPrimitive.Root const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger const DropdownMenuGroup = DropdownMenuPrimitive.Group const DropdownMenuPortal = DropdownMenuPrimitive.Portal const DropdownMenuSub = DropdownMenuPrimitive.Sub const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup const DropdownMenuSubTrigger = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.SubTrigger>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubTrigger> & { inset?: boolean } >(({ className, inset, children, ...props }, ref) => ( <DropdownMenuPrimitive.SubTrigger ref={ref} className={cn( "flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent", inset && "pl-8", className )} {...props} > {children} <ChevronRight className="ml-auto h-4 w-4" /> </DropdownMenuPrimitive.SubTrigger> )) DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName const DropdownMenuSubContent = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.SubContent>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.SubContent> >(({ className, ...props }, ref) => ( <DropdownMenuPrimitive.SubContent ref={ref} className={cn( "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className )} {...props} /> )) DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName const DropdownMenuContent = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.Content>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Content> >(({ className, sideOffset = 4, ...props }, ref) => ( <DropdownMenuPrimitive.Portal> <DropdownMenuPrimitive.Content ref={ref} sideOffset={sideOffset} className={cn( "z-50 min-w-[8rem] overflow-hidden rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2", className )} {...props} /> </DropdownMenuPrimitive.Portal> )) DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName const DropdownMenuItem = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.Item>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Item> & { inset?: boolean } >(({ className, inset, ...props }, ref) => ( <DropdownMenuPrimitive.Item ref={ref} className={cn( "relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", inset && "pl-8", className )} {...props} /> )) DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName const DropdownMenuCheckboxItem = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.CheckboxItem>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.CheckboxItem> >(({ className, children, checked, ...props }, ref) => ( <DropdownMenuPrimitive.CheckboxItem ref={ref} className={cn( "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className )} checked={checked} {...props} > <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <DropdownMenuPrimitive.ItemIndicator> <Check className="h-4 w-4" /> </DropdownMenuPrimitive.ItemIndicator> </span> {children} </DropdownMenuPrimitive.CheckboxItem> )) DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName const DropdownMenuRadioItem = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.RadioItem>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.RadioItem> >(({ className, children, ...props }, ref) => ( <DropdownMenuPrimitive.RadioItem ref={ref} className={cn( "relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", className )} {...props} > <span className="absolute left-2 flex h-3.5 w-3.5 items-center justify-center"> <DropdownMenuPrimitive.ItemIndicator> <Circle className="h-2 w-2 fill-current" /> </DropdownMenuPrimitive.ItemIndicator> </span> {children} </DropdownMenuPrimitive.RadioItem> )) DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName const DropdownMenuLabel = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.Label>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Label> & { inset?: boolean } >(({ className, inset, ...props }, ref) => ( <DropdownMenuPrimitive.Label ref={ref} className={cn( "px-2 py-1.5 text-sm font-semibold", inset && "pl-8", className )} {...props} /> )) DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName const DropdownMenuSeparator = React.forwardRef< React.ElementRef<typeof DropdownMenuPrimitive.Separator>, React.ComponentPropsWithoutRef<typeof DropdownMenuPrimitive.Separator> >(({ className, ...props }, ref) => ( <DropdownMenuPrimitive.Separator ref={ref} className={cn("-mx-1 my-1 h-px bg-muted", className)} {...props} /> )) DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName const DropdownMenuShortcut = ({ className, ...props }: React.HTMLAttributes<HTMLSpanElement>) => { return ( <span className={cn("ml-auto text-xs tracking-widest opacity-60", className)} {...props} /> ) } DropdownMenuShortcut.displayName = "DropdownMenuShortcut" export { DropdownMenu, DropdownMenuTrigger, DropdownMenuContent, DropdownMenuItem, DropdownMenuCheckboxItem, DropdownMenuRadioItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuShortcut, DropdownMenuGroup, DropdownMenuPortal, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuRadioGroup, }
alifarooq9/rapidlaunch/apps/www/src/components/ui/dropdown-menu.tsx
{ "file_path": "alifarooq9/rapidlaunch/apps/www/src/components/ui/dropdown-menu.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 2630 }
9
import type { Config } from "tailwindcss"; import { fontFamily } from "tailwindcss/defaultTheme"; import baseConfig from "@rapidlaunch/tailwind-config/base"; export default { // We need to append the path to the UI package to the content array so that // those classes are included correctly. content: [...baseConfig.content], presets: [baseConfig], safelist: ["dark"], theme: { extend: {}, fontFamily: { sans: ["var(--font-sans)", ...fontFamily.sans], heading: ["var(--font-heading)", ...fontFamily.sans], }, }, } satisfies Config;
alifarooq9/rapidlaunch/apps/www/tailwind.config.ts
{ "file_path": "alifarooq9/rapidlaunch/apps/www/tailwind.config.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 224 }
10
import { AppPageShell } from "@/app/(app)/_components/page-shell"; import { dashboardPageConfig } from "@/app/(app)/(user)/dashboard/_constants/page-config"; import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { ActivityIcon, CreditCardIcon, DollarSignIcon, Users2Icon, } from "lucide-react"; export default function DashboardPage() { return ( <AppPageShell title={dashboardPageConfig.title} description={dashboardPageConfig.description} > <div className="grid gap-6"> <div className="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-4"> <Card> <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <CardTitle className="text-sm font-medium"> Total Revenue </CardTitle> <DollarSignIcon className="h-4 w-4 text-muted-foreground" /> </CardHeader> <CardContent> <div className="text-2xl font-bold">$45,231.89</div> <p className="text-xs text-muted-foreground"> +20.1% from last month </p> </CardContent> </Card> <Card> <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <CardTitle className="text-sm font-medium"> Subscriptions </CardTitle> <Users2Icon className="h-4 w-4 text-muted-foreground" /> </CardHeader> <CardContent> <div className="text-2xl font-bold">+3402</div> <p className="text-xs text-muted-foreground"> +20.1% from last month </p> </CardContent> </Card> <Card> <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <CardTitle className="text-sm font-medium"> Active Now </CardTitle> <ActivityIcon className="h-4 w-4 text-muted-foreground" /> </CardHeader> <CardContent> <div className="text-2xl font-bold">+304</div> <p className="text-xs text-muted-foreground"> +20.1% from last month </p> </CardContent> </Card> <Card> <CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2"> <CardTitle className="text-sm font-medium"> Sales </CardTitle> <CreditCardIcon className="h-4 w-4 text-muted-foreground" /> </CardHeader> <CardContent> <div className="text-2xl font-bold">+102304</div> <p className="text-xs text-muted-foreground"> +20.1% from last month </p> </CardContent> </Card> </div> <div className="flex min-h-44 w-full items-center justify-center rounded-md border-2 border-dashed border-border p-4"> <p className="text-sm text-muted-foreground"> Your Content here, Above is a dummy data </p> </div> </div> </AppPageShell> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/dashboard/page.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/dashboard/page.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 2486 }
11
"use client"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuRadioGroup, DropdownMenuRadioItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuSubContent, DropdownMenuSubTrigger, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { Button } from "@/components/ui/button"; import { MoreHorizontalIcon } from "lucide-react"; import { membersToOrganizationsRoleEnum } from "@/server/db/schema"; import { toast } from "sonner"; import { type MembersData } from "@/app/(app)/(user)/org/members/_components/columns"; import { useMutation } from "@tanstack/react-query"; import { useRouter } from "next/navigation"; import { removeUserMutation, updateMemberRoleMutation, } from "@/server/actions/organization/mutations"; import { useAwaitableTransition } from "@/hooks/use-awaitable-transition"; type Role = (typeof membersToOrganizationsRoleEnum.enumValues)[number]; export function ColumnDropdown({ role, memberId }: MembersData) { const router = useRouter(); const { mutateAsync: changeRoleMutate, isPending: changeRoleIsPending } = useMutation({ mutationFn: ({ role }: { role: Role }) => { return updateMemberRoleMutation({ memberId, role }); }, onSettled: () => { router.refresh(); }, }); const [roleChangeIsTransitionPending, startAwaitableRoleChangeTransition] = useAwaitableTransition(); const onRoleChange = (role: Role) => { toast.promise( async () => { await changeRoleMutate({ role }); await startAwaitableRoleChangeTransition(() => { router.refresh(); }); }, { loading: "Updating user role...", success: "User role updated!", error: "Failed to update user role, Check your permissions.", }, ); }; const { mutateAsync: removeMemberMutate, isPending: removeMemberIsPending, } = useMutation({ mutationFn: ({ memberId }: { memberId: string }) => removeUserMutation({ memberId }), }); const [ removeMemberIsTransitionPending, startAwaitableRemoveMemberTransition, ] = useAwaitableTransition(); const onRemoveMember = async () => { toast.promise( async () => { await removeMemberMutate({ memberId, }); await startAwaitableRemoveMemberTransition(() => { router.refresh(); }); }, { loading: "Removing user...", success: "User removed ", error: "Failed to remove user.", }, ); }; return ( <DropdownMenu modal={false}> <DropdownMenuTrigger asChild> <Button variant="ghost" className="h-8 w-8 p-0"> <span className="sr-only">Open menu</span> <MoreHorizontalIcon className="h-4 w-4" /> </Button> </DropdownMenuTrigger> <DropdownMenuContent align="end" className="w-screen max-w-[12rem]"> <DropdownMenuLabel>Actions</DropdownMenuLabel> <DropdownMenuSeparator /> <DropdownMenuSub> <DropdownMenuSubTrigger>Edit role</DropdownMenuSubTrigger> <DropdownMenuSubContent> <DropdownMenuRadioGroup value={role} onValueChange={(r) => onRoleChange(r as Role)} > {membersToOrganizationsRoleEnum.enumValues.map( (currentRole) => ( <DropdownMenuRadioItem key={currentRole} value={currentRole} disabled={ changeRoleIsPending || roleChangeIsTransitionPending } > {currentRole} </DropdownMenuRadioItem> ), )} </DropdownMenuRadioGroup> </DropdownMenuSubContent> </DropdownMenuSub> <DropdownMenuSeparator /> <DropdownMenuItem disabled={ removeMemberIsPending || removeMemberIsTransitionPending } onClick={onRemoveMember} className="text-red-600" > Remove </DropdownMenuItem> </DropdownMenuContent> </DropdownMenu> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/_components/column-dropdown.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/_components/column-dropdown.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 2723 }
12
import { AppPageLoading } from "@/app/(app)/_components/page-loading"; import { orgSettingsPageConfig } from "@/app/(app)/(user)/org/settings/_constants/page-config"; import { Skeleton } from "@/components/ui/skeleton"; export default function OrgSettingsLoading() { return ( <AppPageLoading title={orgSettingsPageConfig.title} description={orgSettingsPageConfig.description} > <div className="grid w-full 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)/org/settings/loading.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/settings/loading.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 312 }
13
"use client"; import * as React from "react"; import { type ColumnDef, type Table as TanstackTable, flexRender, } from "@tanstack/react-table"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@/components/ui/table"; import { DataTablePagination } from "@/app/(app)/_components/data-table-pagination"; import { DataTableToolbar } from "@/app/(app)/_components/data-table-toolbar"; import type { DataTableFilterableColumn, DataTableSearchableColumn, } from "@/types/data-table"; /** * learn more about data-table at shadcn ui website @see https://ui.shadcn.com/docs/components/data-table */ type DataTableProps<TData, TValue> = { columns: ColumnDef<TData, TValue>[]; table: TanstackTable<TData>; totalRows: number; filterableColumns?: DataTableFilterableColumn<TData>[]; searchableColumns?: DataTableSearchableColumn<TData>[]; }; export function DataTable<TData, TValue>({ columns, table, totalRows, searchableColumns = [], filterableColumns = [], }: DataTableProps<TData, TValue>) { return ( <div className="space-y-4"> <DataTableToolbar table={table} filterableColumns={filterableColumns} searchableColumns={searchableColumns} /> <div className="flex-shrink rounded-md border border-border bg-background"> <Table> <TableHeader> {table.getHeaderGroups().map((headerGroup) => ( <TableRow key={headerGroup.id}> {headerGroup.headers.map((header) => { return ( <TableHead key={header.id}> {header.isPlaceholder ? null : (flexRender( header.column.columnDef .header, header.getContext(), ) as React.ReactNode)} </TableHead> ); })} </TableRow> ))} </TableHeader> <TableBody> {table.getRowModel().rows?.length ? ( table.getRowModel().rows.map((row) => ( <TableRow key={row.id} data-state={ row.getIsSelected() && "selected" } > {row.getVisibleCells().map((cell) => ( <TableCell key={cell.id}> { flexRender( cell.column.columnDef.cell, cell.getContext(), ) as React.ReactNode } </TableCell> ))} </TableRow> )) ) : ( <TableRow> <TableCell colSpan={columns.length} className="h-24 text-center" > No results. </TableCell> </TableRow> )} </TableBody> </Table> </div> <DataTablePagination table={table} totalRows={totalRows} /> </div> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/data-table.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/data-table.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 2772 }
14
"use client"; import { LineChart } from "@/components/charts"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from "@/components/ui/card"; import { thousandToK } from "@/lib/utils"; type UsersChartProps = { data: { Date: string; UsersCount: number; }[]; }; export function UsersChart({ data }: UsersChartProps) { return ( <Card> <CardHeader> <CardTitle>Users Analytics</CardTitle> <CardDescription> Count of users joined each month for last 6 months </CardDescription> </CardHeader> <CardContent> <LineChart data={data} xAxisDataKey="Date" yAxisDataKey="UsersCount" lineDataKeys={["UsersCount"]} lineProps={[{ stroke: "hsl(var(--primary))" }]} yAxisProps={{ tickFormatter: (value) => { if (value >= 10000) { return `${thousandToK(Number(value)).toFixed(1)}k`; } else { return value as string; } }, }} /> </CardContent> </Card> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/dashboard/_components/users-chart.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/dashboard/_components/users-chart.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 821 }
15
export const organizationsPageConfig = { title: "Organizations", description: "View all organizations in your app.", } as const;
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/organizations/_constants/page-config.ts
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/organizations/_constants/page-config.ts", "repo_id": "alifarooq9/rapidlaunch", "token_count": 45 }
16
import { SwtichOrgLoading } from "@/app/(app)/_components/org-switch-loading"; import { NewUserSetup } from "@/app/(app)/_components/new-user-setup"; import { CreateFirstOrgForm } from "@/app/(app)/_components/create-first-org-form"; import React, { Fragment, Suspense } from "react"; type AppLayoutProps = { children: React.ReactNode; }; export default function AppLayout({ children }: AppLayoutProps) { return ( <Fragment> <SwtichOrgLoading /> {children} <Suspense fallback={null}> <NewUserSetup /> </Suspense> <Suspense fallback={null}> <CreateFirstOrgForm /> </Suspense> </Fragment> ); }
alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/layout.tsx
{ "file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/layout.tsx", "repo_id": "alifarooq9/rapidlaunch", "token_count": 324 }
17