text
stringlengths 21
253k
| id
stringlengths 25
123
| metadata
dict | __index_level_0__
int64 0
181
|
---|---|---|---|
"use client";
import { Badge } from "@/components/ui/badge";
import { Button, buttonVariants } from "@/components/ui/button";
import { Icons } from "@/components/ui/icons";
import {
Sheet,
SheetContent,
SheetHeader,
SheetTrigger,
} from "@/components/ui/sheet";
import { navigation } from "@/config/header";
import { siteUrls } from "@/config/urls";
import { cn } from "@/lib/utils";
import { MenuIcon } from "lucide-react";
import Link from "next/link";
import React from "react";
export function MobileNav() {
const [isOpen, setIsOpen] = React.useState(false);
return (
<Sheet open={isOpen} onOpenChange={setIsOpen}>
<SheetTrigger asChild>
<Button variant="outline" size="iconSmall">
<MenuIcon className="h-4 w-4" />
<p className="sr-only">Open menu</p>
</Button>
</SheetTrigger>
<SheetContent side="left">
<SheetHeader>
<Icons.logo hideTextOnMobile={false} />
</SheetHeader>
<ul className="space-y-3 py-8">
<li onClick={() => setIsOpen(false)}>
<Link
href={siteUrls.home}
className={buttonVariants({
variant: "link",
})}
>
<span className="text-lg">Home</span>
</Link>
</li>
{navigation.map((item) => (
<li key={item.href} onClick={() => setIsOpen(false)}>
<Link
href={item.href}
className={cn(
buttonVariants({
variant: "link",
}),
)}
>
<span className="text-lg">{item.label}</span>
{item.badge ? (
<Badge variant="secondary" className="ml-2">
{item.badge}
</Badge>
) : null}
</Link>
</li>
))}
</ul>
</SheetContent>
</Sheet>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(web)/_components/mobile-nav.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(web)/_components/mobile-nav.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 1582
} | 14 |
import NextAuth from "next-auth";
import { authOptions } from "@/server/auth";
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const handler = NextAuth(authOptions);
export { handler as GET, handler as POST };
| alifarooq9/rapidlaunch/starterkits/saas/src/app/api/auth/[...nextauth]/route.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/api/auth/[...nextauth]/route.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 73
} | 15 |
import React from "react";
import { Providers } from "@/components/providers";
import { Toaster } from "@/components/ui/sonner";
import "@/styles/globals.css";
import { fontHeading, fontSans } from "@/lib/fonts";
import { type Metadata } from "next";
import {
defaultMetadata,
twitterMetadata,
ogMetadata,
} from "@/app/shared-metadata";
export const metadata: Metadata = {
...defaultMetadata,
twitter: {
...twitterMetadata,
},
openGraph: {
...ogMetadata,
},
};
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en" suppressHydrationWarning>
<body
className={`${fontSans.variable} ${fontHeading.variable} overflow-x-hidden font-sans`}
>
<Providers>
{children}
<Toaster richColors position="top-right" expand />
</Providers>
</body>
</html>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/layout.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/layout.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 451
} | 16 |
import {
BarChart4Icon,
BookTextIcon,
Building2Icon,
ClipboardListIcon,
CreditCardIcon,
HelpCircleIcon,
LayoutDashboardIcon,
MessageSquareIcon,
PenLineIcon,
Settings2Icon,
UserRoundCheckIcon,
UserRoundPlusIcon,
UsersRoundIcon,
} from "lucide-react";
import { siteUrls } from "@/config/urls";
/**
* This file contains the configuration for the navigation items in the sidebar
* to add a new navigation item, you can add a new object to the navigation array
* 1 id: a unique id for the navigation, add it to the navIds object
* 2 label: the label for the navigation (it's a category label)
* 3 showLabel: if true, the label will be shown in the sidebar (it's a category label)
* 4 items: an array of navigation items
* - label: the label for the navigation item
* - icon: the icon for the navigation item
* - href: the href for the navigation item
* - subMenu: an array of subMenu items
* > label: the label for the subMenu item
* > href: the href for the subMenu item
* > icon: the icon for the subMenu item
*
* @use specific navigation items in the sidebar, you can use the filterNavItems function
*/
type IconProps = React.HTMLAttributes<SVGElement>;
type NavItemBase = {
label: string;
icon: React.ComponentType<IconProps>;
disabled?: boolean;
};
type NavItemWithHref = NavItemBase & {
href: string;
external?: boolean;
subMenu?: never;
};
type NavItemWithSubMenu = NavItemBase & {
href?: never;
subMenu: {
label: string;
href: string;
icon: React.ComponentType<IconProps>;
external?: boolean;
disabled?: boolean;
}[];
};
type NavItem = NavItemWithHref | NavItemWithSubMenu;
export type SidebarNavItems = {
id: string;
label: string;
showLabel?: boolean;
items: NavItem[];
};
const navIds = {
admin: "admin",
general: "general",
org: "org",
resources: "resources",
};
const navigation: SidebarNavItems[] = [
{
id: navIds.admin,
label: "Admin",
showLabel: true,
items: [
{
label: "Dashboard",
icon: LayoutDashboardIcon,
href: siteUrls.admin.dashboard,
},
{
label: "Users",
icon: UsersRoundIcon,
href: siteUrls.admin.users,
},
{
label: "Organizations",
icon: Building2Icon,
href: siteUrls.admin.organizations,
},
{
label: "Waitlist",
icon: ClipboardListIcon,
href: siteUrls.admin.waitlist,
},
{
label: "Analytics",
icon: BarChart4Icon,
href: siteUrls.admin.analytics,
},
{
label: "Feedback List",
icon: HelpCircleIcon,
href: siteUrls.admin.feedbacks,
},
],
},
{
id: navIds.general,
label: "General",
showLabel: true,
items: [
{
label: "Dashboard",
icon: LayoutDashboardIcon,
href: siteUrls.dashboard.home,
},
],
},
{
id: navIds.org,
label: "Organization",
showLabel: true,
items: [
{
label: "Members",
icon: UsersRoundIcon,
subMenu: [
{
label: "Org Members",
icon: UserRoundCheckIcon,
href: siteUrls.organization.members.home,
},
{
label: "Invite Members",
icon: UserRoundPlusIcon,
href: siteUrls.organization.members.invite,
},
],
},
{
label: "Plans & Billing",
icon: CreditCardIcon,
href: siteUrls.organization.plansAndBilling,
},
{
label: "Settings",
icon: Settings2Icon,
href: siteUrls.organization.settings,
},
],
},
{
id: navIds.resources,
label: "Resources",
showLabel: true,
items: [
{
label: "Feedbacks",
icon: MessageSquareIcon,
href: siteUrls.feedback,
},
{
label: "Docs",
icon: BookTextIcon,
href: siteUrls.docs,
},
{
label: "Blog",
icon: PenLineIcon,
href: siteUrls.blogs,
},
{
label: "Support",
icon: HelpCircleIcon,
href: siteUrls.support,
},
],
},
];
type FilterNavItemsProps = {
removeIds?: string[];
includedIds?: string[];
};
/**
* @purpose Filters the navigation items for the sidebar.
* The filterNavItems function filters the navigation items for the sidebar.
* @param removeIds An array of string identifiers to remove from the navigation items.
* @param includeIds An array of string identifiers to include in the navigation items.
*
* @returns The filtered navigation items for the sidebar.
* */
export function filteredNavItems({
removeIds = [],
includedIds = [],
}: FilterNavItemsProps) {
let includedItems = sidebarConfig.navigation;
if (includedIds.length) {
includedItems = includedItems.filter((item) =>
includedIds.includes(item.id),
);
}
if (removeIds.length) {
includedItems = includedItems.filter(
(item) => !removeIds.includes(item.id),
);
}
return includedItems;
}
/**
* The sidebarConfig is an object that contains the configuration for the dashboard
* @export all the configuration for the sidebar in sidebarConfig
*/
export const sidebarConfig = {
navIds,
navigation,
filteredNavItems,
} as const;
| alifarooq9/rapidlaunch/starterkits/saas/src/config/sidebar.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/config/sidebar.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 3027
} | 17 |
"use server";
import { orgConfig } from "@/config/organization";
import { db } from "@/server/db";
import {
membersToOrganizations,
orgRequests,
organizations,
} from "@/server/db/schema";
import { adminProcedure, protectedProcedure } from "@/server/procedures";
import { and, asc, count, desc, eq, ilike, inArray, or } from "drizzle-orm";
import { cookies } from "next/headers";
import { z } from "zod";
import { unstable_noStore as noStore } from "next/cache";
export async function getUserOrgsQuery() {
const { user } = await protectedProcedure();
return (
await db.query.membersToOrganizations
.findMany({
where: eq(membersToOrganizations.memberId, user.id),
with: {
organization: true,
},
})
.execute()
).map((mto) => ({
...mto.organization,
}));
}
export async function getOrganizations() {
const userOrgs = await getUserOrgsQuery();
const defaultOrg = cookies().get(orgConfig.cookieName)?.value;
const currentOrg =
userOrgs.find((org) => org.id === defaultOrg) ?? userOrgs[0];
return {
currentOrg: currentOrg as typeof organizations.$inferSelect,
userOrgs,
};
}
export async function getOrgRequestsQuery() {
await protectedProcedure();
const { currentOrg } = await getOrganizations();
return await db.query.orgRequests
.findMany({
where: eq(orgRequests.organizationId, currentOrg.id),
with: {
user: true,
},
})
.execute();
}
/**
* @purpose Get organization by id
* @param orgId
* @returns organization
*/
type GetOrgByIdProps = {
orgId: string;
};
export async function getOrgByIdQuery({ orgId }: GetOrgByIdProps) {
await protectedProcedure();
return await db.query.organizations.findFirst({
where: and(eq(organizations.id, orgId)),
columns: {
name: true,
image: true,
},
});
}
/**
* @purpose Get paginated users
* @param page - page number
* @param per_page - number of items per page
* @param sort - sort by column
* @param email - filter by email
* @param role - filter by role
* @param operator - filter by operator
* @returns Paginated users
*/
const panginatedOrgMembersPropsSchema = z.object({
page: z.coerce.number().default(1),
per_page: z.coerce.number().default(10),
sort: z.string().optional(),
email: z.string().optional(),
role: z.string().optional(),
operator: z.string().optional(),
});
type GetPaginatedOrgMembersQueryProps = z.infer<
typeof panginatedOrgMembersPropsSchema
>;
export async function getPaginatedOrgMembersQuery(
input: GetPaginatedOrgMembersQueryProps,
) {
const { currentOrg } = await getOrganizations();
noStore();
const offset = (input.page - 1) * input.per_page;
const [column, order] = (input.sort?.split(".") as [
keyof typeof membersToOrganizations.$inferSelect | undefined,
"asc" | "desc" | undefined,
]) ?? ["title", "desc"];
const roles =
(input.role?.split(
".",
) as (typeof membersToOrganizations.$inferSelect.role)[]) ?? [];
const { data, total } = await db.transaction(async (tx) => {
const data = await tx.query.membersToOrganizations.findMany({
offset,
limit: input.per_page,
where: and(
eq(membersToOrganizations.organizationId, currentOrg.id),
or(
input.email
? ilike(
membersToOrganizations.memberEmail,
`%${input.email}%`,
)
: undefined,
roles.length > 0
? inArray(membersToOrganizations.role, roles)
: undefined,
),
),
with: {
member: {
columns: {
id: true,
email: true,
image: true,
name: true,
},
},
},
orderBy:
column && column in membersToOrganizations
? order === "asc"
? asc(membersToOrganizations[column])
: desc(membersToOrganizations[column])
: desc(membersToOrganizations.createdAt),
});
const total = await tx
.select({
count: count(),
})
.from(membersToOrganizations)
.where(
and(
eq(membersToOrganizations.organizationId, currentOrg.id),
or(
input.email
? ilike(
membersToOrganizations.memberEmail,
`%${input.email}%`,
)
: undefined,
roles.length > 0
? inArray(membersToOrganizations.role, roles)
: undefined,
),
),
)
.execute()
.then((res) => res[0]?.count ?? 0);
return { data, total };
});
const pageCount = Math.ceil(total / input.per_page);
return { data, pageCount, total };
}
const panginatedOrgPropsSchema = z.object({
page: z.coerce.number().default(1),
per_page: z.coerce.number().default(10),
sort: z.string().optional(),
email: z.string().optional(),
name: z.string().optional(),
operator: z.string().optional(),
});
type GetPaginatedOrgsQueryProps = z.infer<typeof panginatedOrgPropsSchema>;
export async function getPaginatedOrgsQuery(input: GetPaginatedOrgsQueryProps) {
noStore();
await adminProcedure();
const offset = (input.page - 1) * input.per_page;
const [column, order] = (input.sort?.split(".") as [
keyof typeof organizations.$inferSelect | undefined,
"asc" | "desc" | undefined,
]) ?? ["title", "desc"];
const { data, total } = await db.transaction(async (tx) => {
const response = await tx.query.organizations.findMany({
where: input.email
? ilike(organizations.email, `%${input.email}%`)
: undefined,
with: {
owner: true,
membersToOrganizations: {
with: {
member: true,
},
},
subscriptions: true,
},
offset,
limit: input.per_page,
orderBy:
column && column in organizations
? order === "asc"
? asc(organizations[column])
: desc(organizations[column])
: desc(organizations.createdAt),
});
const data = response.map((org) => {
return {
...org,
members: org.membersToOrganizations.map((mto) => {
return {
...mto.member,
role: mto.role,
};
}),
};
});
const total = await tx
.select({
count: count(),
})
.from(organizations)
.where(
or(
input.email
? ilike(organizations.email, `%${input.email}%`)
: undefined,
),
)
.execute()
.then((res) => res[0]?.count ?? 0);
return { data, total };
});
const pageCount = Math.ceil(total / input.per_page);
return { data, pageCount, total };
}
| alifarooq9/rapidlaunch/starterkits/saas/src/server/actions/organization/queries.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/server/actions/organization/queries.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 4077
} | 18 |
import { createClient } from '@/utils/supabase/server';
import { NextResponse } from 'next/server';
import { NextRequest } from 'next/server';
import { getErrorRedirect, getStatusRedirect } from '@/utils/helpers';
export async function GET(request: NextRequest) {
// The `/auth/callback` route is required for the server-side auth flow implemented
// by the `@supabase/ssr` package. It exchanges an auth code for the user's session.
const requestUrl = new URL(request.url);
const code = requestUrl.searchParams.get('code');
if (code) {
const supabase = createClient();
const { error } = await supabase.auth.exchangeCodeForSession(code);
if (error) {
return NextResponse.redirect(
getErrorRedirect(
`${requestUrl.origin}/dashboard/signin`,
error.name,
"Sorry, we weren't able to log you in. Please try again."
)
);
}
}
// URL to redirect to after sign in process completes
return NextResponse.redirect(
getStatusRedirect(
`${requestUrl.origin}/dashboard/main`,
'Success!',
'You are now signed in.'
)
);
}
| horizon-ui/shadcn-nextjs-boilerplate/app/auth/callback/route.ts | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/app/auth/callback/route.ts",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 398
} | 19 |
interface Props {
text: string;
editable?: boolean;
onChange?: (value: string) => void;
}
export const TextBlock: React.FC<Props> = ({
text,
editable = false,
onChange = () => {}
}) => {
return (
<textarea
className="min-h-[500px] w-full bg-[#1A1B26] p-4 text-sm text-neutral-200 focus:outline-none"
style={{ resize: 'none' }}
value={text}
onChange={(e) => onChange(e.target.value)}
disabled={!editable}
/>
);
};
| horizon-ui/shadcn-nextjs-boilerplate/components/TextBlock.tsx | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/components/TextBlock.tsx",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 199
} | 20 |
/*eslint-disable*/
'use client';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import Notification from '@/components/notification';
import { HiOutlineBellAlert } from 'react-icons/hi2';
import { Switch } from '@/components/ui/switch';
import { HiOutlineCheck } from 'react-icons/hi';
interface Props {
notifications: {
message: string;
time: string;
status?: 'danger' | 'waiting' | 'confirmed';
className?: string;
}[];
}
export default function Settings(props: Props) {
return (
<Card
className={
'mb-5 mr-0 h-min max-w-full pt-8 pb-6 px-6 dark:border-zinc-800 md:mb-0'
}
>
<div>
<p className="text-xl font-extrabold text-zinc-950 dark:text-white md:text-3xl">
Notifications
</p>
<p className="mb-5 mt-1 text-sm font-medium text-zinc-500 dark:text-zinc-400 md:mt-4 md:text-base">
You have 3 unread messages.
</p>
</div>
<Card
className={
'mb-5 h-min flex items-center max-w-full py-4 px-4 dark:border-zinc-800'
}
>
<HiOutlineBellAlert className="w-6 h-6 me-4" />
<div>
<p className="text-zinc-950 dark:text-white font-medium mb-1">
Push Notifications
</p>
<p className="text-zinc-500 dark:text-zinc-400 font-medium">
Send notifications to device.
</p>
</div>
<Switch className="ms-auto" />
</Card>
{props.notifications.map((notification, key) => {
return (
<Notification
className={key < props.notifications.length - 1 ? 'mb-6' : ''}
time={notification.time}
message={notification.message}
/>
);
})}
<Button className="flex h-full w-full max-w-full mt-6 items-center justify-center rounded-lg px-4 py-4 text-base font-medium">
<HiOutlineCheck className="me-2 h-6 w-6" /> Mark all as read
</Button>
</Card>
);
}
| horizon-ui/shadcn-nextjs-boilerplate/components/dashboard/settings/components/notification-settings.tsx | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/components/dashboard/settings/components/notification-settings.tsx",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 950
} | 21 |
import { createContext } from 'react';
import { User } from '@supabase/supabase-js';
interface OpenContextType {
open: boolean;
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
}
type UserDetails = { [x: string]: any } | null;
export const OpenContext = createContext<OpenContextType>(undefined);
export const UserContext = createContext<User | undefined | null>(undefined);
export const UserDetailsContext = createContext<UserDetails | undefined | null>(
undefined
);
| horizon-ui/shadcn-nextjs-boilerplate/contexts/layout.ts | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/contexts/layout.ts",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 134
} | 22 |
/**
* Chrome has a bug with transitions on load since 2012!
*
* To prevent a "pop" of content, you have to disable all transitions until
* the page is done loading.
*
* https://lab.laukstein.com/bug/input
* https://twitter.com/timer150/status/1345217126680899584
*/
body.loading * {
transition: none !important;
}
| horizon-ui/shadcn-nextjs-boilerplate/styles/chrome-bug.css | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/styles/chrome-bug.css",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 100
} | 23 |
import { Database } from '@/types/types_db';
type Price = Database['public']['Tables']['prices']['Row'];
export const getURL = (path?: string) => {
let url =
process?.env?.NEXT_PUBLIC_SITE_URL ?? // Set this to your site URL in production env.
process?.env?.NEXT_PUBLIC_VERCEL_URL ?? // Automatically set by Vercel.
'http://localhost:3000/';
// Make sure to include `https://` when not localhost.
url = url.includes('http') ? url : `https://${url}`;
// Make sure to including trailing `/`.
url = url.charAt(url.length - 1) === '/' ? url : `${url}/`;
if (path) {
path = path.replace(/^\/+/, '');
// Concatenate the URL and the path.
return path ? `${url}/${path}` : url;
}
return url;
};
export const postData = async ({
url,
data
}: {
url: string;
data?: { price: Price };
}) => {
console.log('posting,', url, data);
const res = await fetch(url, {
method: 'POST',
headers: new Headers({ 'Content-Type': 'application/json' }),
credentials: 'same-origin',
body: JSON.stringify(data)
});
if (!res.ok) {
console.log('Error in postData', { url, data, res });
throw Error(res.statusText);
}
return res.json();
};
export const toDateTime = (secs: number) => {
var t = new Date('1970-01-01T00:30:00Z'); // Unix epoch start.
t.setSeconds(secs);
return t;
};
export const calculateTrialEndUnixTimestamp = (
trialPeriodDays: number | null | undefined
) => {
// Check if trialPeriodDays is null, undefined, or less than 2 days
if (
trialPeriodDays === null ||
trialPeriodDays === undefined ||
trialPeriodDays < 2
) {
return undefined;
}
const currentDate = new Date(); // Current date and time
const trialEnd = new Date(
currentDate.getTime() + (trialPeriodDays + 1) * 24 * 60 * 60 * 1000
); // Add trial days
return Math.floor(trialEnd.getTime() / 1000); // Convert to Unix timestamp in seconds
};
const toastKeyMap: { [key: string]: string[] } = {
status: ['status', 'status_description'],
error: ['error', 'error_description']
};
const getToastRedirect = (
path: string,
toastType: string,
toastName: string,
toastDescription: string = '',
disableButton: boolean = false,
arbitraryParams: string = ''
): string => {
const [nameKey, descriptionKey] = toastKeyMap[toastType];
let redirectPath = `${path}?${nameKey}=${encodeURIComponent(toastName)}`;
if (toastDescription) {
redirectPath += `&${descriptionKey}=${encodeURIComponent(
toastDescription
)}`;
}
if (disableButton) {
redirectPath += `&disable_button=true`;
}
if (arbitraryParams) {
redirectPath += `&${arbitraryParams}`;
}
return redirectPath;
};
export const getStatusRedirect = (
path: string,
statusName: string,
statusDescription: string = '',
disableButton: boolean = false,
arbitraryParams: string = ''
) =>
getToastRedirect(
path,
'status',
statusName,
statusDescription,
disableButton,
arbitraryParams
);
export const getErrorRedirect = (
path: string,
errorName: string,
errorDescription: string = '',
disableButton: boolean = false,
arbitraryParams: string = ''
) =>
getToastRedirect(
path,
'error',
errorName,
errorDescription,
disableButton,
arbitraryParams
);
| horizon-ui/shadcn-nextjs-boilerplate/utils/helpers.ts | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/utils/helpers.ts",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 1173
} | 24 |
# FIXME: Configure environment variables for production
# Hosting
# Replace by your domain name
# NEXT_PUBLIC_APP_URL=https://example.com
# Sentry DSN
NEXT_PUBLIC_SENTRY_DSN=
# Stripe
# If you need a real Stripe subscription payment with checkout page, customer portal, webhook, etc.
# You can check out the Next.js Boilerplate Pro: https://nextjs-boilerplate.com/pro-saas-starter-kit
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_live
# Use Stripe test mode price id or production price id
BILLING_PLAN_ENV=prod
######## [BEGIN] SENSITIVE DATA ######## For security reason, don't update the following variables (secret key) directly in this file.
######## Please create a new file named `.env.production.local`, all environment files ending with `.local` won't be tracked by Git.
######## After creating the file, you can add the following variables.
# Database
# Using an incorrect DATABASE_URL value, Next.js build will timeout and you will get the following error: "because it took more than 60 seconds"
# DATABASE_URL=postgresql://postgres@localhost:5432/postgres
# Stripe
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
# Error monitoring
# SENTRY_AUTH_TOKEN=
# Logging ingestion
# LOGTAIL_SOURCE_TOKEN=
######## [END] SENSITIVE DATA
| ixartz/SaaS-Boilerplate/.env.production | {
"file_path": "ixartz/SaaS-Boilerplate/.env.production",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 399
} | 25 |
import type { UserConfig } from '@commitlint/types';
const Configuration: UserConfig = {
extends: ['@commitlint/config-conventional'],
};
export default Configuration;
| ixartz/SaaS-Boilerplate/commitlint.config.ts | {
"file_path": "ixartz/SaaS-Boilerplate/commitlint.config.ts",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 49
} | 26 |
import { getTranslations, unstable_setRequestLocale } from 'next-intl/server';
import { CTA } from '@/templates/CTA';
import { DemoBanner } from '@/templates/DemoBanner';
import { FAQ } from '@/templates/FAQ';
import { Features } from '@/templates/Features';
import { Footer } from '@/templates/Footer';
import { Hero } from '@/templates/Hero';
import { Navbar } from '@/templates/Navbar';
import { Pricing } from '@/templates/Pricing';
import { Sponsors } from '@/templates/Sponsors';
export async function generateMetadata(props: { params: { locale: string } }) {
const t = await getTranslations({
locale: props.params.locale,
namespace: 'Index',
});
return {
title: t('meta_title'),
description: t('meta_description'),
};
}
const IndexPage = (props: { params: { locale: string } }) => {
unstable_setRequestLocale(props.params.locale);
return (
<>
<DemoBanner />
<Navbar />
<Hero />
<Sponsors />
<Features />
<Pricing />
<FAQ />
<CTA />
<Footer />
</>
);
};
export default IndexPage;
| ixartz/SaaS-Boilerplate/src/app/[locale]/(unauth)/page.tsx | {
"file_path": "ixartz/SaaS-Boilerplate/src/app/[locale]/(unauth)/page.tsx",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 411
} | 27 |
import { cva } from 'class-variance-authority';
export const buttonVariants = cva(
'inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50',
{
variants: {
variant: {
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
destructive:
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
outline:
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
secondary:
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
ghost: 'hover:bg-accent hover:text-accent-foreground',
link: 'text-primary underline-offset-4 hover:underline',
},
size: {
default: 'h-10 px-4 py-2',
sm: 'h-9 rounded-md px-3',
lg: 'h-11 rounded-md px-8',
icon: 'size-10',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
},
);
| ixartz/SaaS-Boilerplate/src/components/ui/buttonVariants.ts | {
"file_path": "ixartz/SaaS-Boilerplate/src/components/ui/buttonVariants.ts",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 481
} | 28 |
export const TitleBar = (props: {
title: React.ReactNode;
description?: React.ReactNode;
}) => (
<div className="mb-8">
<div className="text-2xl font-semibold">{props.title}</div>
{props.description && (
<div className="text-sm font-medium text-muted-foreground">
{props.description}
</div>
)}
</div>
);
| ixartz/SaaS-Boilerplate/src/features/dashboard/TitleBar.tsx | {
"file_path": "ixartz/SaaS-Boilerplate/src/features/dashboard/TitleBar.tsx",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 147
} | 29 |
import { notFound } from 'next/navigation';
import { getRequestConfig } from 'next-intl/server';
import { AllLocales } from '@/utils/AppConfig';
// NextJS Boilerplate uses Crowdin as the localization software.
// As a developer, you only need to take care of the English (or another default language) version.
// Other languages are automatically generated and handled by Crowdin.
// The localisation files are synced with Crowdin using GitHub Actions.
// By default, there are 3 ways to sync the message files:
// 1. Automatically sync on push to the `main` branch
// 2. Run manually the workflow on GitHub Actions
// 3. Every 24 hours at 5am, the workflow will run automatically
// Using internationalization in Server Components
export default getRequestConfig(async ({ locale }) => {
// Validate that the incoming `locale` parameter is valid
if (!AllLocales.includes(locale)) {
notFound();
}
return {
messages: (await import(`../locales/${locale}.json`)).default,
};
});
| ixartz/SaaS-Boilerplate/src/libs/i18n.ts | {
"file_path": "ixartz/SaaS-Boilerplate/src/libs/i18n.ts",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 268
} | 30 |
/* eslint-disable react-dom/no-unsafe-target-blank */
import Image from 'next/image';
import { LogoCloud } from '@/features/landing/LogoCloud';
import { Section } from '@/features/landing/Section';
export const Sponsors = () => (
<Section>
<LogoCloud text="Sponsored by">
<a
href="https://clerk.com?utm_source=github&utm_medium=sponsorship&utm_campaign=nextjs-boilerplate"
target="_blank"
rel="noopener"
>
<Image
src="/assets/images/clerk-logo-dark.png"
alt="Clerk"
width="128"
height="37"
/>
</a>
<a
href="https://l.crowdin.com/next-js"
target="_blank"
rel="noopener"
>
<Image
src="/assets/images/crowdin-dark.png"
alt="Crowdin"
width="128"
height="26"
/>
</a>
<a
href="https://sentry.io/for/nextjs/?utm_source=github&utm_medium=paid-community&utm_campaign=general-fy25q1-nextjs&utm_content=github-banner-nextjsboilerplate-logo"
target="_blank"
rel="noopener"
>
<Image
src="/assets/images/sentry-dark.png"
alt="Sentry"
width="128"
height="38"
/>
</a>
<a href="https://nextjs-boilerplate.com/pro-saas-starter-kit">
<Image
src="/assets/images/nextjs-boilerplate-saas.png"
alt="Nextjs SaaS Boilerplate"
width="128"
height="30"
/>
</a>
</LogoCloud>
</Section>
);
| ixartz/SaaS-Boilerplate/src/templates/Sponsors.tsx | {
"file_path": "ixartz/SaaS-Boilerplate/src/templates/Sponsors.tsx",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 792
} | 31 |
export default eventHandler(() => {
return { nitro: 'Is Awesome! asda' };
});
| lucide-icons/lucide/docs/.vitepress/api/test.ts | {
"file_path": "lucide-icons/lucide/docs/.vitepress/api/test.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 26
} | 32 |
import { bundledLanguages, type ThemeRegistration } from 'shikiji';
import { getHighlighter } from 'shikiji';
export type ThemeOptions =
| ThemeRegistration
| { light: ThemeRegistration; dark: ThemeRegistration };
const highLightCode = async (code: string, lang: string, active?: boolean) => {
const highlighter = await getHighlighter({
themes: ['github-light', 'github-dark'],
langs: Object.keys(bundledLanguages),
});
const highlightedCode = highlighter
.codeToHtml(code, {
lang,
themes: {
light: 'github-light',
dark: 'github-dark',
},
defaultColor: false,
})
.replace('shiki-themes', 'shiki-themes vp-code');
return `<div class="language-${lang} ${active ? 'active' : ''}">
<button title="Copy Code" class="copy"></button>
<span class="lang">${lang}</span>
${highlightedCode}
</div>`;
};
export default highLightCode;
| lucide-icons/lucide/docs/.vitepress/lib/codeExamples/highLightCode.ts | {
"file_path": "lucide-icons/lucide/docs/.vitepress/lib/codeExamples/highLightCode.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 323
} | 33 |
import iconNodes from '../../../data/iconNodes';
const getRandomItem = <Item>(items: Item[]): Item =>
items[Math.floor(Math.random() * items.length)];
export default {
async load() {
const icons = Object.entries(iconNodes).map(([name, iconNode]) => ({ name, iconNode }));
const randomIcons = Array.from({ length: 200 }, () => getRandomItem(icons));
return {
icons: randomIcons,
iconsCount: icons.length,
};
},
};
| lucide-icons/lucide/docs/.vitepress/theme/components/home/HomeHeroIconsCard.data.ts | {
"file_path": "lucide-icons/lucide/docs/.vitepress/theme/components/home/HomeHeroIconsCard.data.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 160
} | 34 |
/* eslint-disable no-console */
import { ref, inject, Ref } from 'vue';
export const ICON_STYLE_CONTEXT = Symbol('size');
interface IconSizeContext {
size: Ref<number>;
strokeWidth: Ref<number>;
color: Ref<string>;
absoluteStrokeWidth: Ref<boolean>;
}
export const STYLE_DEFAULTS = {
size: 24,
strokeWidth: 2,
color: 'currentColor',
absoluteStrokeWidth: false,
};
export const iconStyleContext = {
size: ref(24),
strokeWidth: ref(2),
color: ref('currentColor'),
absoluteStrokeWidth: ref(false),
};
export function useIconStyleContext(): IconSizeContext {
const context = inject<IconSizeContext>(ICON_STYLE_CONTEXT);
if (!context) {
throw new Error('useIconStyleContext must be used with useIconStyleProvider');
}
return context;
}
| lucide-icons/lucide/docs/.vitepress/theme/composables/useIconStyle.ts | {
"file_path": "lucide-icons/lucide/docs/.vitepress/theme/composables/useIconStyle.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 262
} | 35 |
import Button from "./Button";
export default function App() {
return <Button />;
}
| lucide-icons/lucide/docs/guide/basics/examples/button-example/App.js | {
"file_path": "lucide-icons/lucide/docs/guide/basics/examples/button-example/App.js",
"repo_id": "lucide-icons/lucide",
"token_count": 25
} | 36 |
import createCodeExamples from '../../.vitepress/lib/codeExamples/createLabCodeExamples';
export default {
async load() {
const codeExamples = await createCodeExamples();
return {
codeExamples,
};
},
};
| lucide-icons/lucide/docs/icons/lab/codeExamples.data.ts | {
"file_path": "lucide-icons/lucide/docs/icons/lab/codeExamples.data.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 74
} | 37 |
import fs from 'fs';
import path from 'path';
import { renderIconsObject } from '@lucide/build-icons';
import { readSvgDirectory, toCamelCase } from '@lucide/helpers';
const currentDir = process.cwd();
const ICONS_DIR = path.resolve(currentDir, '../icons');
const svgFiles = readSvgDirectory(ICONS_DIR);
const icons = renderIconsObject(svgFiles, ICONS_DIR, true);
const iconNodesDirectory = path.resolve(currentDir, '.vitepress/data', 'iconNodes');
if (fs.existsSync(iconNodesDirectory)) {
fs.rmSync(iconNodesDirectory, { recursive: true, force: true });
}
if (!fs.existsSync(iconNodesDirectory)) {
fs.mkdirSync(iconNodesDirectory);
}
const iconIndexFile = path.resolve(iconNodesDirectory, `index.ts`);
const iconIndexFileImports = [];
const iconIndexFileExports = [];
const iconIndexFileDefaultExports = [];
const writeIconFiles = Object.entries(icons).map(async ([iconName, { children }]) => {
// We need to use .node.json because the there is a file called package, which is a reserved word for packages.
const location = path.resolve(iconNodesDirectory, `${iconName}.node.json`);
const iconNode = children.map(({ name, attributes }) => [name, attributes]);
const output = JSON.stringify(iconNode, null, 2);
await fs.promises.writeFile(location, output, 'utf-8');
iconIndexFileImports.push(
`import ${toCamelCase(iconName)}Node from './${iconName}.node.json' assert { type: "json" };`,
);
iconIndexFileExports.push(` ${toCamelCase(iconName)}Node as ${toCamelCase(iconName)},`);
iconIndexFileDefaultExports.push(` '${iconName}': ${toCamelCase(iconName)}Node,`);
});
try {
await Promise.all(writeIconFiles);
await fs.promises.writeFile(
iconIndexFile,
`\
${iconIndexFileImports.join('\n')}
export {
${iconIndexFileExports.join('\n')}
}
export default {
${iconIndexFileDefaultExports.join('\n')}
}
`,
'utf-8',
);
console.log('Successfully write', writeIconFiles.length, 'iconNodes.');
} catch (error) {
throw new Error(`Something went wrong generating iconNode files,\n ${error}`);
}
| lucide-icons/lucide/docs/scripts/writeIconNodes.mjs | {
"file_path": "lucide-icons/lucide/docs/scripts/writeIconNodes.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 696
} | 38 |
module.exports = {
root: true,
overrides: [
{
files: ['*.ts'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:@angular-eslint/recommended',
'plugin:@angular-eslint/template/process-inline-templates',
'prettier',
],
rules: {
'@angular-eslint/directive-selector': [
'error',
{
type: 'attribute',
prefix: 'lucide',
style: 'camelCase',
},
],
'@angular-eslint/component-selector': [
'error',
{
type: 'element',
prefix: ['lucide', 'i', 'span'],
style: 'kebab-case',
},
],
},
},
{
files: ['*.html'],
extends: ['plugin:@angular-eslint/template/recommended'],
rules: {},
},
],
};
| lucide-icons/lucide/packages/lucide-angular/.eslintrc.js | {
"file_path": "lucide-icons/lucide/packages/lucide-angular/.eslintrc.js",
"repo_id": "lucide-icons/lucide",
"token_count": 488
} | 39 |
import { LucideIconData, LucideIcons } from '../icons/types';
import { InjectionToken } from '@angular/core';
export interface LucideIconProviderInterface {
hasIcon(name: string): boolean;
getIcon(name: string): LucideIconData | null;
}
export const LUCIDE_ICONS = new InjectionToken<LucideIconProviderInterface>('LucideIcons', {
factory: () => new LucideIconProvider({}),
});
export class LucideIconProvider implements LucideIconProviderInterface {
constructor(private icons: LucideIcons) {}
getIcon(name: string): LucideIconData | null {
return this.hasIcon(name) ? this.icons[name] : null;
}
hasIcon(name: string): boolean {
return typeof this.icons === 'object' && name in this.icons;
}
}
| lucide-icons/lucide/packages/lucide-angular/src/lib/lucide-icon.provider.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-angular/src/lib/lucide-icon.provider.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 224
} | 40 |
import { type FunctionComponent, type JSX } from 'preact';
export type IconNode = [elementName: keyof JSX.IntrinsicElements, attrs: Record<string, string>][];
export interface LucideProps extends Partial<Omit<JSX.SVGAttributes, 'ref' | 'size'>> {
color?: string;
size?: string | number;
strokeWidth?: string | number;
absoluteStrokeWidth?: boolean;
}
export type LucideIcon = FunctionComponent<LucideProps>;
| lucide-icons/lucide/packages/lucide-preact/src/types.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-preact/src/types.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 132
} | 41 |
import { describe, it, expect } from 'vitest';
import { Suspense, lazy } from 'react';
import { render, waitFor } from '@testing-library/react';
import dynamicIconImports from '../src/dynamicIconImports';
import { LucideProps } from '../src/types';
describe('Using dynamicImports', () => {
it('should render icons dynamically by using the dynamicIconImports module', async () => {
interface IconProps extends Omit<LucideProps, 'ref'> {
name: keyof typeof dynamicIconImports;
}
const Icon = ({ name, ...props }: IconProps) => {
const LucideIcon = lazy(dynamicIconImports[name]);
return (
<Suspense fallback={null}>
<LucideIcon {...props} />
</Suspense>
);
};
const { container, getByLabelText } = render(
<Icon
aria-label="smile"
name="smile"
size={48}
stroke="red"
absoluteStrokeWidth
/>,
);
await waitFor(() => getByLabelText('smile'));
expect(container.innerHTML).toMatchSnapshot();
});
});
| lucide-icons/lucide/packages/lucide-react/tests/dynamicImports.spec.tsx | {
"file_path": "lucide-icons/lucide/packages/lucide-react/tests/dynamicImports.spec.tsx",
"repo_id": "lucide-icons/lucide",
"token_count": 410
} | 42 |
/* eslint-disable import/no-extraneous-dependencies */
import { stringify } from 'svgson';
import { format } from 'prettier';
import { appendFile } from '@lucide/helpers';
export default function generateSprite(svgs, packageDir, license) {
const symbols = svgs.map(({ name, parsedSvg }) => ({
name: 'symbol',
type: 'element',
attributes: {
id: name,
},
children: parsedSvg.children,
}));
const spriteSvgObject = {
name: 'svg',
type: 'element',
attributes: {
xmlns: 'http://www.w3.org/2000/svg',
version: '1.1',
},
children: [
{
name: 'defs',
type: 'element',
children: symbols,
},
],
};
const spriteSvg = stringify(spriteSvgObject);
const prettifiedSprite = format(spriteSvg, { parser: 'babel' }).replace(/;/g, '');
const xmlMeta = `<?xml version="1.0" encoding="utf-8"?>\n<!-- ${license} -->\n`;
appendFile(xmlMeta, `sprite.svg`, packageDir);
appendFile(prettifiedSprite, `sprite.svg`, packageDir);
}
| lucide-icons/lucide/packages/lucide-static/scripts/generateSprite.mjs | {
"file_path": "lucide-icons/lucide/packages/lucide-static/scripts/generateSprite.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 420
} | 43 |
import { describe, it, expect } from 'vitest';
import { render } from '@testing-library/svelte';
import { Icon } from '../src/lucide-svelte';
import { airVent } from './testIconNodes';
describe('Using Icon Component', () => {
it('should render icon based on a iconNode', async () => {
const { container } = render(Icon, {
props: {
iconNode: airVent,
size: 48,
color: 'red',
absoluteStrokeWidth: true,
},
});
expect(container.firstChild).toBeDefined();
});
it('should render icon and match snapshot', async () => {
const { container } = render(Icon, {
props: {
iconNode: airVent,
size: 48,
color: 'red',
absoluteStrokeWidth: true,
},
});
expect(container.firstChild).toMatchSnapshot();
});
});
| lucide-icons/lucide/packages/lucide-svelte/tests/Icon.spec.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-svelte/tests/Icon.spec.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 331
} | 44 |
import { Component } from 'vue';
import defaultAttributes from './defaultAttributes';
import { toKebabCase } from '@lucide/shared';
var showDeprecationWarning = true;
type IconNode = [elementName: string, attrs: Record<string, string>][];
export default (iconName: string, iconNode: IconNode): Component => ({
name: iconName,
functional: true,
props: {
color: {
type: String,
default: 'currentColor',
},
size: {
type: Number,
default: 24,
},
strokeWidth: {
type: Number,
default: 2,
},
absoluteStrokeWidth: {
type: Boolean,
default: false,
},
defaultClass: {
type: String,
default: `lucide-icon lucide lucide-${toKebabCase(iconName).replace('-icon', '')}`,
},
},
render(
createElement,
{ props: { color, size, strokeWidth, absoluteStrokeWidth, defaultClass }, data, children = [] },
) {
if (showDeprecationWarning) {
console.warn(
'[Lucide Vue] This package will be deprecated end of 2023. Please upgrade to Vue 3 and use the latest lucide package for Vue.',
);
showDeprecationWarning = false;
}
return createElement(
'svg',
{
// prettier-ignore
class: [defaultClass, data.class, data.staticClass, data.attrs && data.attrs.class].filter(Boolean),
style: [data.style, data.staticStyle, data.attrs && data.attrs.style].filter(Boolean),
attrs: {
...defaultAttributes,
width: size,
height: size,
stroke: color,
'stroke-width': absoluteStrokeWidth
? (Number(strokeWidth) * 24) / Number(size)
: strokeWidth,
...data.attrs,
},
on: data?.on || {},
},
[...iconNode.map(([tag, attrs]) => createElement(String(tag), { attrs })), ...children],
);
},
});
| lucide-icons/lucide/packages/lucide-vue/src/createLucideIcon.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-vue/src/createLucideIcon.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 783
} | 45 |
import { IconNode, IconNodeChild, SVGProps } from './types';
/**
* Creates a new HTMLElement from icon node
* @param {string} tag
* @param {object} attrs
* @param {array} children
* @returns {HTMLElement}
*/
const createElement = (tag: string, attrs: SVGProps, children: IconNodeChild[] = []) => {
const element = document.createElementNS('http://www.w3.org/2000/svg', tag);
Object.keys(attrs).forEach((name) => {
element.setAttribute(name, String(attrs[name]));
});
if (children.length) {
children.forEach((child) => {
const childElement = createElement(...child);
element.appendChild(childElement);
});
}
return element;
};
/**
* Creates a new HTMLElement from icon node
* @param {[tag: string, attrs: object, children: array]} iconNode
* @returns {HTMLElement}
*/
export default ([tag, attrs, children]: IconNode) => createElement(tag, attrs, children);
| lucide-icons/lucide/packages/lucide/src/createElement.ts | {
"file_path": "lucide-icons/lucide/packages/lucide/src/createElement.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 308
} | 46 |
export * from './utils';
export * from './utility-types';
| lucide-icons/lucide/packages/shared/src/index.ts | {
"file_path": "lucide-icons/lucide/packages/shared/src/index.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 19
} | 47 |
import path from 'path';
import { writeFile, getCurrentDirPath, readAllMetadata } from '../tools/build-helpers/helpers.mjs';
const currentDir = getCurrentDirPath(import.meta.url);
const ICONS_DIR = path.resolve(currentDir, '../icons');
const icons = readAllMetadata(ICONS_DIR);
const tags = Object.keys(icons)
.sort()
.reduce((acc, iconName) => {
acc[iconName] = icons[iconName].tags;
return acc;
}, {});
const tagsContent = JSON.stringify(tags, null, 2);
writeFile(tagsContent, 'tags.json', path.resolve(process.cwd()));
| lucide-icons/lucide/scripts/migrateIconsToTags.mjs | {
"file_path": "lucide-icons/lucide/scripts/migrateIconsToTags.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 189
} | 48 |
/* eslint-disable import/prefer-default-export */
import { hash } from './hash.mjs';
/**
* Generate Hashed string based on name and attributes
*
* @param {object} seed
* @param {string} seed.name A name, for example an icon name
* @param {object} seed.attributes An object of SVGElement Attrbutes
* @returns {string} A hashed string of 6 characters
*/
export const generateHashedKey = ({ name, attributes }) => hash(JSON.stringify([name, attributes]));
| lucide-icons/lucide/tools/build-helpers/src/generateHashedKey.mjs | {
"file_path": "lucide-icons/lucide/tools/build-helpers/src/generateHashedKey.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 135
} | 49 |
/* eslint-disable import/prefer-default-export */
import fs from 'fs';
import path from 'path';
/**
* writes content to a file
*
* @param {string} content
* @param {string} fileName
* @param {string} outputDirectory
*/
export const writeFile = (content, fileName, outputDirectory) =>
fs.writeFileSync(path.join(outputDirectory, fileName), content, 'utf-8');
| lucide-icons/lucide/tools/build-helpers/src/writeFile.mjs | {
"file_path": "lucide-icons/lucide/tools/build-helpers/src/writeFile.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 111
} | 50 |
import path from 'path';
import { readSvgDirectory } from '@lucide/helpers';
async function getIconMetaData(iconDirectory) {
const iconJsons = readSvgDirectory(iconDirectory, '.json');
const aliasesEntries = await Promise.all(
iconJsons.map(async (jsonFile) => {
/** eslint-disable */
const file = await import(path.join(iconDirectory, jsonFile), { assert: { type: 'json' } });
return [path.basename(jsonFile, '.json'), file.default];
}),
);
return Object.fromEntries(aliasesEntries);
}
export default getIconMetaData;
| lucide-icons/lucide/tools/build-icons/utils/getIconMetaData.mjs | {
"file_path": "lucide-icons/lucide/tools/build-icons/utils/getIconMetaData.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 190
} | 51 |
import LoginModal from "~/components/layout/login-modal";
export default async function Login() {
return <LoginModal />;
}
| moinulmoin/chadnext/src/app/[locale]/@loginDialog/(.)login/page.tsx | {
"file_path": "moinulmoin/chadnext/src/app/[locale]/@loginDialog/(.)login/page.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 39
} | 52 |
import Link from "next/link";
import { Card } from "~/components/ui/card";
import { getProjects } from "./action";
import CreateProjectModal from "./create-project-modal";
export default async function Projects() {
const projects = await getProjects();
return (
<div className="grid gap-4 md:grid-cols-3 lg:grid-cols-4 ">
<CreateProjectModal />
{projects.map((project) => (
<Card
role="button"
key={project.id}
className="relative flex flex-col items-center justify-center gap-y-2.5 p-8 text-center hover:bg-accent"
>
<h4 className="font-medium ">{project.name}</h4>
<p className=" text-muted-foreground">{`https://${project.domain}`}</p>
<Link
href={`/dashboard/projects/${project.id}`}
className="absolute inset-0 "
>
<span className="sr-only">View project details</span>
</Link>
</Card>
))}
</div>
);
}
| moinulmoin/chadnext/src/app/[locale]/dashboard/projects/page.tsx | {
"file_path": "moinulmoin/chadnext/src/app/[locale]/dashboard/projects/page.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 438
} | 53 |
import { createRouteHandler } from "uploadthing/next";
import { ourFileRouter } from "./core";
export const runtime = "nodejs";
// Export routes for Next App Router
export const { GET, POST } = createRouteHandler({
router: ourFileRouter,
});
| moinulmoin/chadnext/src/app/api/uploadthing/route.ts | {
"file_path": "moinulmoin/chadnext/src/app/api/uploadthing/route.ts",
"repo_id": "moinulmoin/chadnext",
"token_count": 70
} | 54 |
"use client";
import { useRouter } from "next/navigation";
import Icons from "./shared/icons";
import { Button } from "./ui/button";
export default function GoBack() {
const router = useRouter();
return (
<Button
className="mb-5"
size="icon"
variant="secondary"
onClick={() => router.back()}
>
<span className="sr-only">Go back</span>
<Icons.moveLeft className="h-5 w-5" />
</Button>
);
}
| moinulmoin/chadnext/src/components/go-back.tsx | {
"file_path": "moinulmoin/chadnext/src/components/go-back.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 179
} | 55 |
import { LogOutIcon } from "lucide-react";
import { logout } from "~/actions/auth";
import { Button } from "../ui/button";
export default function LogoutButton({ className }: { className?: string }) {
return (
<form action={logout} className={className}>
<Button type="submit" variant="destructive">
<LogOutIcon className="mr-2 h-4 w-4" />
<span>Log out</span>
</Button>
</form>
);
}
| moinulmoin/chadnext/src/components/shared/logout-button.tsx | {
"file_path": "moinulmoin/chadnext/src/components/shared/logout-button.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 163
} | 56 |
import { createI18nMiddleware } from "next-international/middleware";
import { type NextRequest } from "next/server";
const I18nMiddleware = createI18nMiddleware({
locales: ["en", "fr"],
defaultLocale: "en",
});
export function middleware(request: NextRequest) {
return I18nMiddleware(request);
}
export const config = {
matcher: [
"/((?!api|static|.*\\..*|_next|favicon.ico|sitemap.xml|robots.txt).*)",
],
};
| moinulmoin/chadnext/src/middleware.ts | {
"file_path": "moinulmoin/chadnext/src/middleware.ts",
"repo_id": "moinulmoin/chadnext",
"token_count": 152
} | 57 |
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion";
interface FAQProps {
question: string;
answer: string;
value: string;
}
const FAQList: FAQProps[] = [
{
question: "Is this template free?",
answer: "Yes. It is a free NextJS Shadcn template.",
value: "item-1",
},
{
question: "Duis aute irure dolor in reprehenderit in voluptate velit?",
answer:
"Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sint labore quidem quam consectetur sapiente, iste rerum reiciendis animi nihil nostrum sit quo, modi quod.",
value: "item-2",
},
{
question:
"Lorem ipsum dolor sit amet Consectetur natus dolor minus quibusdam?",
answer:
"Lorem ipsum dolor sit amet consectetur, adipisicing elit. Labore qui nostrum reiciendis veritatis.",
value: "item-3",
},
{
question: "Excepteur sint occaecat cupidata non proident sunt?",
answer: "Lorem ipsum dolor sit amet consectetur, adipisicing elit.",
value: "item-4",
},
{
question:
"Enim ad minim veniam, quis nostrud exercitation ullamco laboris?",
answer: "consectetur adipisicing elit. Sint labore.",
value: "item-5",
},
];
export const FAQSection = () => {
return (
<section id="faq" className="container md:w-[700px] py-24 sm:py-32">
<div className="text-center mb-8">
<h2 className="text-lg text-primary text-center mb-2 tracking-wider">
FAQS
</h2>
<h2 className="text-3xl md:text-4xl text-center font-bold">
Common Questions
</h2>
</div>
<Accordion type="single" collapsible className="AccordionRoot">
{FAQList.map(({ question, answer, value }) => (
<AccordionItem key={value} value={value}>
<AccordionTrigger className="text-left">
{question}
</AccordionTrigger>
<AccordionContent>{answer}</AccordionContent>
</AccordionItem>
))}
</Accordion>
</section>
);
};
| nobruf/shadcn-landing-page/components/layout/sections/faq.tsx | {
"file_path": "nobruf/shadcn-landing-page/components/layout/sections/faq.tsx",
"repo_id": "nobruf/shadcn-landing-page",
"token_count": 880
} | 58 |
/** @type {import('postcss-load-config').Config} */
const config = {
plugins: {
tailwindcss: {},
},
};
export default config;
| nobruf/shadcn-landing-page/postcss.config.mjs | {
"file_path": "nobruf/shadcn-landing-page/postcss.config.mjs",
"repo_id": "nobruf/shadcn-landing-page",
"token_count": 48
} | 59 |
import { notFound } from "next/navigation"
import { dashboardConfig } from "@/config/dashboard"
import { getCurrentUser } from "@/lib/session"
import { MainNav } from "@/components/main-nav"
import { DashboardNav } from "@/components/nav"
import { SiteFooter } from "@/components/site-footer"
import { UserAccountNav } from "@/components/user-account-nav"
interface DashboardLayoutProps {
children?: React.ReactNode
}
export default async function DashboardLayout({
children,
}: DashboardLayoutProps) {
const user = await getCurrentUser()
if (!user) {
return notFound()
}
return (
<div className="flex min-h-screen flex-col space-y-6">
<header className="sticky top-0 z-40 border-b bg-background">
<div className="container flex h-16 items-center justify-between py-4">
<MainNav items={dashboardConfig.mainNav} />
<UserAccountNav
user={{
name: user.name,
image: user.image,
email: user.email,
}}
/>
</div>
</header>
<div className="container grid flex-1 gap-12 md:grid-cols-[200px_1fr]">
<aside className="hidden w-[200px] flex-col md:flex">
<DashboardNav items={dashboardConfig.sidebarNav} />
</aside>
<main className="flex w-full flex-1 flex-col overflow-hidden">
{children}
</main>
</div>
<SiteFooter className="border-t" />
</div>
)
}
| shadcn-ui/taxonomy/app/(dashboard)/dashboard/layout.tsx | {
"file_path": "shadcn-ui/taxonomy/app/(dashboard)/dashboard/layout.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 607
} | 60 |
import { notFound } from "next/navigation"
import { allAuthors, allPosts } from "contentlayer/generated"
import { Mdx } from "@/components/mdx-components"
import "@/styles/mdx.css"
import { Metadata } from "next"
import Image from "next/image"
import Link from "next/link"
import { env } from "@/env.mjs"
import { absoluteUrl, cn, formatDate } from "@/lib/utils"
import { buttonVariants } from "@/components/ui/button"
import { Icons } from "@/components/icons"
interface PostPageProps {
params: {
slug: string[]
}
}
async function getPostFromParams(params) {
const slug = params?.slug?.join("/")
const post = allPosts.find((post) => post.slugAsParams === slug)
if (!post) {
null
}
return post
}
export async function generateMetadata({
params,
}: PostPageProps): Promise<Metadata> {
const post = await getPostFromParams(params)
if (!post) {
return {}
}
const url = env.NEXT_PUBLIC_APP_URL
const ogUrl = new URL(`${url}/api/og`)
ogUrl.searchParams.set("heading", post.title)
ogUrl.searchParams.set("type", "Blog Post")
ogUrl.searchParams.set("mode", "dark")
return {
title: post.title,
description: post.description,
authors: post.authors.map((author) => ({
name: author,
})),
openGraph: {
title: post.title,
description: post.description,
type: "article",
url: absoluteUrl(post.slug),
images: [
{
url: ogUrl.toString(),
width: 1200,
height: 630,
alt: post.title,
},
],
},
twitter: {
card: "summary_large_image",
title: post.title,
description: post.description,
images: [ogUrl.toString()],
},
}
}
export async function generateStaticParams(): Promise<
PostPageProps["params"][]
> {
return allPosts.map((post) => ({
slug: post.slugAsParams.split("/"),
}))
}
export default async function PostPage({ params }: PostPageProps) {
const post = await getPostFromParams(params)
if (!post) {
notFound()
}
const authors = post.authors.map((author) =>
allAuthors.find(({ slug }) => slug === `/authors/${author}`)
)
return (
<article className="container relative max-w-3xl py-6 lg:py-10">
<Link
href="/blog"
className={cn(
buttonVariants({ variant: "ghost" }),
"absolute left-[-200px] top-14 hidden xl:inline-flex"
)}
>
<Icons.chevronLeft className="mr-2 h-4 w-4" />
See all posts
</Link>
<div>
{post.date && (
<time
dateTime={post.date}
className="block text-sm text-muted-foreground"
>
Published on {formatDate(post.date)}
</time>
)}
<h1 className="mt-2 inline-block font-heading text-4xl leading-tight lg:text-5xl">
{post.title}
</h1>
{authors?.length ? (
<div className="mt-4 flex space-x-4">
{authors.map((author) =>
author ? (
<Link
key={author._id}
href={`https://twitter.com/${author.twitter}`}
className="flex items-center space-x-2 text-sm"
>
<Image
src={author.avatar}
alt={author.title}
width={42}
height={42}
className="rounded-full bg-white"
/>
<div className="flex-1 text-left leading-tight">
<p className="font-medium">{author.title}</p>
<p className="text-[12px] text-muted-foreground">
@{author.twitter}
</p>
</div>
</Link>
) : null
)}
</div>
) : null}
</div>
{post.image && (
<Image
src={post.image}
alt={post.title}
width={720}
height={405}
className="my-8 rounded-md border bg-muted transition-colors"
priority
/>
)}
<Mdx code={post.body.code} />
<hr className="mt-12" />
<div className="flex justify-center py-6 lg:py-10">
<Link href="/blog" className={cn(buttonVariants({ variant: "ghost" }))}>
<Icons.chevronLeft className="mr-2 h-4 w-4" />
See all posts
</Link>
</div>
</article>
)
}
| shadcn-ui/taxonomy/app/(marketing)/blog/[...slug]/page.tsx | {
"file_path": "shadcn-ui/taxonomy/app/(marketing)/blog/[...slug]/page.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 2171
} | 61 |
"use client"
import * as React from "react"
import { useTheme } from "next-themes"
import { Button } from "@/components/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/components/ui/dropdown-menu"
import { Icons } from "@/components/icons"
export function ModeToggle() {
const { setTheme } = useTheme()
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="sm" className="h-8 w-8 px-0">
<Icons.sun className="rotate-0 scale-100 transition-all dark:-rotate-90 dark:scale-0" />
<Icons.moon className="absolute rotate-90 scale-0 transition-all dark:rotate-0 dark:scale-100" />
<span className="sr-only">Toggle theme</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem onClick={() => setTheme("light")}>
<Icons.sun className="mr-2 h-4 w-4" />
<span>Light</span>
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("dark")}>
<Icons.moon className="mr-2 h-4 w-4" />
<span>Dark</span>
</DropdownMenuItem>
<DropdownMenuItem onClick={() => setTheme("system")}>
<Icons.laptop className="mr-2 h-4 w-4" />
<span>System</span>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}
| shadcn-ui/taxonomy/components/mode-toggle.tsx | {
"file_path": "shadcn-ui/taxonomy/components/mode-toggle.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 609
} | 62 |
import * as React from "react"
import { VariantProps, cva } from "class-variance-authority"
import { cn } from "@/lib/utils"
const alertVariants = cva(
"relative w-full rounded-lg border p-4 [&>svg]:absolute [&>svg]:text-foreground [&>svg]:left-4 [&>svg]:top-4 [&>svg+div]:translate-y-[-3px] [&:has(svg)]:pl-11",
{
variants: {
variant: {
default: "bg-background text-foreground",
destructive:
"text-destructive border-destructive/50 dark:border-destructive [&>svg]:text-destructive text-destructive",
},
},
defaultVariants: {
variant: "default",
},
}
)
const Alert = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement> & VariantProps<typeof alertVariants>
>(({ className, variant, ...props }, ref) => (
<div
ref={ref}
role="alert"
className={cn(alertVariants({ variant }), className)}
{...props}
/>
))
Alert.displayName = "Alert"
const AlertTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h5
ref={ref}
className={cn("mb-1 font-medium leading-none tracking-tight", className)}
{...props}
/>
))
AlertTitle.displayName = "AlertTitle"
const AlertDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("text-sm [&_p]:leading-relaxed", className)}
{...props}
/>
))
AlertDescription.displayName = "AlertDescription"
export { Alert, AlertTitle, AlertDescription }
| shadcn-ui/taxonomy/components/ui/alert.tsx | {
"file_path": "shadcn-ui/taxonomy/components/ui/alert.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 599
} | 63 |
"use client"
import * as React from "react"
import * as TogglePrimitive from "@radix-ui/react-toggle"
import { VariantProps, cva } from "class-variance-authority"
import { cn } from "@/lib/utils"
const toggleVariants = cva(
"inline-flex items-center justify-center rounded-md text-sm font-medium transition-colors data-[state=on]:bg-accent data-[state=on]:text-accent-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 ring-offset-background hover:bg-muted hover:text-muted-foreground",
{
variants: {
variant: {
default: "bg-transparent",
outline:
"bg-transparent border border-input 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/taxonomy/components/ui/toggle.tsx | {
"file_path": "shadcn-ui/taxonomy/components/ui/toggle.tsx",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 554
} | 64 |
import { PrismaClient } from "@prisma/client"
declare global {
// eslint-disable-next-line no-var
var cachedPrisma: PrismaClient
}
let prisma: PrismaClient
if (process.env.NODE_ENV === "production") {
prisma = new PrismaClient()
} else {
if (!global.cachedPrisma) {
global.cachedPrisma = new PrismaClient()
}
prisma = global.cachedPrisma
}
export const db = prisma
| shadcn-ui/taxonomy/lib/db.ts | {
"file_path": "shadcn-ui/taxonomy/lib/db.ts",
"repo_id": "shadcn-ui/taxonomy",
"token_count": 139
} | 65 |
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/registry/new-york/ui/avatar"
import { Button } from "@/registry/new-york/ui/button"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuGroup,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuShortcut,
DropdownMenuTrigger,
} from "@/registry/new-york/ui/dropdown-menu"
export function UserNav() {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="relative h-8 w-8 rounded-full">
<Avatar className="h-8 w-8">
<AvatarImage src="/avatars/01.png" alt="@shadcn" />
<AvatarFallback>SC</AvatarFallback>
</Avatar>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent className="w-56" align="end" forceMount>
<DropdownMenuLabel className="font-normal">
<div className="flex flex-col space-y-1">
<p className="text-sm font-medium leading-none">shadcn</p>
<p className="text-xs leading-none text-muted-foreground">
[email protected]
</p>
</div>
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
<DropdownMenuItem>
Profile
<DropdownMenuShortcut>P</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>
Billing
<DropdownMenuShortcut>B</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>
Settings
<DropdownMenuShortcut>S</DropdownMenuShortcut>
</DropdownMenuItem>
<DropdownMenuItem>New Team</DropdownMenuItem>
</DropdownMenuGroup>
<DropdownMenuSeparator />
<DropdownMenuItem>
Log out
<DropdownMenuShortcut>Q</DropdownMenuShortcut>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/dashboard/components/user-nav.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/dashboard/components/user-nav.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 905
} | 66 |
import addDays from "date-fns/addDays"
import addHours from "date-fns/addHours"
import format from "date-fns/format"
import nextSaturday from "date-fns/nextSaturday"
import {
Archive,
ArchiveX,
Clock,
Forward,
MoreVertical,
Reply,
ReplyAll,
Trash2,
} from "lucide-react"
import {
DropdownMenuContent,
DropdownMenuItem,
} from "@/registry/default/ui/dropdown-menu"
import {
Avatar,
AvatarFallback,
AvatarImage,
} from "@/registry/new-york/ui/avatar"
import { Button } from "@/registry/new-york/ui/button"
import { Calendar } from "@/registry/new-york/ui/calendar"
import {
DropdownMenu,
DropdownMenuTrigger,
} from "@/registry/new-york/ui/dropdown-menu"
import { Label } from "@/registry/new-york/ui/label"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/registry/new-york/ui/popover"
import { Separator } from "@/registry/new-york/ui/separator"
import { Switch } from "@/registry/new-york/ui/switch"
import { Textarea } from "@/registry/new-york/ui/textarea"
import {
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/registry/new-york/ui/tooltip"
import { Mail } from "@/app/(app)/examples/mail/data"
interface MailDisplayProps {
mail: Mail | null
}
export function MailDisplay({ mail }: MailDisplayProps) {
const today = new Date()
return (
<div className="flex h-full flex-col">
<div className="flex items-center p-2">
<div className="flex items-center gap-2">
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<Archive className="h-4 w-4" />
<span className="sr-only">Archive</span>
</Button>
</TooltipTrigger>
<TooltipContent>Archive</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<ArchiveX className="h-4 w-4" />
<span className="sr-only">Move to junk</span>
</Button>
</TooltipTrigger>
<TooltipContent>Move to junk</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<Trash2 className="h-4 w-4" />
<span className="sr-only">Move to trash</span>
</Button>
</TooltipTrigger>
<TooltipContent>Move to trash</TooltipContent>
</Tooltip>
<Separator orientation="vertical" className="mx-1 h-6" />
<Tooltip>
<Popover>
<PopoverTrigger asChild>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<Clock className="h-4 w-4" />
<span className="sr-only">Snooze</span>
</Button>
</TooltipTrigger>
</PopoverTrigger>
<PopoverContent className="flex w-[535px] p-0">
<div className="flex flex-col gap-2 border-r px-2 py-4">
<div className="px-4 text-sm font-medium">Snooze until</div>
<div className="grid min-w-[250px] gap-1">
<Button
variant="ghost"
className="justify-start font-normal"
>
Later today{" "}
<span className="ml-auto text-muted-foreground">
{format(addHours(today, 4), "E, h:m b")}
</span>
</Button>
<Button
variant="ghost"
className="justify-start font-normal"
>
Tomorrow
<span className="ml-auto text-muted-foreground">
{format(addDays(today, 1), "E, h:m b")}
</span>
</Button>
<Button
variant="ghost"
className="justify-start font-normal"
>
This weekend
<span className="ml-auto text-muted-foreground">
{format(nextSaturday(today), "E, h:m b")}
</span>
</Button>
<Button
variant="ghost"
className="justify-start font-normal"
>
Next week
<span className="ml-auto text-muted-foreground">
{format(addDays(today, 7), "E, h:m b")}
</span>
</Button>
</div>
</div>
<div className="p-2">
<Calendar />
</div>
</PopoverContent>
</Popover>
<TooltipContent>Snooze</TooltipContent>
</Tooltip>
</div>
<div className="ml-auto flex items-center gap-2">
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<Reply className="h-4 w-4" />
<span className="sr-only">Reply</span>
</Button>
</TooltipTrigger>
<TooltipContent>Reply</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<ReplyAll className="h-4 w-4" />
<span className="sr-only">Reply all</span>
</Button>
</TooltipTrigger>
<TooltipContent>Reply all</TooltipContent>
</Tooltip>
<Tooltip>
<TooltipTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<Forward className="h-4 w-4" />
<span className="sr-only">Forward</span>
</Button>
</TooltipTrigger>
<TooltipContent>Forward</TooltipContent>
</Tooltip>
</div>
<Separator orientation="vertical" className="mx-2 h-6" />
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon" disabled={!mail}>
<MoreVertical className="h-4 w-4" />
<span className="sr-only">More</span>
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuItem>Mark as unread</DropdownMenuItem>
<DropdownMenuItem>Star thread</DropdownMenuItem>
<DropdownMenuItem>Add label</DropdownMenuItem>
<DropdownMenuItem>Mute thread</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
<Separator />
{mail ? (
<div className="flex flex-1 flex-col">
<div className="flex items-start p-4">
<div className="flex items-start gap-4 text-sm">
<Avatar>
<AvatarImage alt={mail.name} />
<AvatarFallback>
{mail.name
.split(" ")
.map((chunk) => chunk[0])
.join("")}
</AvatarFallback>
</Avatar>
<div className="grid gap-1">
<div className="font-semibold">{mail.name}</div>
<div className="line-clamp-1 text-xs">{mail.subject}</div>
<div className="line-clamp-1 text-xs">
<span className="font-medium">Reply-To:</span> {mail.email}
</div>
</div>
</div>
{mail.date && (
<div className="ml-auto text-xs text-muted-foreground">
{format(new Date(mail.date), "PPpp")}
</div>
)}
</div>
<Separator />
<div className="flex-1 whitespace-pre-wrap p-4 text-sm">
{mail.text}
</div>
<Separator className="mt-auto" />
<div className="p-4">
<form>
<div className="grid gap-4">
<Textarea
className="p-4"
placeholder={`Reply ${mail.name}...`}
/>
<div className="flex items-center">
<Label
htmlFor="mute"
className="flex items-center gap-2 text-xs font-normal"
>
<Switch id="mute" aria-label="Mute thread" /> Mute this
thread
</Label>
<Button
onClick={(e) => e.preventDefault()}
size="sm"
className="ml-auto"
>
Send
</Button>
</div>
</div>
</form>
</div>
</div>
) : (
<div className="p-8 text-center text-muted-foreground">
No message selected
</div>
)}
</div>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/mail/components/mail-display.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/mail/components/mail-display.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 5126
} | 67 |
"use client"
import * as React from "react"
import { CaretSortIcon, CheckIcon } from "@radix-ui/react-icons"
import { PopoverProps } from "@radix-ui/react-popover"
import { cn } from "@/lib/utils"
import { useMutationObserver } from "@/hooks/use-mutation-observer"
import { Button } from "@/registry/new-york/ui/button"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/registry/new-york/ui/command"
import {
HoverCard,
HoverCardContent,
HoverCardTrigger,
} from "@/registry/new-york/ui/hover-card"
import { Label } from "@/registry/new-york/ui/label"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/registry/new-york/ui/popover"
import { Model, ModelType } from "../data/models"
interface ModelSelectorProps extends PopoverProps {
types: readonly ModelType[]
models: Model[]
}
export function ModelSelector({ models, types, ...props }: ModelSelectorProps) {
const [open, setOpen] = React.useState(false)
const [selectedModel, setSelectedModel] = React.useState<Model>(models[0])
const [peekedModel, setPeekedModel] = React.useState<Model>(models[0])
return (
<div className="grid gap-2">
<HoverCard openDelay={200}>
<HoverCardTrigger asChild>
<Label htmlFor="model">Model</Label>
</HoverCardTrigger>
<HoverCardContent
align="start"
className="w-[260px] text-sm"
side="left"
>
The model which will generate the completion. Some models are suitable
for natural language tasks, others specialize in code. Learn more.
</HoverCardContent>
</HoverCard>
<Popover open={open} onOpenChange={setOpen} {...props}>
<PopoverTrigger asChild>
<Button
variant="outline"
role="combobox"
aria-expanded={open}
aria-label="Select a model"
className="w-full justify-between"
>
{selectedModel ? selectedModel.name : "Select a model..."}
<CaretSortIcon className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent align="end" className="w-[250px] p-0">
<HoverCard>
<HoverCardContent
side="left"
align="start"
forceMount
className="min-h-[280px]"
>
<div className="grid gap-2">
<h4 className="font-medium leading-none">{peekedModel.name}</h4>
<div className="text-sm text-muted-foreground">
{peekedModel.description}
</div>
{peekedModel.strengths ? (
<div className="mt-4 grid gap-2">
<h5 className="text-sm font-medium leading-none">
Strengths
</h5>
<ul className="text-sm text-muted-foreground">
{peekedModel.strengths}
</ul>
</div>
) : null}
</div>
</HoverCardContent>
<Command loop>
<CommandList className="h-[var(--cmdk-list-height)] max-h-[400px]">
<CommandInput placeholder="Search Models..." />
<CommandEmpty>No Models found.</CommandEmpty>
<HoverCardTrigger />
{types.map((type) => (
<CommandGroup key={type} heading={type}>
{models
.filter((model) => model.type === type)
.map((model) => (
<ModelItem
key={model.id}
model={model}
isSelected={selectedModel?.id === model.id}
onPeek={(model) => setPeekedModel(model)}
onSelect={() => {
setSelectedModel(model)
setOpen(false)
}}
/>
))}
</CommandGroup>
))}
</CommandList>
</Command>
</HoverCard>
</PopoverContent>
</Popover>
</div>
)
}
interface ModelItemProps {
model: Model
isSelected: boolean
onSelect: () => void
onPeek: (model: Model) => void
}
function ModelItem({ model, isSelected, onSelect, onPeek }: ModelItemProps) {
const ref = React.useRef<HTMLDivElement>(null)
useMutationObserver(ref, (mutations) => {
mutations.forEach((mutation) => {
if (
mutation.type === "attributes" &&
mutation.attributeName === "aria-selected" &&
ref.current?.getAttribute("aria-selected") === "true"
) {
onPeek(model)
}
})
})
return (
<CommandItem
key={model.id}
onSelect={onSelect}
ref={ref}
className="data-[selected=true]:bg-primary data-[selected=true]:text-primary-foreground"
>
{model.name}
<CheckIcon
className={cn(
"ml-auto h-4 w-4",
isSelected ? "opacity-100" : "opacity-0"
)}
/>
</CommandItem>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/playground/components/model-selector.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/playground/components/model-selector.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 2632
} | 68 |
"use client"
import { DropdownMenuTrigger } from "@radix-ui/react-dropdown-menu"
import { MixerHorizontalIcon } from "@radix-ui/react-icons"
import { Table } from "@tanstack/react-table"
import { Button } from "@/registry/new-york/ui/button"
import {
DropdownMenu,
DropdownMenuCheckboxItem,
DropdownMenuContent,
DropdownMenuLabel,
DropdownMenuSeparator,
} from "@/registry/new-york/ui/dropdown-menu"
interface DataTableViewOptionsProps<TData> {
table: Table<TData>
}
export function DataTableViewOptions<TData>({
table,
}: DataTableViewOptionsProps<TData>) {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button
variant="outline"
size="sm"
className="ml-auto hidden h-8 lg:flex"
>
<MixerHorizontalIcon className="mr-2 h-4 w-4" />
View
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-[150px]">
<DropdownMenuLabel>Toggle columns</DropdownMenuLabel>
<DropdownMenuSeparator />
{table
.getAllColumns()
.filter(
(column) =>
typeof column.accessorFn !== "undefined" && column.getCanHide()
)
.map((column) => {
return (
<DropdownMenuCheckboxItem
key={column.id}
className="capitalize"
checked={column.getIsVisible()}
onCheckedChange={(value) => column.toggleVisibility(!!value)}
>
{column.id}
</DropdownMenuCheckboxItem>
)
})}
</DropdownMenuContent>
</DropdownMenu>
)
}
| shadcn-ui/ui/apps/www/app/(app)/examples/tasks/components/data-table-view-options.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/(app)/examples/tasks/components/data-table-view-options.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 792
} | 69 |
import "@/styles/globals.css"
import { Metadata, Viewport } from "next"
import { siteConfig } from "@/config/site"
import { fontSans } from "@/lib/fonts"
import { cn } from "@/lib/utils"
import { Analytics } from "@/components/analytics"
import { ThemeProvider } from "@/components/providers"
import { TailwindIndicator } from "@/components/tailwind-indicator"
import { ThemeSwitcher } from "@/components/theme-switcher"
import { Toaster as DefaultToaster } from "@/registry/default/ui/toaster"
import { Toaster as NewYorkSonner } from "@/registry/new-york/ui/sonner"
import { Toaster as NewYorkToaster } from "@/registry/new-york/ui/toaster"
export const metadata: Metadata = {
title: {
default: siteConfig.name,
template: `%s - ${siteConfig.name}`,
},
metadataBase: new URL(siteConfig.url),
description: siteConfig.description,
keywords: [
"Next.js",
"React",
"Tailwind CSS",
"Server Components",
"Radix UI",
],
authors: [
{
name: "shadcn",
url: "https://shadcn.com",
},
],
creator: "shadcn",
openGraph: {
type: "website",
locale: "en_US",
url: siteConfig.url,
title: siteConfig.name,
description: siteConfig.description,
siteName: siteConfig.name,
images: [
{
url: siteConfig.ogImage,
width: 1200,
height: 630,
alt: siteConfig.name,
},
],
},
twitter: {
card: "summary_large_image",
title: siteConfig.name,
description: siteConfig.description,
images: [siteConfig.ogImage],
creator: "@shadcn",
},
icons: {
icon: "/favicon.ico",
shortcut: "/favicon-16x16.png",
apple: "/apple-touch-icon.png",
},
manifest: `${siteConfig.url}/site.webmanifest`,
}
export const viewport: Viewport = {
themeColor: [
{ media: "(prefers-color-scheme: light)", color: "white" },
{ media: "(prefers-color-scheme: dark)", color: "black" },
],
}
interface RootLayoutProps {
children: React.ReactNode
}
export default function RootLayout({ children }: RootLayoutProps) {
return (
<>
<html lang="en" suppressHydrationWarning>
<head />
<body
className={cn(
"min-h-screen bg-background font-sans antialiased",
fontSans.variable
)}
>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
<div vaul-drawer-wrapper="">
<div className="relative flex min-h-screen flex-col bg-background">
{children}
</div>
</div>
<TailwindIndicator />
<ThemeSwitcher />
<Analytics />
<NewYorkToaster />
<DefaultToaster />
<NewYorkSonner />
</ThemeProvider>
</body>
</html>
</>
)
}
| shadcn-ui/ui/apps/www/app/layout.tsx | {
"file_path": "shadcn-ui/ui/apps/www/app/layout.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1270
} | 70 |
"use client"
import * as React from "react"
import { cn } from "@/lib/utils"
import { Button } from "@/registry/new-york/ui/button"
import {
Collapsible,
CollapsibleContent,
CollapsibleTrigger,
} from "@/registry/new-york/ui/collapsible"
interface CodeBlockProps extends React.HTMLAttributes<HTMLDivElement> {
expandButtonTitle?: string
}
export function CodeBlockWrapper({
expandButtonTitle = "View Code",
className,
children,
...props
}: CodeBlockProps) {
const [isOpened, setIsOpened] = React.useState(false)
return (
<Collapsible open={isOpened} onOpenChange={setIsOpened}>
<div className={cn("relative overflow-hidden", className)} {...props}>
<CollapsibleContent
forceMount
className={cn("overflow-hidden", !isOpened && "max-h-32")}
>
<div
className={cn(
"[&_pre]:my-0 [&_pre]:max-h-[650px] [&_pre]:pb-[100px]",
!isOpened ? "[&_pre]:overflow-hidden" : "[&_pre]:overflow-auto]"
)}
>
{children}
</div>
</CollapsibleContent>
<div
className={cn(
"absolute flex items-center justify-center bg-gradient-to-b from-zinc-700/30 to-zinc-950/90 p-2",
isOpened ? "inset-x-0 bottom-0 h-12" : "inset-0"
)}
>
<CollapsibleTrigger asChild>
<Button variant="secondary" className="h-8 text-xs">
{isOpened ? "Collapse" : expandButtonTitle}
</Button>
</CollapsibleTrigger>
</div>
</div>
</Collapsible>
)
}
| shadcn-ui/ui/apps/www/components/code-block-wrapper.tsx | {
"file_path": "shadcn-ui/ui/apps/www/components/code-block-wrapper.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 752
} | 71 |
"use client"
import * as React from "react"
import Link, { LinkProps } from "next/link"
import { useRouter } from "next/navigation"
import { ViewVerticalIcon } from "@radix-ui/react-icons"
import { docsConfig } from "@/config/docs"
import { siteConfig } from "@/config/site"
import { cn } from "@/lib/utils"
import { Icons } from "@/components/icons"
import { Button } from "@/registry/new-york/ui/button"
import { ScrollArea } from "@/registry/new-york/ui/scroll-area"
import { Sheet, SheetContent, SheetTrigger } from "@/registry/new-york/ui/sheet"
export function MobileNav() {
const [open, setOpen] = React.useState(false)
return (
<Sheet open={open} onOpenChange={setOpen}>
<SheetTrigger asChild>
<Button
variant="ghost"
className="mr-2 px-0 text-base hover:bg-transparent focus-visible:bg-transparent focus-visible:ring-0 focus-visible:ring-offset-0 md:hidden"
>
<svg
strokeWidth="1.5"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="h-5 w-5"
>
<path
d="M3 5H11"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
></path>
<path
d="M3 12H16"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
></path>
<path
d="M3 19H21"
stroke="currentColor"
strokeWidth="1.5"
strokeLinecap="round"
strokeLinejoin="round"
></path>
</svg>
<span className="sr-only">Toggle Menu</span>
</Button>
</SheetTrigger>
<SheetContent side="left" className="pr-0">
<MobileLink
href="/"
className="flex items-center"
onOpenChange={setOpen}
>
<Icons.logo className="mr-2 h-4 w-4" />
<span className="font-bold">{siteConfig.name}</span>
</MobileLink>
<ScrollArea className="my-4 h-[calc(100vh-8rem)] pb-10 pl-6">
<div className="flex flex-col space-y-3">
{docsConfig.mainNav?.map(
(item) =>
item.href && (
<MobileLink
key={item.href}
href={item.href}
onOpenChange={setOpen}
>
{item.title}
</MobileLink>
)
)}
</div>
<div className="flex flex-col space-y-2">
{docsConfig.sidebarNav.map((item, index) => (
<div key={index} className="flex flex-col space-y-3 pt-6">
<h4 className="font-medium">{item.title}</h4>
{item?.items?.length &&
item.items.map((item) => (
<React.Fragment key={item.href}>
{!item.disabled &&
(item.href ? (
<MobileLink
href={item.href}
onOpenChange={setOpen}
className="text-muted-foreground"
>
{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>
)}
</MobileLink>
) : (
item.title
))}
</React.Fragment>
))}
</div>
))}
</div>
</ScrollArea>
</SheetContent>
</Sheet>
)
}
interface MobileLinkProps extends LinkProps {
onOpenChange?: (open: boolean) => void
children: React.ReactNode
className?: string
}
function MobileLink({
href,
onOpenChange,
className,
children,
...props
}: MobileLinkProps) {
const router = useRouter()
return (
<Link
href={href}
onClick={() => {
router.push(href.toString())
onOpenChange?.(false)
}}
className={cn(className)}
{...props}
>
{children}
</Link>
)
}
| shadcn-ui/ui/apps/www/components/mobile-nav.tsx | {
"file_path": "shadcn-ui/ui/apps/www/components/mobile-nav.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 2550
} | 72 |
"use client"
import { cn } from "@/lib/utils"
import { useConfig } from "@/hooks/use-config"
interface ThemeWrapperProps extends React.ComponentProps<"div"> {
defaultTheme?: string
}
export function ThemeWrapper({
defaultTheme,
children,
className,
}: ThemeWrapperProps) {
const [config] = useConfig()
return (
<div
className={cn(
`theme-${defaultTheme || config.theme}`,
"w-full",
className
)}
style={
{
"--radius": `${defaultTheme ? 0.5 : config.radius}rem`,
} as React.CSSProperties
}
>
{children}
</div>
)
}
| shadcn-ui/ui/apps/www/components/theme-wrapper.tsx | {
"file_path": "shadcn-ui/ui/apps/www/components/theme-wrapper.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 269
} | 73 |
import { useAtom } from "jotai"
import { atomWithStorage } from "jotai/utils"
import { BaseColor } from "@/registry/registry-base-colors"
import { Style } from "@/registry/registry-styles"
type Config = {
style: Style["name"]
theme: BaseColor["name"]
radius: number
}
const configAtom = atomWithStorage<Config>("config", {
style: "default",
theme: "zinc",
radius: 0.5,
})
export function useConfig() {
return useAtom(configAtom)
}
| shadcn-ui/ui/apps/www/hooks/use-config.ts | {
"file_path": "shadcn-ui/ui/apps/www/hooks/use-config.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 158
} | 74 |
import { UnistNode, UnistTree } from "types/unist"
import { visit } from "unist-util-visit"
export function rehypeNpmCommand() {
return (tree: UnistTree) => {
visit(tree, (node: UnistNode) => {
if (node.type !== "element" || node?.tagName !== "pre") {
return
}
// npm install.
if (node.properties?.["__rawString__"]?.startsWith("npm install")) {
const npmCommand = node.properties?.["__rawString__"]
node.properties["__npmCommand__"] = npmCommand
node.properties["__yarnCommand__"] = npmCommand.replace(
"npm install",
"yarn add"
)
node.properties["__pnpmCommand__"] = npmCommand.replace(
"npm install",
"pnpm add"
)
node.properties["__bunCommand__"] = npmCommand.replace(
"npm install",
"bun add"
)
}
// npx create.
if (node.properties?.["__rawString__"]?.startsWith("npx create-")) {
const npmCommand = node.properties?.["__rawString__"]
node.properties["__npmCommand__"] = npmCommand
node.properties["__yarnCommand__"] = npmCommand.replace(
"npx create-",
"yarn create "
)
node.properties["__pnpmCommand__"] = npmCommand.replace(
"npx create-",
"pnpm create "
)
node.properties["__bunCommand__"] = npmCommand.replace(
"npx",
"bunx --bun"
)
}
// npx.
if (
node.properties?.["__rawString__"]?.startsWith("npx") &&
!node.properties?.["__rawString__"]?.startsWith("npx create-")
) {
const npmCommand = node.properties?.["__rawString__"]
node.properties["__npmCommand__"] = npmCommand
node.properties["__yarnCommand__"] = npmCommand
node.properties["__pnpmCommand__"] = npmCommand.replace(
"npx",
"pnpm dlx"
)
node.properties["__bunCommand__"] = npmCommand.replace(
"npx",
"bunx --bun"
)
}
})
}
}
| shadcn-ui/ui/apps/www/lib/rehype-npm-command.ts | {
"file_path": "shadcn-ui/ui/apps/www/lib/rehype-npm-command.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 981
} | 75 |
"use client"
import { Bar, BarChart, Label, Rectangle, ReferenceLine, XAxis } from "recharts"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/registry/default/ui/card"
import {
ChartContainer,
ChartTooltip,
ChartTooltipContent,
} from "@/registry/default/ui/chart"
export default function Component() {
return (
<Card className="lg:max-w-md" x-chunk="charts-01-chunk-0">
<CardHeader className="space-y-0 pb-2">
<CardDescription>Today</CardDescription>
<CardTitle className="text-4xl tabular-nums">
12,584{" "}
<span className="font-sans text-sm font-normal tracking-normal text-muted-foreground">
steps
</span>
</CardTitle>
</CardHeader>
<CardContent>
<ChartContainer
config={{
steps: {
label: "Steps",
color: "hsl(var(--chart-1))",
},
}}
>
<BarChart
accessibilityLayer
margin={{
left: -4,
right: -4,
}}
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={5}
fillOpacity={0.6}
activeBar={<Rectangle fillOpacity={0.8} />}
/>
<XAxis
dataKey="date"
tickLine={false}
axisLine={false}
tickMargin={4}
tickFormatter={(value) => {
return new Date(value).toLocaleDateString("en-US", {
weekday: "short",
})
}}
/>
<ChartTooltip
defaultIndex={2}
content={
<ChartTooltipContent
hideIndicator
labelFormatter={(value) => {
return new Date(value).toLocaleDateString("en-US", {
day: "numeric",
month: "long",
year: "numeric",
})
}}
/>
}
cursor={false}
/>
<ReferenceLine
y={1200}
stroke="hsl(var(--muted-foreground))"
strokeDasharray="3 3"
strokeWidth={1}
>
<Label
position="insideBottomLeft"
value="Average Steps"
offset={10}
fill="hsl(var(--foreground))"
/>
<Label
position="insideTopLeft"
value="12,343"
className="text-lg"
fill="hsl(var(--foreground))"
offset={10}
startOffset={100}
/>
</ReferenceLine>
</BarChart>
</ChartContainer>
</CardContent>
<CardFooter className="flex-col items-start gap-1">
<CardDescription>
Over the past 7 days, you have walked{" "}
<span className="font-medium text-foreground">53,305</span> steps.
</CardDescription>
<CardDescription>
You need <span className="font-medium text-foreground">12,584</span>{" "}
more steps to reach your goal.
</CardDescription>
</CardFooter>
</Card>
)
}
| shadcn-ui/ui/apps/www/registry/default/block/charts-01-chunk-0.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/block/charts-01-chunk-0.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 2474
} | 76 |
"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-02-chunk-0">
<CardHeader className="p-2 pt-0 md:p-4">
<CardTitle>Upgrade to Pro</CardTitle>
<CardDescription>
Unlock all features and get unlimited access to our support team.
</CardDescription>
</CardHeader>
<CardContent className="p-2 pt-0 md:p-4 md:pt-0">
<Button size="sm" className="w-full">
Upgrade
</Button>
</CardContent>
</Card>
)
}
| shadcn-ui/ui/apps/www/registry/default/block/dashboard-02-chunk-0.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-02-chunk-0.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 290
} | 77 |
"use client"
import Image from "next/image"
import { MoreHorizontal } from "lucide-react"
import { Badge } from "@/registry/default/ui/badge"
import { Button } from "@/registry/default/ui/button"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/registry/default/ui/card"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuTrigger,
} from "@/registry/default/ui/dropdown-menu"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/registry/default/ui/table"
export default function Component() {
return (
<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>
)
}
| shadcn-ui/ui/apps/www/registry/default/block/dashboard-06-chunk-0.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/block/dashboard-06-chunk-0.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 6325
} | 78 |
import { Database } from "lucide-react"
import { Card, CardContent } from "@/registry/default/ui/card"
import { Progress } from "@/registry/default/ui/progress"
export function StorageCard() {
return (
<Card className="rounded-md text-xs shadow-sm">
<CardContent className="flex items-start gap-2.5 p-2.5">
<div className="flex h-9 w-9 shrink-0 items-center justify-center rounded-md bg-accent text-accent-foreground">
<Database className="h-5 w-5 text-muted-foreground" />
</div>
<div className="grid flex-1 gap-1">
<p className="font-medium">Running out of space?</p>
<p className="text-muted-foreground">79.2 GB / 100 GB used</p>
<Progress
value={79.2}
className="mt-1"
aria-label="79.2 GB / 100 GB used"
/>
</div>
</CardContent>
</Card>
)
}
| shadcn-ui/ui/apps/www/registry/default/block/sidebar-01/components/storage-card.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/block/sidebar-01/components/storage-card.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 396
} | 79 |
import { ChevronDown, Slash } from "lucide-react"
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/registry/default/ui/breadcrumb"
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
} from "@/registry/default/ui/dropdown-menu"
export default function BreadcrumbWithDropdown() {
return (
<Breadcrumb>
<BreadcrumbList>
<BreadcrumbItem>
<BreadcrumbLink href="/">Home</BreadcrumbLink>
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash />
</BreadcrumbSeparator>
<BreadcrumbItem>
<DropdownMenu>
<DropdownMenuTrigger className="flex items-center gap-1">
Components
<ChevronDown className="h-4 w-4" />
</DropdownMenuTrigger>
<DropdownMenuContent align="start">
<DropdownMenuItem>Documentation</DropdownMenuItem>
<DropdownMenuItem>Themes</DropdownMenuItem>
<DropdownMenuItem>GitHub</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</BreadcrumbItem>
<BreadcrumbSeparator>
<Slash />
</BreadcrumbSeparator>
<BreadcrumbItem>
<BreadcrumbPage>Breadcrumb</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/breadcrumb-dropdown.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/breadcrumb-dropdown.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 680
} | 80 |
"use client"
import Link from "next/link"
import { zodResolver } from "@hookform/resolvers/zod"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { toast } from "@/registry/default/hooks/use-toast"
import { Button } from "@/registry/default/ui/button"
import { Checkbox } from "@/registry/default/ui/checkbox"
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
} from "@/registry/default/ui/form"
const FormSchema = z.object({
mobile: z.boolean().default(false).optional(),
})
export default function CheckboxReactHookFormSingle() {
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
defaultValues: {
mobile: true,
},
})
function onSubmit(data: z.infer<typeof FormSchema>) {
toast({
title: "You submitted the following values:",
description: (
<pre className="mt-2 w-[340px] rounded-md bg-slate-950 p-4">
<code className="text-white">{JSON.stringify(data, null, 2)}</code>
</pre>
),
})
}
return (
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-6">
<FormField
control={form.control}
name="mobile"
render={({ field }) => (
<FormItem className="flex flex-row items-start space-x-3 space-y-0 rounded-md border p-4">
<FormControl>
<Checkbox
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
<div className="space-y-1 leading-none">
<FormLabel>
Use different settings for my mobile devices
</FormLabel>
<FormDescription>
You can manage your mobile notifications in the{" "}
<Link href="/examples/forms">mobile settings</Link> page.
</FormDescription>
</div>
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/checkbox-form-single.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/checkbox-form-single.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 971
} | 81 |
import { Copy } from "lucide-react"
import { Button } from "@/registry/default/ui/button"
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/registry/default/ui/dialog"
import { Input } from "@/registry/default/ui/input"
import { Label } from "@/registry/default/ui/label"
export default function DialogCloseButton() {
return (
<Dialog>
<DialogTrigger asChild>
<Button variant="outline">Share</Button>
</DialogTrigger>
<DialogContent className="sm:max-w-md">
<DialogHeader>
<DialogTitle>Share link</DialogTitle>
<DialogDescription>
Anyone who has this link will be able to view this.
</DialogDescription>
</DialogHeader>
<div className="flex items-center space-x-2">
<div className="grid flex-1 gap-2">
<Label htmlFor="link" className="sr-only">
Link
</Label>
<Input
id="link"
defaultValue="https://ui.shadcn.com/docs/installation"
readOnly
/>
</div>
<Button type="submit" size="sm" className="px-3">
<span className="sr-only">Copy</span>
<Copy className="h-4 w-4" />
</Button>
</div>
<DialogFooter className="sm:justify-start">
<DialogClose asChild>
<Button type="button" variant="secondary">
Close
</Button>
</DialogClose>
</DialogFooter>
</DialogContent>
</Dialog>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/dialog-close-button.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/dialog-close-button.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 758
} | 82 |
import React from "react"
import {
InputOTP,
InputOTPGroup,
InputOTPSeparator,
InputOTPSlot,
} from "@/registry/default/ui/input-otp"
export default function InputOTPWithSeparator() {
return (
<InputOTP maxLength={6}>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
</InputOTPGroup>
<InputOTPSeparator />
<InputOTPGroup>
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
</InputOTPGroup>
<InputOTPSeparator />
<InputOTPGroup>
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/input-otp-separator.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/input-otp-separator.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 311
} | 83 |
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/registry/default/ui/resizable"
export default function ResizableDemo() {
return (
<ResizablePanelGroup
direction="vertical"
className="min-h-[200px] max-w-md rounded-lg border md:min-w-[450px]"
>
<ResizablePanel defaultSize={25}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Header</span>
</div>
</ResizablePanel>
<ResizableHandle />
<ResizablePanel defaultSize={75}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Content</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/resizable-vertical.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/resizable-vertical.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 318
} | 84 |
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"
import {
Tabs,
TabsContent,
TabsList,
TabsTrigger,
} from "@/registry/default/ui/tabs"
export default function TabsDemo() {
return (
<Tabs defaultValue="account" className="w-[400px]">
<TabsList className="grid w-full grid-cols-2">
<TabsTrigger value="account">Account</TabsTrigger>
<TabsTrigger value="password">Password</TabsTrigger>
</TabsList>
<TabsContent value="account">
<Card>
<CardHeader>
<CardTitle>Account</CardTitle>
<CardDescription>
Make changes to your account here. Click save when you're done.
</CardDescription>
</CardHeader>
<CardContent className="space-y-2">
<div className="space-y-1">
<Label htmlFor="name">Name</Label>
<Input id="name" defaultValue="Pedro Duarte" />
</div>
<div className="space-y-1">
<Label htmlFor="username">Username</Label>
<Input id="username" defaultValue="@peduarte" />
</div>
</CardContent>
<CardFooter>
<Button>Save changes</Button>
</CardFooter>
</Card>
</TabsContent>
<TabsContent value="password">
<Card>
<CardHeader>
<CardTitle>Password</CardTitle>
<CardDescription>
Change your password here. After saving, you'll be logged out.
</CardDescription>
</CardHeader>
<CardContent className="space-y-2">
<div className="space-y-1">
<Label htmlFor="current">Current password</Label>
<Input id="current" type="password" />
</div>
<div className="space-y-1">
<Label htmlFor="new">New password</Label>
<Input id="new" type="password" />
</div>
</CardContent>
<CardFooter>
<Button>Save password</Button>
</CardFooter>
</Card>
</TabsContent>
</Tabs>
)
}
| shadcn-ui/ui/apps/www/registry/default/example/tabs-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/tabs-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1114
} | 85 |
export default function TypographyLarge() {
return <div className="text-lg font-semibold">Are you absolutely sure?</div>
}
| shadcn-ui/ui/apps/www/registry/default/example/typography-large.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/typography-large.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 37
} | 86 |
import * as React from "react"
import { Slot } from "@radix-ui/react-slot"
import { ChevronRight, MoreHorizontal } from "lucide-react"
import { cn } from "@/lib/utils"
const Breadcrumb = React.forwardRef<
HTMLElement,
React.ComponentPropsWithoutRef<"nav"> & {
separator?: React.ReactNode
}
>(({ ...props }, ref) => <nav ref={ref} aria-label="breadcrumb" {...props} />)
Breadcrumb.displayName = "Breadcrumb"
const BreadcrumbList = React.forwardRef<
HTMLOListElement,
React.ComponentPropsWithoutRef<"ol">
>(({ className, ...props }, ref) => (
<ol
ref={ref}
className={cn(
"flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",
className
)}
{...props}
/>
))
BreadcrumbList.displayName = "BreadcrumbList"
const BreadcrumbItem = React.forwardRef<
HTMLLIElement,
React.ComponentPropsWithoutRef<"li">
>(({ className, ...props }, ref) => (
<li
ref={ref}
className={cn("inline-flex items-center gap-1.5", className)}
{...props}
/>
))
BreadcrumbItem.displayName = "BreadcrumbItem"
const BreadcrumbLink = React.forwardRef<
HTMLAnchorElement,
React.ComponentPropsWithoutRef<"a"> & {
asChild?: boolean
}
>(({ asChild, className, ...props }, ref) => {
const Comp = asChild ? Slot : "a"
return (
<Comp
ref={ref}
className={cn("transition-colors hover:text-foreground", className)}
{...props}
/>
)
})
BreadcrumbLink.displayName = "BreadcrumbLink"
const BreadcrumbPage = React.forwardRef<
HTMLSpanElement,
React.ComponentPropsWithoutRef<"span">
>(({ className, ...props }, ref) => (
<span
ref={ref}
role="link"
aria-disabled="true"
aria-current="page"
className={cn("font-normal text-foreground", className)}
{...props}
/>
))
BreadcrumbPage.displayName = "BreadcrumbPage"
const BreadcrumbSeparator = ({
children,
className,
...props
}: React.ComponentProps<"li">) => (
<li
role="presentation"
aria-hidden="true"
className={cn("[&>svg]:size-3.5", className)}
{...props}
>
{children ?? <ChevronRight />}
</li>
)
BreadcrumbSeparator.displayName = "BreadcrumbSeparator"
const BreadcrumbEllipsis = ({
className,
...props
}: React.ComponentProps<"span">) => (
<span
role="presentation"
aria-hidden="true"
className={cn("flex h-9 w-9 items-center justify-center", className)}
{...props}
>
<MoreHorizontal className="h-4 w-4" />
<span className="sr-only">More</span>
</span>
)
BreadcrumbEllipsis.displayName = "BreadcrumbElipssis"
export {
Breadcrumb,
BreadcrumbList,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbPage,
BreadcrumbSeparator,
BreadcrumbEllipsis,
}
| shadcn-ui/ui/apps/www/registry/default/ui/breadcrumb.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/ui/breadcrumb.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1083
} | 87 |
"use client"
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/registry/new-york/ui/card"
import { Progress } from "@/registry/new-york/ui/progress"
export default function Component() {
return (
<Card x-chunk="dashboard-05-chunk-2">
<CardHeader className="pb-2">
<CardDescription>This Month</CardDescription>
<CardTitle className="text-4xl">$5,329</CardTitle>
</CardHeader>
<CardContent>
<div className="text-xs text-muted-foreground">
+10% from last month
</div>
</CardContent>
<CardFooter>
<Progress value={12} aria-label="12% increase" />
</CardFooter>
</Card>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-05-chunk-2.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/block/dashboard-05-chunk-2.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 310
} | 88 |
import { Button } from "@/registry/new-york/ui/button"
export default function ButtonLink() {
return <Button variant="link">Link</Button>
}
| shadcn-ui/ui/apps/www/registry/new-york/example/button-link.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/button-link.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 44
} | 89 |
"use client"
import { useToast } from "@/registry/new-york/hooks/use-toast"
import { Button } from "@/registry/new-york/ui/button"
export default function ToastWithTitle() {
const { toast } = useToast()
return (
<Button
variant="outline"
onClick={() => {
toast({
title: "Uh oh! Something went wrong.",
description: "There was a problem with your request.",
})
}}
>
Show Toast
</Button>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/toast-with-title.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/toast-with-title.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 198
} | 90 |
import { Registry } from "@/registry/schema"
export const charts: Registry = [
// Area Charts
{
name: "chart-area-axes",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-axes.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-default",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-default.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-gradient",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-gradient.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-icons",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-icons.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-interactive",
type: "registry:block",
registryDependencies: ["card", "chart", "select"],
files: [
{
path: "block/chart-area-interactive.tsx",
type: "registry:component",
},
],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-legend",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-legend.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-linear",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-linear.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-stacked-expand",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-stacked-expand.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-stacked",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-stacked.tsx"],
category: "Charts",
subcategory: "Area",
},
{
name: "chart-area-step",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-area-step.tsx"],
category: "Charts",
subcategory: "Area",
},
// Bar Charts
{
name: "chart-bar-active",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-active.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-default",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-default.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-horizontal",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-horizontal.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-interactive",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-interactive.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-label-custom",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-label-custom.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-label",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-label.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-mixed",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-mixed.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-multiple",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-multiple.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-negative",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-negative.tsx"],
category: "Charts",
subcategory: "Bar",
},
{
name: "chart-bar-stacked",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-bar-stacked.tsx"],
category: "Charts",
subcategory: "Bar",
},
// Line Charts
{
name: "chart-line-default",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-default.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-dots-colors",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-dots-colors.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-dots-custom",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-dots-custom.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-dots",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-dots.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-interactive",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-interactive.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-label-custom",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-label-custom.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-label",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-label.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-linear",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-linear.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-multiple",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-multiple.tsx"],
category: "Charts",
subcategory: "Line",
},
{
name: "chart-line-step",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-line-step.tsx"],
category: "Charts",
subcategory: "Line",
},
// Pie Charts
{
name: "chart-pie-donut-active",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-donut-active.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-donut-text",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-donut-text.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-donut",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-donut.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-interactive",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-interactive.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-label-custom",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-label-custom.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-label-list",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-label-list.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-label",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-label.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-legend",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-legend.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-separator-none",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-separator-none.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-simple",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-simple.tsx"],
category: "Charts",
subcategory: "Pie",
},
{
name: "chart-pie-stacked",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-pie-stacked.tsx"],
category: "Charts",
subcategory: "Pie",
},
// Radar Charts
{
name: "chart-radar-default",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-default.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-dots",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-dots.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-grid-circle-fill",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-grid-circle-fill.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-grid-circle-no-lines",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-grid-circle-no-lines.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-grid-circle",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-grid-circle.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-grid-custom",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-grid-custom.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-grid-fill",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-grid-fill.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-grid-none",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-grid-none.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-icons",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-icons.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-label-custom",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-label-custom.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-legend",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-legend.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-lines-only",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-lines-only.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-multiple",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-multiple.tsx"],
category: "Charts",
subcategory: "Radar",
},
{
name: "chart-radar-radius",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radar-radius.tsx"],
category: "Charts",
subcategory: "Radar",
},
// Radial Charts
{
name: "chart-radial-grid",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radial-grid.tsx"],
category: "Charts",
subcategory: "Radial",
},
{
name: "chart-radial-label",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radial-label.tsx"],
category: "Charts",
subcategory: "Radial",
},
{
name: "chart-radial-shape",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radial-shape.tsx"],
category: "Charts",
subcategory: "Radial",
},
{
name: "chart-radial-simple",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radial-simple.tsx"],
category: "Charts",
subcategory: "Radial",
},
{
name: "chart-radial-stacked",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radial-stacked.tsx"],
category: "Charts",
subcategory: "Radial",
},
{
name: "chart-radial-text",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-radial-text.tsx"],
category: "Charts",
subcategory: "Radial",
},
{
name: "chart-tooltip-default",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-default.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-indicator-line",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-indicator-line.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-indicator-none",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-indicator-none.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-label-none",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-label-none.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-label-custom",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-label-custom.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-label-formatter",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-label-formatter.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-formatter",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-formatter.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-icons",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-icons.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
{
name: "chart-tooltip-advanced",
type: "registry:block",
registryDependencies: ["card", "chart"],
files: ["block/chart-tooltip-advanced.tsx"],
category: "Charts",
subcategory: "Tooltip",
},
]
| shadcn-ui/ui/apps/www/registry/registry-charts.ts | {
"file_path": "shadcn-ui/ui/apps/www/registry/registry-charts.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 6242
} | 91 |
import { Node } from "unist-builder"
export interface UnistNode extends Node {
type: string
name?: string
tagName?: string
value?: string
properties?: {
__rawString__?: string
__className__?: string
__event__?: string
[key: string]: unknown
} & NpmCommands
attributes?: {
name: string
value: unknown
type?: string
}[]
children?: UnistNode[]
}
export interface UnistTree extends Node {
children: UnistNode[]
}
export interface NpmCommands {
__npmCommand__?: string
__yarnCommand__?: string
__pnpmCommand__?: string
__bunCommand__?: string
}
| shadcn-ui/ui/apps/www/types/unist.ts | {
"file_path": "shadcn-ui/ui/apps/www/types/unist.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 202
} | 92 |
import { logger } from "@/src/utils/logger"
export function handleError(error: unknown) {
if (typeof error === "string") {
logger.error(error)
process.exit(1)
}
if (error instanceof Error) {
logger.error(error.message)
process.exit(1)
}
logger.error("Something went wrong. Please try again.")
process.exit(1)
}
| shadcn-ui/ui/packages/cli/src/utils/handle-error.ts | {
"file_path": "shadcn-ui/ui/packages/cli/src/utils/handle-error.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 121
} | 93 |
import "./styles.css"
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
)
}
| shadcn-ui/ui/packages/cli/test/fixtures/next-app-src/src/app/layout.tsx | {
"file_path": "shadcn-ui/ui/packages/cli/test/fixtures/next-app-src/src/app/layout.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 76
} | 94 |
body {
background-color: red;
}
| shadcn-ui/ui/packages/cli/test/fixtures/next-pages-src/src/styles/other.css | {
"file_path": "shadcn-ui/ui/packages/cli/test/fixtures/next-pages-src/src/styles/other.css",
"repo_id": "shadcn-ui/ui",
"token_count": 13
} | 95 |
import path from "path"
import { describe, expect, test } from "vitest"
import { getProjectType } from "../../src/utils/get-project-info"
describe("get project type", async () => {
test.each([
{
name: "next-app",
type: "next-app",
},
{
name: "next-app-src",
type: "next-app-src",
},
{
name: "next-pages",
type: "next-pages",
},
{
name: "next-pages-src",
type: "next-pages-src",
},
{
name: "project",
type: null,
},
{
name: "t3-app",
type: "next-pages-src",
},
])(`getProjectType($name) -> $type`, async ({ name, type }) => {
expect(
await getProjectType(path.resolve(__dirname, `../fixtures/${name}`))
).toBe(type)
})
})
| shadcn-ui/ui/packages/cli/test/utils/get-project-type.test.ts | {
"file_path": "shadcn-ui/ui/packages/cli/test/utils/get-project-type.test.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 359
} | 96 |
import { cyan, green, red, yellow } from "kleur/colors"
export const highlighter = {
error: red,
warn: yellow,
info: cyan,
success: green,
}
| shadcn-ui/ui/packages/shadcn/src/utils/highlighter.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/src/utils/highlighter.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 55
} | 97 |
import { existsSync, promises as fs } from "fs"
import path, { basename } from "path"
import { Config } from "@/src/utils/get-config"
import { getProjectInfo } from "@/src/utils/get-project-info"
import { highlighter } from "@/src/utils/highlighter"
import { logger } from "@/src/utils/logger"
import {
getRegistryBaseColor,
getRegistryItemFileTargetPath,
} from "@/src/utils/registry"
import { RegistryItem } from "@/src/utils/registry/schema"
import { spinner } from "@/src/utils/spinner"
import { transform } from "@/src/utils/transformers"
import { transformCssVars } from "@/src/utils/transformers/transform-css-vars"
import { transformImport } from "@/src/utils/transformers/transform-import"
import { transformRsc } from "@/src/utils/transformers/transform-rsc"
import { transformTwPrefixes } from "@/src/utils/transformers/transform-tw-prefix"
import prompts from "prompts"
export function resolveTargetDir(
projectInfo: Awaited<ReturnType<typeof getProjectInfo>>,
config: Config,
target: string
) {
if (target.startsWith("~/")) {
return path.join(config.resolvedPaths.cwd, target.replace("~/", ""))
}
return projectInfo?.isSrcDir
? path.join(config.resolvedPaths.cwd, "src", target)
: path.join(config.resolvedPaths.cwd, target)
}
export async function updateFiles(
files: RegistryItem["files"],
config: Config,
options: {
overwrite?: boolean
force?: boolean
silent?: boolean
}
) {
if (!files?.length) {
return
}
options = {
overwrite: false,
force: false,
silent: false,
...options,
}
const filesCreatedSpinner = spinner(`Updating files.`, {
silent: options.silent,
})?.start()
const [projectInfo, baseColor] = await Promise.all([
getProjectInfo(config.resolvedPaths.cwd),
getRegistryBaseColor(config.tailwind.baseColor),
])
const filesCreated = []
const filesUpdated = []
const filesSkipped = []
for (const file of files) {
if (!file.content) {
continue
}
let targetDir = getRegistryItemFileTargetPath(file, config)
const fileName = basename(file.path)
let filePath = path.join(targetDir, fileName)
if (file.target) {
filePath = resolveTargetDir(projectInfo, config, file.target)
targetDir = path.dirname(filePath)
}
if (!config.tsx) {
filePath = filePath.replace(/\.tsx?$/, (match) =>
match === ".tsx" ? ".jsx" : ".js"
)
}
const existingFile = existsSync(filePath)
if (existingFile && !options.overwrite) {
filesCreatedSpinner.stop()
const { overwrite } = await prompts({
type: "confirm",
name: "overwrite",
message: `The file ${highlighter.info(
fileName
)} already exists. Would you like to overwrite?`,
initial: false,
})
if (!overwrite) {
filesSkipped.push(path.relative(config.resolvedPaths.cwd, filePath))
continue
}
filesCreatedSpinner?.start()
}
// Create the target directory if it doesn't exist.
if (!existsSync(targetDir)) {
await fs.mkdir(targetDir, { recursive: true })
}
// Run our transformers.
const content = await transform(
{
filename: file.path,
raw: file.content,
config,
baseColor,
transformJsx: !config.tsx,
},
[transformImport, transformRsc, transformCssVars, transformTwPrefixes]
)
await fs.writeFile(filePath, content, "utf-8")
existingFile
? filesUpdated.push(path.relative(config.resolvedPaths.cwd, filePath))
: filesCreated.push(path.relative(config.resolvedPaths.cwd, filePath))
}
const hasUpdatedFiles = filesCreated.length || filesUpdated.length
if (!hasUpdatedFiles && !filesSkipped.length) {
filesCreatedSpinner?.info("No files updated.")
}
if (filesCreated.length) {
filesCreatedSpinner?.succeed(
`Created ${filesCreated.length} ${
filesCreated.length === 1 ? "file" : "files"
}:`
)
if (!options.silent) {
for (const file of filesCreated) {
logger.log(` - ${file}`)
}
}
} else {
filesCreatedSpinner?.stop()
}
if (filesUpdated.length) {
spinner(
`Updated ${filesUpdated.length} ${
filesUpdated.length === 1 ? "file" : "files"
}:`,
{
silent: options.silent,
}
)?.info()
if (!options.silent) {
for (const file of filesUpdated) {
logger.log(` - ${file}`)
}
}
}
if (filesSkipped.length) {
spinner(
`Skipped ${filesSkipped.length} ${
filesUpdated.length === 1 ? "file" : "files"
}:`,
{
silent: options.silent,
}
)?.info()
if (!options.silent) {
for (const file of filesSkipped) {
logger.log(` - ${file}`)
}
}
}
if (!options.silent) {
logger.break()
}
}
| shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-files.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-files.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 1927
} | 98 |
import { PrismaClient } from "@prisma/client";
import { singleton } from "./singleton.server";
// Hard-code a unique key, so we can look up the client when this module gets re-imported
const prisma = singleton("prisma", () => new PrismaClient());
prisma.$connect();
export { prisma };
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/db.server.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/db.server.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 85
} | 99 |
// Since the dev server re-requires the bundle, do some shenanigans to make
// certain things persist across that
// Borrowed/modified from https://github.com/jenseng/abuse-the-platform/blob/2993a7e846c95ace693ce61626fa072174c8d9c7/app/utils/singleton.ts
export const singleton = <Value>(
name: string,
valueFactory: () => Value,
): Value => {
const g = global as unknown as { __singletons: Record<string, unknown> };
g.__singletons ??= {};
g.__singletons[name] ??= valueFactory();
return g.__singletons[name] as Value;
};
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/singleton.server.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/singleton.server.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 182
} | 100 |
import { describe, expect, test } from "vitest"
import { transformCssVars } from "../../../src/utils/updaters/update-css-vars"
describe("transformCssVars", () => {
test("should add light and dark css vars if not present", async () => {
expect(
await transformCssVars(
`@tailwind base;
@tailwind components;
@tailwind utilities;
`,
{
light: {
background: "white",
foreground: "black",
},
dark: {
background: "black",
foreground: "white",
},
},
{
tailwind: {
cssVariables: true,
},
}
)
).toMatchInlineSnapshot(`
"@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
:root {
--background: white;
--foreground: black
}
.dark {
--background: black;
--foreground: white
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
"
`)
})
test("should update light and dark css vars if present", async () => {
expect(
await transformCssVars(
`@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base{
:root{
--background: 210 40% 98%;
}
.dark{
--background: 222.2 84% 4.9%;
}
}
`,
{
light: {
background: "215 20.2% 65.1%",
foreground: "222.2 84% 4.9%",
},
dark: {
foreground: "60 9.1% 97.8%",
},
},
{
tailwind: {
cssVariables: true,
},
}
)
).toMatchInlineSnapshot(`
"@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base{
:root{
--background: 215 20.2% 65.1%;
--foreground: 222.2 84% 4.9%;
}
.dark{
--background: 222.2 84% 4.9%;
--foreground: 60 9.1% 97.8%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
"
`)
})
test("should not add the base layer if it is already present", async () => {
expect(
await transformCssVars(
`@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base{
:root{
--background: 210 40% 98%;
}
.dark{
--background: 222.2 84% 4.9%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
`,
{},
{
tailwind: {
cssVariables: true,
},
}
)
).toMatchInlineSnapshot(`
"@tailwind base;
@tailwind components;
@tailwind utilities;
@layer base{
:root{
--background: 210 40% 98%;
}
.dark{
--background: 222.2 84% 4.9%;
}
}
@layer base {
* {
@apply border-border;
}
body {
@apply bg-background text-foreground;
}
}
"
`)
})
})
| shadcn-ui/ui/packages/shadcn/test/utils/updaters/update-css-vars.test.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/utils/updaters/update-css-vars.test.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 1741
} | 101 |
"use client";
import {
Accordion,
AccordionContent,
AccordionItem,
AccordionTrigger,
} from "@/components/ui/accordion"
export default function FaqPage() {
return (
<Accordion type="single" collapsible className="w-full">
<AccordionItem value="item-1">
<AccordionTrigger>Is Easy UI 100% free and open-source?</AccordionTrigger>
<AccordionContent>
Yes, all our templates are completely free and open-source.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-2">
<AccordionTrigger>How do I use the Easy UI templates?</AccordionTrigger>
<AccordionContent>
Browse and select a template, download it, or clone it from our GitHub repository, and start using it.
</AccordionContent>
</AccordionItem>
<AccordionItem value="item-3">
<AccordionTrigger>What tech stack are these templates built with and how?</AccordionTrigger>
<AccordionContent>
Our templates are built with Next.js, React, MagicUI, ShadCNUI, Tailwind CSS, and Framer Motion, ensuring a modern, responsive, and seamless user experience.
</AccordionContent>
</AccordionItem>
</Accordion>
)
}
| DarkInventor/easy-ui/app/faqs/page.tsx | {
"file_path": "DarkInventor/easy-ui/app/faqs/page.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 516
} | 0 |
'use client'
import Image from 'next/image'
import { ImageProps } from 'next/image'
interface MDXImageProps extends Omit<ImageProps, 'src' | 'alt'> {
src: string
alt: string
}
export default function MDXImage({ src, alt, ...props }: MDXImageProps) {
return (
<Image
src={src}
alt={alt}
width={800}
height={600}
{...props}
/>
)
} | DarkInventor/easy-ui/components/MDXImage.tsx | {
"file_path": "DarkInventor/easy-ui/components/MDXImage.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 159
} | 1 |
import { cn } from "@/lib/utils";
import { ReactNode } from "react";
export default function AnimatedGradientText({
children,
className,
}: {
children: ReactNode;
className?: string;
}) {
return (
<div
className={cn(
"group relative mx-auto flex max-w-fit flex-row items-center justify-center rounded-2xl bg-white/40 px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#8fdfff1f] backdrop-blur-sm transition-shadow duration-500 ease-out [--bg-size:300%] hover:shadow-[inset_0_-5px_10px_#8fdfff3f] dark:bg-black/40",
className,
)}
>
<div
className={`animate-gradient absolute inset-0 block size-full bg-gradient-to-r from-[#ffaa40]/50 via-[#9c40ff]/50 to-[#ffaa40]/50 bg-[length:var(--bg-size)_100%] p-px [border-radius:inherit] ![mask-composite:subtract] [mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)]`}
/>
{children}
</div>
);
}
| DarkInventor/easy-ui/components/magicui/animated-gradient-text.tsx | {
"file_path": "DarkInventor/easy-ui/components/magicui/animated-gradient-text.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 403
} | 2 |
"use client";
import { ChevronRight } from "lucide-react";
import Link from "next/link";
// import posthog from "posthog-js";
export function SiteBanner() {
return (
<div className="group relative z-50 top-0 bg-purple-600 py-3 text-white transition-all duration-300 md:py-0">
<div className="container flex flex-col items-center justify-center gap-4 md:h-12 md:flex-row">
<Link
href="https://premium.easyui.pro/"
target="_blank"
className="inline-flex text-xs leading-normal md:text-sm"
>
{" "}
<span className="ml-1 font-[580] dark:font-[550]">
{" "}
Introducing Easy UI Premium - 100+ Blocks and Templates to build your landing page in minutes
</span>{" "}
<ChevronRight className="ml-1 mt-[3px] hidden size-4 transition-all duration-300 ease-out group-hover:translate-x-1 lg:inline-block" />
</Link>
</div>
<hr className="absolute bottom-0 m-0 h-px w-full bg-neutral-200/30" />
</div>
);
} | DarkInventor/easy-ui/components/site-banner.tsx | {
"file_path": "DarkInventor/easy-ui/components/site-banner.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 451
} | 3 |
interface BackgroundProps {
children: React.ReactNode;
}
export function Background({ children }: BackgroundProps) {
return (
<>
<div className="absolute left-0 top-0 -z-50 h-full w-full overflow-hidden">
<div className="sticky left-0 top-0 h-full w-full overflow-hidden">
<div className="absolute inset-0 z-[-1] bg-muted-foreground/40" />
<div className="absolute left-[--x] top-[--y] z-[-1] h-56 w-56 -translate-x-1/2 -translate-y-1/2 rounded-full bg-gradient-radial from-muted-foreground/50 from-0% to-transparent to-90% blur-md" />
<svg
xmlns="http://www.w3.org/2000/svg"
width="100%"
height="100%"
>
<defs>
<pattern
id="dotted-pattern"
width="16"
height="16"
patternUnits="userSpaceOnUse"
>
<circle cx="2" cy="2" r="1" fill="black" />
</pattern>
<mask id="dots-mask">
<rect width="100%" height="100%" fill="white" />
<rect
width="100%"
height="100%"
fill="url(#dotted-pattern)"
/>
</mask>
</defs>
<rect
width="100%"
height="100%"
fill="hsl(var(--background))"
mask="url(#dots-mask)"
/>
</svg>
</div>
</div>
{children}
</>
);
}
| alifarooq9/rapidlaunch/apps/www/src/components/background.tsx | {
"file_path": "alifarooq9/rapidlaunch/apps/www/src/components/background.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 1355
} | 4 |
export const siteConfig = {
name: "RapidLaunch",
} as const;
| alifarooq9/rapidlaunch/apps/www/src/config/site.ts | {
"file_path": "alifarooq9/rapidlaunch/apps/www/src/config/site.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 23
} | 5 |
/** Auto-generated **/
declare const map: Record<string, unknown>
export { map } | alifarooq9/rapidlaunch/starterkits/saas/.map.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/.map.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 24
} | 6 |
import { CancelPauseResumeBtns } from "@/app/(app)/(user)/org/billing/_components/cancel-pause-resume-btns";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import type { OrgSubscription } from "@/types/org-subscription";
import { format } from "date-fns";
import { redirect } from "next/navigation";
type CurrentPlanProps = {
subscription: OrgSubscription;
};
export function CurrentPlan({ subscription }: CurrentPlanProps) {
return (
<Card>
<CardHeader>
<CardTitle>Current Plan</CardTitle>
<CardDescription>
Manage and view your current plan
</CardDescription>
</CardHeader>
<CardContent className="space-y-3">
<div className="space-y-1">
<div className="flex items-center gap-2">
<p>
<span className="font-semibold">Plan:</span>{" "}
{subscription ? subscription.plan?.title : "Free"}
</p>
{subscription?.status_formatted && (
<Badge variant="secondary">
{subscription.status_formatted}
</Badge>
)}
</div>
<p className="text-sm text-muted-foreground">
{subscription ? (
<>
{subscription.status === "active" &&
"Renews at " +
format(subscription.renews_at, "PP")}
{subscription.status === "paused" &&
"Your subscription is paused"}
{subscription.status === "cancelled" &&
subscription.ends_at &&
`${
new Date(subscription.ends_at) >
new Date()
? "Ends at "
: "Ended on "
}` + format(subscription.ends_at, "PP")}
</>
) : (
"No expiration"
)}
</p>
</div>
<div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
<form
action={async () => {
"use server";
if (subscription?.customerPortalUrl) {
redirect(subscription?.customerPortalUrl);
}
}}
>
<Button disabled={!subscription} variant="outline">
Manage your billing settings
</Button>
</form>
<CancelPauseResumeBtns subscription={subscription} />
</div>
</CardContent>
</Card>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/current-plan.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/current-plan.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 2105
} | 7 |
import { AppPageShell } from "@/app/(app)/_components/page-shell";
import { orgMembersInvitePageConfig } from "@/app/(app)/(user)/org/members/invite/_constants/page-config";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Separator } from "@/components/ui/separator";
import { env } from "@/env";
import {
getOrgRequestsQuery,
getOrganizations,
} from "@/server/actions/organization/queries";
import { ShareInviteLink } from "@/app/(app)/(user)/org/members/invite/_components/share-invite-link";
import { OrgRequests } from "@/app/(app)/(user)/org/members/invite/_components/org-requests";
import { SendInviteLink } from "./_components/send-invite-link";
export default async function OrgMemberInvite() {
const { currentOrg } = await getOrganizations();
const inviteLink = `${env.NEXTAUTH_URL}/invite/org/${currentOrg.id}`;
const requests = await getOrgRequestsQuery();
return (
<AppPageShell
title={orgMembersInvitePageConfig.title}
description={orgMembersInvitePageConfig.description}
>
<div className="w-full space-y-5">
<Card>
<CardHeader>
<CardTitle>Share the link to invite</CardTitle>
<CardDescription>
Invite a new member to your organization by sharing
the link below.
</CardDescription>
</CardHeader>
<CardContent>
<ShareInviteLink inviteLink={inviteLink} />
<Separator className="my-4" />
<OrgRequests requests={requests} />
</CardContent>
</Card>
<Card>
<CardHeader>
<CardTitle>Send invite link</CardTitle>
<CardDescription>
Send an invite link to a new member.
</CardDescription>
</CardHeader>
<CardContent>
<SendInviteLink inviteLink={inviteLink} orgName={currentOrg.name} />
</CardContent>
</Card>
</div>
</AppPageShell>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/invite/page.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/invite/page.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 1180
} | 8 |
import { MobileSidenav } from "@/app/(app)/_components/mobile-sidenav";
import { Icons } from "@/components/ui/icons";
type AppHeaderProps = {
sidebarNavIncludeIds?: string[];
sidebarNavRemoveIds?: string[];
showOrgSwitcher?: boolean;
};
export function AppHeader({
sidebarNavIncludeIds,
sidebarNavRemoveIds,
showOrgSwitcher,
}: AppHeaderProps) {
return (
<header className="flex h-14 items-center gap-4">
<MobileSidenav
showOrgSwitcher={showOrgSwitcher}
sidebarNavIncludeIds={sidebarNavIncludeIds}
sidebarNavRemoveIds={sidebarNavRemoveIds}
/>
<Icons.logo hideTextOnMobile={false} />
</header>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/app-header.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/app-header.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 325
} | 9 |
import { type ElementType } from "react";
type AppPageShellProps = {
children: React.ReactNode;
as?: ElementType;
title: string;
description: string;
};
export function AppPageShell({
children,
as,
title,
description,
}: AppPageShellProps) {
const Container = as ?? "main";
return (
<div className="w-full space-y-8">
<PageHeader title={title} description={description} />
<Container className="space-y-8 pb-8">{children}</Container>
</div>
);
}
type PageHeaderProps = {
title: string;
description: string;
};
function PageHeader({ title, description }: PageHeaderProps) {
return (
<header className="flex w-full flex-col gap-1 border-b border-border py-6">
<h1 className="font-heading text-2xl font-bold">{title}</h1>
<p className="max-w-xl text-muted-foreground">{description}</p>
</header>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/page-shell.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/page-shell.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 391
} | 10 |
import { AppPageLoading } from "@/app/(app)/_components/page-loading";
import { adminFeedbackPageConfig } from "@/app/(app)/admin/feedbacks/_constants/page-config";
import { Skeleton } from "@/components/ui/skeleton";
export default function AdminFeedbackPageLoading() {
return (
<AppPageLoading
title={adminFeedbackPageConfig.title}
description={adminFeedbackPageConfig.description}
>
<Skeleton className="h-96 w-full" />
</AppPageLoading>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/feedbacks/loading.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/feedbacks/loading.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 196
} | 11 |
Subsets and Splits