text
stringlengths 21
253k
| id
stringlengths 25
123
| metadata
dict | __index_level_0__
int64 0
181
|
---|---|---|---|
import { Textarea } from "@/registry/default/ui/textarea"
export default function TextareaDisabled() {
return <Textarea placeholder="Type your message here." disabled />
}
| shadcn-ui/ui/apps/www/registry/default/example/textarea-disabled.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/default/example/textarea-disabled.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 47
} | 71 |
import { Badge } from "@/registry/new-york/ui/badge"
export default function BadgeDestructive() {
return <Badge variant="destructive">Destructive</Badge>
}
| shadcn-ui/ui/apps/www/registry/new-york/example/badge-destructive.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/badge-destructive.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 52
} | 72 |
import { Button } from "@/registry/new-york/ui/button"
export default function ButtonOutline() {
return <Button variant="outline">Outline</Button>
}
| shadcn-ui/ui/apps/www/registry/new-york/example/button-outline.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/button-outline.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 47
} | 73 |
"use client"
import { Checkbox } from "@/registry/new-york/ui/checkbox"
export default function CheckboxDemo() {
return (
<div className="flex items-center space-x-2">
<Checkbox id="terms" />
<label
htmlFor="terms"
className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
>
Accept terms and conditions
</label>
</div>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/checkbox-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/checkbox-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 176
} | 74 |
"use client"
import { zodResolver } from "@hookform/resolvers/zod"
import { CalendarIcon } from "@radix-ui/react-icons"
import { format } from "date-fns"
import { useForm } from "react-hook-form"
import { z } from "zod"
import { cn } from "@/lib/utils"
import { toast } from "@/registry/new-york/hooks/use-toast"
import { Button } from "@/registry/new-york/ui/button"
import { Calendar } from "@/registry/new-york/ui/calendar"
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/registry/new-york/ui/form"
import {
Popover,
PopoverContent,
PopoverTrigger,
} from "@/registry/new-york/ui/popover"
const FormSchema = z.object({
dob: z.date({
required_error: "A date of birth is required.",
}),
})
export default function DatePickerForm() {
const form = useForm<z.infer<typeof FormSchema>>({
resolver: zodResolver(FormSchema),
})
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-8">
<FormField
control={form.control}
name="dob"
render={({ field }) => (
<FormItem className="flex flex-col">
<FormLabel>Date of birth</FormLabel>
<Popover>
<PopoverTrigger asChild>
<FormControl>
<Button
variant={"outline"}
className={cn(
"w-[240px] pl-3 text-left font-normal",
!field.value && "text-muted-foreground"
)}
>
{field.value ? (
format(field.value, "PPP")
) : (
<span>Pick a date</span>
)}
<CalendarIcon className="ml-auto h-4 w-4 opacity-50" />
</Button>
</FormControl>
</PopoverTrigger>
<PopoverContent className="w-auto p-0" align="start">
<Calendar
mode="single"
selected={field.value}
onSelect={field.onChange}
disabled={(date) =>
date > new Date() || date < new Date("1900-01-01")
}
initialFocus
/>
</PopoverContent>
</Popover>
<FormDescription>
Your date of birth is used to calculate your age.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<Button type="submit">Submit</Button>
</form>
</Form>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/date-picker-form.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/date-picker-form.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1610
} | 75 |
import {
InputOTP,
InputOTPGroup,
InputOTPSeparator,
InputOTPSlot,
} from "@/registry/new-york/ui/input-otp"
export default function InputOTPDemo() {
return (
<InputOTP maxLength={6}>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
</InputOTPGroup>
<InputOTPSeparator />
<InputOTPGroup>
<InputOTPSlot index={3} />
<InputOTPSlot index={4} />
<InputOTPSlot index={5} />
</InputOTPGroup>
</InputOTP>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/input-otp-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/input-otp-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 265
} | 76 |
import {
ResizableHandle,
ResizablePanel,
ResizablePanelGroup,
} from "@/registry/new-york/ui/resizable"
export default function ResizableDemo() {
return (
<ResizablePanelGroup
direction="horizontal"
className="max-w-md rounded-lg border md:min-w-[450px]"
>
<ResizablePanel defaultSize={50}>
<div className="flex h-[200px] items-center justify-center p-6">
<span className="font-semibold">One</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize={50}>
<ResizablePanelGroup direction="vertical">
<ResizablePanel defaultSize={25}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Two</span>
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize={75}>
<div className="flex h-full items-center justify-center p-6">
<span className="font-semibold">Three</span>
</div>
</ResizablePanel>
</ResizablePanelGroup>
</ResizablePanel>
</ResizablePanelGroup>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/resizable-demo-with-handle.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/resizable-demo-with-handle.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 524
} | 77 |
import { Label } from "@/registry/new-york/ui/label"
import { Switch } from "@/registry/new-york/ui/switch"
export default function SwitchDemo() {
return (
<div className="flex items-center space-x-2">
<Switch id="airplane-mode" />
<Label htmlFor="airplane-mode">Airplane Mode</Label>
</div>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/switch-demo.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/switch-demo.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 123
} | 78 |
import { UnderlineIcon } from "@radix-ui/react-icons"
import { Toggle } from "@/registry/new-york/ui/toggle"
export default function ToggleDisabled() {
return (
<Toggle aria-label="Toggle italic" disabled>
<UnderlineIcon className="h-4 w-4" />
</Toggle>
)
}
| shadcn-ui/ui/apps/www/registry/new-york/example/toggle-disabled.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/example/toggle-disabled.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 106
} | 79 |
import { cn } from "@/lib/utils"
function Skeleton({
className,
...props
}: React.HTMLAttributes<HTMLDivElement>) {
return (
<div
className={cn("animate-pulse rounded-md bg-primary/10", className)}
{...props}
/>
)
}
export { Skeleton }
| shadcn-ui/ui/apps/www/registry/new-york/ui/skeleton.tsx | {
"file_path": "shadcn-ui/ui/apps/www/registry/new-york/ui/skeleton.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 107
} | 80 |
import { Registry } from "@/registry/schema"
export const examples: Registry = [
{
name: "accordion-demo",
type: "registry:example",
registryDependencies: ["accordion"],
files: ["example/accordion-demo.tsx"],
},
{
name: "alert-demo",
type: "registry:example",
registryDependencies: ["alert"],
files: ["example/alert-demo.tsx"],
},
{
name: "alert-destructive",
type: "registry:example",
registryDependencies: ["alert"],
files: ["example/alert-destructive.tsx"],
},
{
name: "alert-dialog-demo",
type: "registry:example",
registryDependencies: ["alert-dialog", "button"],
files: ["example/alert-dialog-demo.tsx"],
},
{
name: "aspect-ratio-demo",
type: "registry:example",
registryDependencies: ["aspect-ratio"],
files: ["example/aspect-ratio-demo.tsx"],
},
{
name: "avatar-demo",
type: "registry:example",
registryDependencies: ["avatar"],
files: ["example/avatar-demo.tsx"],
},
{
name: "badge-demo",
type: "registry:example",
registryDependencies: ["badge"],
files: ["example/badge-demo.tsx"],
},
{
name: "badge-destructive",
type: "registry:example",
registryDependencies: ["badge"],
files: ["example/badge-destructive.tsx"],
},
{
name: "badge-outline",
type: "registry:example",
registryDependencies: ["badge"],
files: ["example/badge-outline.tsx"],
},
{
name: "badge-secondary",
type: "registry:example",
registryDependencies: ["badge"],
files: ["example/badge-secondary.tsx"],
},
{
name: "breadcrumb-demo",
type: "registry:example",
registryDependencies: ["breadcrumb"],
files: ["example/breadcrumb-demo.tsx"],
},
{
name: "breadcrumb-separator",
type: "registry:example",
registryDependencies: ["breadcrumb"],
files: ["example/breadcrumb-separator.tsx"],
},
{
name: "breadcrumb-dropdown",
type: "registry:example",
registryDependencies: ["breadcrumb"],
files: ["example/breadcrumb-dropdown.tsx"],
},
{
name: "breadcrumb-ellipsis",
type: "registry:example",
registryDependencies: ["breadcrumb"],
files: ["example/breadcrumb-ellipsis.tsx"],
},
{
name: "breadcrumb-link",
type: "registry:example",
registryDependencies: ["breadcrumb"],
files: ["example/breadcrumb-link.tsx"],
},
{
name: "breadcrumb-responsive",
type: "registry:example",
registryDependencies: ["breadcrumb"],
files: ["example/breadcrumb-responsive.tsx"],
},
{
name: "button-demo",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-demo.tsx"],
},
{
name: "button-secondary",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-secondary.tsx"],
},
{
name: "button-destructive",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-destructive.tsx"],
},
{
name: "button-outline",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-outline.tsx"],
},
{
name: "button-ghost",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-ghost.tsx"],
},
{
name: "button-link",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-link.tsx"],
},
{
name: "button-with-icon",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-with-icon.tsx"],
},
{
name: "button-loading",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-loading.tsx"],
},
{
name: "button-icon",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-icon.tsx"],
},
{
name: "button-as-child",
type: "registry:example",
registryDependencies: ["button"],
files: ["example/button-as-child.tsx"],
},
{
name: "calendar-demo",
type: "registry:example",
registryDependencies: ["calendar"],
files: ["example/calendar-demo.tsx"],
},
{
name: "calendar-form",
type: "registry:example",
registryDependencies: ["calendar", "form", "popover"],
files: ["example/calendar-form.tsx"],
},
{
name: "card-demo",
type: "registry:example",
registryDependencies: ["card", "button", "switch"],
files: ["example/card-demo.tsx"],
},
{
name: "card-with-form",
type: "registry:example",
registryDependencies: ["button", "card", "input", "label", "select"],
files: ["example/card-with-form.tsx"],
},
{
name: "carousel-demo",
type: "registry:example",
registryDependencies: ["carousel"],
files: ["example/carousel-demo.tsx"],
},
{
name: "carousel-size",
type: "registry:example",
registryDependencies: ["carousel"],
files: ["example/carousel-size.tsx"],
},
{
name: "carousel-spacing",
type: "registry:example",
registryDependencies: ["carousel"],
files: ["example/carousel-spacing.tsx"],
},
{
name: "carousel-orientation",
type: "registry:example",
registryDependencies: ["carousel"],
files: ["example/carousel-orientation.tsx"],
},
{
name: "carousel-api",
type: "registry:example",
registryDependencies: ["carousel"],
files: ["example/carousel-api.tsx"],
},
{
name: "carousel-plugin",
type: "registry:example",
registryDependencies: ["carousel"],
files: ["example/carousel-plugin.tsx"],
},
{
name: "checkbox-demo",
type: "registry:example",
registryDependencies: ["checkbox"],
files: ["example/checkbox-demo.tsx"],
},
{
name: "checkbox-disabled",
type: "registry:example",
registryDependencies: ["checkbox"],
files: ["example/checkbox-disabled.tsx"],
},
{
name: "checkbox-form-multiple",
type: "registry:example",
registryDependencies: ["checkbox", "form"],
files: ["example/checkbox-form-multiple.tsx"],
},
{
name: "checkbox-form-single",
type: "registry:example",
registryDependencies: ["checkbox", "form"],
files: ["example/checkbox-form-single.tsx"],
},
{
name: "checkbox-with-text",
type: "registry:example",
registryDependencies: ["checkbox"],
files: ["example/checkbox-with-text.tsx"],
},
{
name: "collapsible-demo",
type: "registry:example",
registryDependencies: ["collapsible"],
files: ["example/collapsible-demo.tsx"],
},
{
name: "combobox-demo",
type: "registry:example",
registryDependencies: ["command"],
files: ["example/combobox-demo.tsx"],
},
{
name: "combobox-dropdown-menu",
type: "registry:example",
registryDependencies: ["command", "dropdown-menu", "button"],
files: ["example/combobox-dropdown-menu.tsx"],
},
{
name: "combobox-form",
type: "registry:example",
registryDependencies: ["command", "form"],
files: ["example/combobox-form.tsx"],
},
{
name: "combobox-popover",
type: "registry:example",
registryDependencies: ["combobox", "popover"],
files: ["example/combobox-popover.tsx"],
},
{
name: "combobox-responsive",
type: "registry:example",
registryDependencies: ["combobox", "popover", "drawer"],
files: ["example/combobox-responsive.tsx"],
},
{
name: "command-demo",
type: "registry:example",
registryDependencies: ["command"],
files: ["example/command-demo.tsx"],
},
{
name: "command-dialog",
type: "registry:example",
registryDependencies: ["command", "dialog"],
files: ["example/command-dialog.tsx"],
},
{
name: "context-menu-demo",
type: "registry:example",
registryDependencies: ["context-menu"],
files: ["example/context-menu-demo.tsx"],
},
{
name: "data-table-demo",
type: "registry:example",
registryDependencies: ["data-table"],
files: ["example/data-table-demo.tsx"],
},
{
name: "date-picker-demo",
type: "registry:example",
registryDependencies: ["button", "calendar", "popover"],
files: ["example/date-picker-demo.tsx"],
dependencies: ["date-fns"],
},
{
name: "date-picker-form",
type: "registry:example",
registryDependencies: ["button", "calendar", "form", "popover"],
files: ["example/date-picker-form.tsx"],
dependencies: ["date-fns"],
},
{
name: "date-picker-with-presets",
type: "registry:example",
registryDependencies: ["button", "calendar", "popover", "select"],
files: ["example/date-picker-with-presets.tsx"],
dependencies: ["date-fns"],
},
{
name: "date-picker-with-range",
type: "registry:example",
registryDependencies: ["button", "calendar", "popover"],
files: ["example/date-picker-with-range.tsx"],
dependencies: ["date-fns"],
},
{
name: "dialog-demo",
type: "registry:example",
registryDependencies: ["dialog"],
files: ["example/dialog-demo.tsx"],
},
{
name: "dialog-close-button",
type: "registry:example",
registryDependencies: ["dialog", "button"],
files: ["example/dialog-close-button.tsx"],
},
{
name: "drawer-demo",
type: "registry:example",
registryDependencies: ["drawer"],
files: ["example/drawer-demo.tsx"],
},
{
name: "drawer-dialog",
type: "registry:example",
registryDependencies: ["drawer", "dialog"],
files: ["example/drawer-dialog.tsx"],
},
{
name: "dropdown-menu-demo",
type: "registry:example",
registryDependencies: ["dropdown-menu"],
files: ["example/dropdown-menu-demo.tsx"],
},
{
name: "dropdown-menu-checkboxes",
type: "registry:example",
registryDependencies: ["dropdown-menu", "checkbox"],
files: ["example/dropdown-menu-checkboxes.tsx"],
},
{
name: "dropdown-menu-radio-group",
type: "registry:example",
registryDependencies: ["dropdown-menu", "radio-group"],
files: ["example/dropdown-menu-radio-group.tsx"],
},
{
name: "hover-card-demo",
type: "registry:example",
registryDependencies: ["hover-card"],
files: ["example/hover-card-demo.tsx"],
},
{
name: "input-demo",
type: "registry:example",
registryDependencies: ["input"],
files: ["example/input-demo.tsx"],
},
{
name: "input-disabled",
type: "registry:example",
registryDependencies: ["input"],
files: ["example/input-disabled.tsx"],
},
{
name: "input-file",
type: "registry:example",
registryDependencies: ["input"],
files: ["example/input-file.tsx"],
},
{
name: "input-form",
type: "registry:example",
registryDependencies: ["input", "button", "form"],
files: ["example/input-form.tsx"],
},
{
name: "input-with-button",
type: "registry:example",
registryDependencies: ["input", "button"],
files: ["example/input-with-button.tsx"],
},
{
name: "input-with-label",
type: "registry:example",
registryDependencies: ["input", "button", "label"],
files: ["example/input-with-label.tsx"],
},
{
name: "input-with-text",
type: "registry:example",
registryDependencies: ["input", "button", "label"],
files: ["example/input-with-text.tsx"],
},
{
name: "input-otp-demo",
type: "registry:example",
registryDependencies: ["input-otp"],
files: ["example/input-otp-demo.tsx"],
},
{
name: "input-otp-pattern",
type: "registry:example",
registryDependencies: ["input-otp"],
files: ["example/input-otp-pattern.tsx"],
},
{
name: "input-otp-separator",
type: "registry:example",
registryDependencies: ["input-otp"],
files: ["example/input-otp-separator.tsx"],
},
{
name: "input-otp-controlled",
type: "registry:example",
registryDependencies: ["input-otp"],
files: ["example/input-otp-controlled.tsx"],
},
{
name: "input-otp-form",
type: "registry:example",
registryDependencies: ["input-otp", "form"],
files: ["example/input-otp-form.tsx"],
},
{
name: "label-demo",
type: "registry:example",
registryDependencies: ["label"],
files: ["example/label-demo.tsx"],
},
{
name: "menubar-demo",
type: "registry:example",
registryDependencies: ["menubar"],
files: ["example/menubar-demo.tsx"],
},
{
name: "navigation-menu-demo",
type: "registry:example",
registryDependencies: ["navigation-menu"],
files: ["example/navigation-menu-demo.tsx"],
},
{
name: "pagination-demo",
type: "registry:example",
registryDependencies: ["pagination"],
files: ["example/pagination-demo.tsx"],
},
{
name: "popover-demo",
type: "registry:example",
registryDependencies: ["popover"],
files: ["example/popover-demo.tsx"],
},
{
name: "progress-demo",
type: "registry:example",
registryDependencies: ["progress"],
files: ["example/progress-demo.tsx"],
},
{
name: "radio-group-demo",
type: "registry:example",
registryDependencies: ["radio-group"],
files: ["example/radio-group-demo.tsx"],
},
{
name: "radio-group-form",
type: "registry:example",
registryDependencies: ["radio-group", "form"],
files: ["example/radio-group-form.tsx"],
},
{
name: "resizable-demo",
type: "registry:example",
registryDependencies: ["resizable"],
files: ["example/resizable-demo.tsx"],
},
{
name: "resizable-demo-with-handle",
type: "registry:example",
registryDependencies: ["resizable"],
files: ["example/resizable-demo-with-handle.tsx"],
},
{
name: "resizable-vertical",
type: "registry:example",
registryDependencies: ["resizable"],
files: ["example/resizable-vertical.tsx"],
},
{
name: "resizable-handle",
type: "registry:example",
registryDependencies: ["resizable"],
files: ["example/resizable-handle.tsx"],
},
{
name: "scroll-area-demo",
type: "registry:example",
registryDependencies: ["scroll-area"],
files: ["example/scroll-area-demo.tsx"],
},
{
name: "scroll-area-horizontal-demo",
type: "registry:example",
registryDependencies: ["scroll-area"],
files: ["example/scroll-area-horizontal-demo.tsx"],
},
{
name: "select-demo",
type: "registry:example",
registryDependencies: ["select"],
files: ["example/select-demo.tsx"],
},
{
name: "select-scrollable",
type: "registry:example",
registryDependencies: ["select"],
files: ["example/select-scrollable.tsx"],
},
{
name: "select-form",
type: "registry:example",
registryDependencies: ["select"],
files: ["example/select-form.tsx"],
},
{
name: "separator-demo",
type: "registry:example",
registryDependencies: ["separator"],
files: ["example/separator-demo.tsx"],
},
{
name: "sheet-demo",
type: "registry:example",
registryDependencies: ["sheet"],
files: ["example/sheet-demo.tsx"],
},
{
name: "sheet-side",
type: "registry:example",
registryDependencies: ["sheet"],
files: ["example/sheet-side.tsx"],
},
{
name: "skeleton-demo",
type: "registry:example",
registryDependencies: ["skeleton"],
files: ["example/skeleton-demo.tsx"],
},
{
name: "skeleton-card",
type: "registry:example",
registryDependencies: ["skeleton"],
files: ["example/skeleton-card.tsx"],
},
{
name: "slider-demo",
type: "registry:example",
registryDependencies: ["slider"],
files: ["example/slider-demo.tsx"],
},
{
name: "sonner-demo",
type: "registry:example",
registryDependencies: ["sonner"],
files: ["example/sonner-demo.tsx"],
},
{
name: "switch-demo",
type: "registry:example",
registryDependencies: ["switch"],
files: ["example/switch-demo.tsx"],
},
{
name: "switch-form",
type: "registry:example",
registryDependencies: ["switch", "form"],
files: ["example/switch-form.tsx"],
},
{
name: "table-demo",
type: "registry:example",
registryDependencies: ["table"],
files: ["example/table-demo.tsx"],
},
{
name: "tabs-demo",
type: "registry:example",
registryDependencies: ["tabs"],
files: ["example/tabs-demo.tsx"],
},
{
name: "textarea-demo",
type: "registry:example",
registryDependencies: ["textarea"],
files: ["example/textarea-demo.tsx"],
},
{
name: "textarea-disabled",
type: "registry:example",
registryDependencies: ["textarea"],
files: ["example/textarea-disabled.tsx"],
},
{
name: "textarea-form",
type: "registry:example",
registryDependencies: ["textarea", "form"],
files: ["example/textarea-form.tsx"],
},
{
name: "textarea-with-button",
type: "registry:example",
registryDependencies: ["textarea", "button"],
files: ["example/textarea-with-button.tsx"],
},
{
name: "textarea-with-label",
type: "registry:example",
registryDependencies: ["textarea", "label"],
files: ["example/textarea-with-label.tsx"],
},
{
name: "textarea-with-text",
type: "registry:example",
registryDependencies: ["textarea", "label"],
files: ["example/textarea-with-text.tsx"],
},
{
name: "toast-demo",
type: "registry:example",
registryDependencies: ["toast"],
files: ["example/toast-demo.tsx"],
},
{
name: "toast-destructive",
type: "registry:example",
registryDependencies: ["toast"],
files: ["example/toast-destructive.tsx"],
},
{
name: "toast-simple",
type: "registry:example",
registryDependencies: ["toast"],
files: ["example/toast-simple.tsx"],
},
{
name: "toast-with-action",
type: "registry:example",
registryDependencies: ["toast"],
files: ["example/toast-with-action.tsx"],
},
{
name: "toast-with-title",
type: "registry:example",
registryDependencies: ["toast"],
files: ["example/toast-with-title.tsx"],
},
{
name: "toggle-group-demo",
type: "registry:example",
registryDependencies: ["toggle-group"],
files: ["example/toggle-group-demo.tsx"],
},
{
name: "toggle-group-disabled",
type: "registry:example",
registryDependencies: ["toggle-group"],
files: ["example/toggle-group-disabled.tsx"],
},
{
name: "toggle-group-lg",
type: "registry:example",
registryDependencies: ["toggle-group"],
files: ["example/toggle-group-lg.tsx"],
},
{
name: "toggle-group-outline",
type: "registry:example",
registryDependencies: ["toggle-group"],
files: ["example/toggle-group-outline.tsx"],
},
{
name: "toggle-group-sm",
type: "registry:example",
registryDependencies: ["toggle-group"],
files: ["example/toggle-group-sm.tsx"],
},
{
name: "toggle-group-single",
type: "registry:example",
registryDependencies: ["toggle-group"],
files: ["example/toggle-group-single.tsx"],
},
{
name: "toggle-demo",
type: "registry:example",
registryDependencies: ["toggle"],
files: ["example/toggle-demo.tsx"],
},
{
name: "toggle-disabled",
type: "registry:example",
registryDependencies: ["toggle"],
files: ["example/toggle-disabled.tsx"],
},
{
name: "toggle-lg",
type: "registry:example",
registryDependencies: ["toggle"],
files: ["example/toggle-lg.tsx"],
},
{
name: "toggle-outline",
type: "registry:example",
registryDependencies: ["toggle"],
files: ["example/toggle-outline.tsx"],
},
{
name: "toggle-sm",
type: "registry:example",
registryDependencies: ["toggle"],
files: ["example/toggle-sm.tsx"],
},
{
name: "toggle-with-text",
type: "registry:example",
registryDependencies: ["toggle"],
files: ["example/toggle-with-text.tsx"],
},
{
name: "tooltip-demo",
type: "registry:example",
registryDependencies: ["tooltip"],
files: ["example/tooltip-demo.tsx"],
},
{
name: "typography-blockquote",
type: "registry:example",
files: ["example/typography-blockquote.tsx"],
},
{
name: "typography-demo",
type: "registry:example",
files: ["example/typography-demo.tsx"],
},
{
name: "typography-h1",
type: "registry:example",
files: ["example/typography-h1.tsx"],
},
{
name: "typography-h2",
type: "registry:example",
files: ["example/typography-h2.tsx"],
},
{
name: "typography-h3",
type: "registry:example",
files: ["example/typography-h3.tsx"],
},
{
name: "typography-h4",
type: "registry:example",
files: ["example/typography-h4.tsx"],
},
{
name: "typography-inline-code",
type: "registry:example",
files: ["example/typography-inline-code.tsx"],
},
{
name: "typography-large",
type: "registry:example",
files: ["example/typography-large.tsx"],
},
{
name: "typography-lead",
type: "registry:example",
files: ["example/typography-lead.tsx"],
},
{
name: "typography-list",
type: "registry:example",
files: ["example/typography-list.tsx"],
},
{
name: "typography-muted",
type: "registry:example",
files: ["example/typography-muted.tsx"],
},
{
name: "typography-p",
type: "registry:example",
files: ["example/typography-p.tsx"],
},
{
name: "typography-small",
type: "registry:example",
files: ["example/typography-small.tsx"],
},
{
name: "typography-table",
type: "registry:example",
files: ["example/typography-table.tsx"],
},
{
name: "mode-toggle",
type: "registry:example",
files: ["example/mode-toggle.tsx"],
},
{
name: "chart-bar-demo",
type: "registry:example",
files: ["example/chart-bar-demo.tsx"],
},
{
name: "chart-bar-demo-grid",
type: "registry:example",
files: ["example/chart-bar-demo-grid.tsx"],
},
{
name: "chart-bar-demo-axis",
type: "registry:example",
files: ["example/chart-bar-demo-axis.tsx"],
},
{
name: "chart-bar-demo-tooltip",
type: "registry:example",
files: ["example/chart-bar-demo-tooltip.tsx"],
},
{
name: "chart-bar-demo-legend",
type: "registry:example",
files: ["example/chart-bar-demo-legend.tsx"],
},
{
name: "chart-tooltip-demo",
type: "registry:example",
files: ["example/chart-tooltip-demo.tsx"],
},
]
| shadcn-ui/ui/apps/www/registry/registry-examples.ts | {
"file_path": "shadcn-ui/ui/apps/www/registry/registry-examples.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 9184
} | 81 |
import path from "path"
import { Config } from "@/src/utils/get-config"
import {
registryBaseColorSchema,
registryIndexSchema,
registryItemWithContentSchema,
registryWithContentSchema,
stylesSchema,
} from "@/src/utils/registry/schema"
import { HttpsProxyAgent } from "https-proxy-agent"
import fetch from "node-fetch"
import { z } from "zod"
const baseUrl = process.env.COMPONENTS_REGISTRY_URL ?? "https://ui.shadcn.com"
const agent = process.env.https_proxy
? new HttpsProxyAgent(process.env.https_proxy)
: undefined
export async function getRegistryIndex() {
try {
const [result] = await fetchRegistry(["index.json"])
return registryIndexSchema.parse(result)
} catch (error) {
throw new Error(`Failed to fetch components from registry.`)
}
}
export async function getRegistryStyles() {
try {
const [result] = await fetchRegistry(["styles/index.json"])
return stylesSchema.parse(result)
} catch (error) {
throw new Error(`Failed to fetch styles from registry.`)
}
}
export async function getRegistryBaseColors() {
return [
{
name: "slate",
label: "Slate",
},
{
name: "gray",
label: "Gray",
},
{
name: "zinc",
label: "Zinc",
},
{
name: "neutral",
label: "Neutral",
},
{
name: "stone",
label: "Stone",
},
]
}
export async function getRegistryBaseColor(baseColor: string) {
try {
const [result] = await fetchRegistry([`colors/${baseColor}.json`])
return registryBaseColorSchema.parse(result)
} catch (error) {
throw new Error(`Failed to fetch base color from registry.`)
}
}
export async function resolveTree(
index: z.infer<typeof registryIndexSchema>,
names: string[]
) {
const tree: z.infer<typeof registryIndexSchema> = []
for (const name of names) {
const entry = index.find((entry) => entry.name === name)
if (!entry) {
continue
}
tree.push(entry)
if (entry.registryDependencies) {
const dependencies = await resolveTree(index, entry.registryDependencies)
tree.push(...dependencies)
}
}
return tree.filter(
(component, index, self) =>
self.findIndex((c) => c.name === component.name) === index
)
}
export async function fetchTree(
style: string,
tree: z.infer<typeof registryIndexSchema>
) {
try {
const paths = tree.map((item) => `styles/${style}/${item.name}.json`)
const result = await fetchRegistry(paths)
return registryWithContentSchema.parse(result)
} catch (error) {
throw new Error(`Failed to fetch tree from registry.`)
}
}
export async function getItemTargetPath(
config: Config,
item: Pick<z.infer<typeof registryItemWithContentSchema>, "type">,
override?: string
) {
if (override) {
return override
}
if (item.type === "components:ui" && config.aliases.ui) {
return config.resolvedPaths.ui
}
const [parent, type] = item.type.split(":")
if (!(parent in config.resolvedPaths)) {
return null
}
return path.join(
config.resolvedPaths[parent as keyof typeof config.resolvedPaths],
type
)
}
async function fetchRegistry(paths: string[]) {
try {
const results = await Promise.all(
paths.map(async (path) => {
const response = await fetch(`${baseUrl}/registry/${path}`, {
agent,
})
return await response.json()
})
)
return results
} catch (error) {
console.log(error)
throw new Error(`Failed to fetch registry from ${baseUrl}.`)
}
}
| shadcn-ui/ui/packages/cli/src/utils/registry/index.ts | {
"file_path": "shadcn-ui/ui/packages/cli/src/utils/registry/index.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 1335
} | 82 |
import { Inter } from 'next/font/google'
import './globals.css'
const inter = Inter({ subsets: ['latin'] })
export const metadata = {
title: 'Create Next App',
description: 'Generated by create next app',
}
export default function RootLayout({ children }) {
return (
<html lang="en">
<body className={inter.className}>{children}</body>
</html>
)
}
| shadcn-ui/ui/packages/cli/test/fixtures/next-app-js/app/layout.js | {
"file_path": "shadcn-ui/ui/packages/cli/test/fixtures/next-app-js/app/layout.js",
"repo_id": "shadcn-ui/ui",
"token_count": 128
} | 83 |
import path from "path"
import { describe, expect, test } from "vitest"
import { getTsConfigAliasPrefix } from "../../src/utils/get-project-info"
describe("get ts config alias prefix", async () => {
test.each([
{
name: "next-app",
prefix: "@",
},
{
name: "next-app-src",
prefix: "#",
},
{
name: "next-pages",
prefix: "~",
},
{
name: "next-pages-src",
prefix: "@",
},
{
name: "t3-app",
prefix: "~",
},
])(`getTsConfigAliasPrefix($name) -> $prefix`, async ({ name, prefix }) => {
expect(
await getTsConfigAliasPrefix(
path.resolve(__dirname, `../fixtures/${name}`)
)
).toBe(prefix)
})
})
| shadcn-ui/ui/packages/cli/test/utils/get-ts-config-alias-prefix.test.ts | {
"file_path": "shadcn-ui/ui/packages/cli/test/utils/get-ts-config-alias-prefix.test.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 335
} | 84 |
import path from "path"
import { Config } from "@/src/utils/get-config"
import { handleError } from "@/src/utils/handle-error"
import { highlighter } from "@/src/utils/highlighter"
import { logger } from "@/src/utils/logger"
import {
registryBaseColorSchema,
registryIndexSchema,
registryItemFileSchema,
registryItemSchema,
registryResolvedItemsTreeSchema,
stylesSchema,
} from "@/src/utils/registry/schema"
import { buildTailwindThemeColorsFromCssVars } from "@/src/utils/updaters/update-tailwind-config"
import deepmerge from "deepmerge"
import { HttpsProxyAgent } from "https-proxy-agent"
import fetch from "node-fetch"
import { z } from "zod"
const REGISTRY_URL = process.env.REGISTRY_URL ?? "https://ui.shadcn.com/r"
const agent = process.env.https_proxy
? new HttpsProxyAgent(process.env.https_proxy)
: undefined
export async function getRegistryIndex() {
try {
const [result] = await fetchRegistry(["index.json"])
return registryIndexSchema.parse(result)
} catch (error) {
logger.error("\n")
handleError(error)
}
}
export async function getRegistryStyles() {
try {
const [result] = await fetchRegistry(["styles/index.json"])
return stylesSchema.parse(result)
} catch (error) {
logger.error("\n")
handleError(error)
return []
}
}
export async function getRegistryItem(name: string, style: string) {
try {
const [result] = await fetchRegistry([
isUrl(name) ? name : `styles/${style}/${name}.json`,
])
return registryItemSchema.parse(result)
} catch (error) {
logger.break()
handleError(error)
return null
}
}
export async function getRegistryBaseColors() {
return [
{
name: "neutral",
label: "Neutral",
},
{
name: "gray",
label: "Gray",
},
{
name: "zinc",
label: "Zinc",
},
{
name: "stone",
label: "Stone",
},
{
name: "slate",
label: "Slate",
},
]
}
export async function getRegistryBaseColor(baseColor: string) {
try {
const [result] = await fetchRegistry([`colors/${baseColor}.json`])
return registryBaseColorSchema.parse(result)
} catch (error) {
handleError(error)
}
}
export async function resolveTree(
index: z.infer<typeof registryIndexSchema>,
names: string[]
) {
const tree: z.infer<typeof registryIndexSchema> = []
for (const name of names) {
const entry = index.find((entry) => entry.name === name)
if (!entry) {
continue
}
tree.push(entry)
if (entry.registryDependencies) {
const dependencies = await resolveTree(index, entry.registryDependencies)
tree.push(...dependencies)
}
}
return tree.filter(
(component, index, self) =>
self.findIndex((c) => c.name === component.name) === index
)
}
export async function fetchTree(
style: string,
tree: z.infer<typeof registryIndexSchema>
) {
try {
const paths = tree.map((item) => `styles/${style}/${item.name}.json`)
const result = await fetchRegistry(paths)
return registryIndexSchema.parse(result)
} catch (error) {
handleError(error)
}
}
export async function getItemTargetPath(
config: Config,
item: Pick<z.infer<typeof registryItemSchema>, "type">,
override?: string
) {
if (override) {
return override
}
if (item.type === "registry:ui") {
return config.resolvedPaths.ui ?? config.resolvedPaths.components
}
const [parent, type] = item.type?.split(":") ?? []
if (!(parent in config.resolvedPaths)) {
return null
}
return path.join(
config.resolvedPaths[parent as keyof typeof config.resolvedPaths],
type
)
}
async function fetchRegistry(paths: string[]) {
try {
const results = await Promise.all(
paths.map(async (path) => {
const url = getRegistryUrl(path)
const response = await fetch(url, { agent })
if (!response.ok) {
const errorMessages: { [key: number]: string } = {
400: "Bad request",
401: "Unauthorized",
403: "Forbidden",
404: "Not found",
500: "Internal server error",
}
if (response.status === 401) {
throw new Error(
`You are not authorized to access the component at ${highlighter.info(
url
)}.\nIf this is a remote registry, you may need to authenticate.`
)
}
if (response.status === 404) {
throw new Error(
`The component at ${highlighter.info(
url
)} was not found.\nIt may not exist at the registry. Please make sure it is a valid component.`
)
}
if (response.status === 403) {
throw new Error(
`You do not have access to the component at ${highlighter.info(
url
)}.\nIf this is a remote registry, you may need to authenticate or a token.`
)
}
const result = await response.json()
const message =
result && typeof result === "object" && "error" in result
? result.error
: response.statusText || errorMessages[response.status]
throw new Error(
`Failed to fetch from ${highlighter.info(url)}.\n${message}`
)
}
return response.json()
})
)
return results
} catch (error) {
logger.error("\n")
handleError(error)
return []
}
}
export function getRegistryItemFileTargetPath(
file: z.infer<typeof registryItemFileSchema>,
config: Config,
override?: string
) {
if (override) {
return override
}
if (file.type === "registry:ui") {
return config.resolvedPaths.ui
}
if (file.type === "registry:lib") {
return config.resolvedPaths.lib
}
if (file.type === "registry:block" || file.type === "registry:component") {
return config.resolvedPaths.components
}
if (file.type === "registry:hook") {
return config.resolvedPaths.hooks
}
// TODO: we put this in components for now.
// We should move this to pages as per framework.
if (file.type === "registry:page") {
return config.resolvedPaths.components
}
return config.resolvedPaths.components
}
export async function registryResolveItemsTree(
names: z.infer<typeof registryItemSchema>["name"][],
config: Config
) {
try {
const index = await getRegistryIndex()
if (!index) {
return null
}
// If we're resolving the index, we want it to go first.
if (names.includes("index")) {
names.unshift("index")
}
let registryDependencies: string[] = []
for (const name of names) {
const itemRegistryDependencies = await resolveRegistryDependencies(
name,
config
)
registryDependencies.push(...itemRegistryDependencies)
}
const uniqueRegistryDependencies = Array.from(new Set(registryDependencies))
let result = await fetchRegistry(uniqueRegistryDependencies)
const payload = z.array(registryItemSchema).parse(result)
if (!payload) {
return null
}
// If we're resolving the index, we want to fetch
// the theme item if a base color is provided.
// We do this for index only.
// Other components will ship with their theme tokens.
if (names.includes("index")) {
if (config.tailwind.baseColor) {
const theme = await registryGetTheme(config.tailwind.baseColor, config)
if (theme) {
payload.unshift(theme)
}
}
}
let tailwind = {}
payload.forEach((item) => {
tailwind = deepmerge(tailwind, item.tailwind ?? {})
})
let cssVars = {}
payload.forEach((item) => {
cssVars = deepmerge(cssVars, item.cssVars ?? {})
})
let docs = ""
payload.forEach((item) => {
if (item.docs) {
docs += `${item.docs}\n`
}
})
return registryResolvedItemsTreeSchema.parse({
dependencies: deepmerge.all(
payload.map((item) => item.dependencies ?? [])
),
devDependencies: deepmerge.all(
payload.map((item) => item.devDependencies ?? [])
),
files: deepmerge.all(payload.map((item) => item.files ?? [])),
tailwind,
cssVars,
docs,
})
} catch (error) {
handleError(error)
return null
}
}
async function resolveRegistryDependencies(
url: string,
config: Config
): Promise<string[]> {
const visited = new Set<string>()
const payload: string[] = []
async function resolveDependencies(itemUrl: string) {
const url = getRegistryUrl(
isUrl(itemUrl) ? itemUrl : `styles/${config.style}/${itemUrl}.json`
)
if (visited.has(url)) {
return
}
visited.add(url)
try {
const [result] = await fetchRegistry([url])
const item = registryItemSchema.parse(result)
payload.push(url)
if (item.registryDependencies) {
for (const dependency of item.registryDependencies) {
await resolveDependencies(dependency)
}
}
} catch (error) {
console.error(
`Error fetching or parsing registry item at ${itemUrl}:`,
error
)
}
}
await resolveDependencies(url)
return Array.from(new Set(payload))
}
export async function registryGetTheme(name: string, config: Config) {
const baseColor = await getRegistryBaseColor(name)
if (!baseColor) {
return null
}
// TODO: Move this to the registry i.e registry:theme.
const theme = {
name,
type: "registry:theme",
tailwind: {
config: {
theme: {
extend: {
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
colors: {},
},
},
},
},
cssVars: {
light: {
radius: "0.5rem",
},
dark: {},
},
} satisfies z.infer<typeof registryItemSchema>
if (config.tailwind.cssVariables) {
theme.tailwind.config.theme.extend.colors = {
...theme.tailwind.config.theme.extend.colors,
...buildTailwindThemeColorsFromCssVars(baseColor.cssVars.dark),
}
theme.cssVars = {
light: {
...baseColor.cssVars.light,
...theme.cssVars.light,
},
dark: {
...baseColor.cssVars.dark,
...theme.cssVars.dark,
},
}
}
return theme
}
function getRegistryUrl(path: string) {
if (isUrl(path)) {
// If the url contains /chat/b/, we assume it's the v0 registry.
// We need to add the /json suffix if it's missing.
const url = new URL(path)
if (url.pathname.match(/\/chat\/b\//) && !url.pathname.endsWith("/json")) {
url.pathname = `${url.pathname}/json`
}
return url.toString()
}
return `${REGISTRY_URL}/${path}`
}
function isUrl(path: string) {
try {
new URL(path)
return true
} catch (error) {
return false
}
}
| shadcn-ui/ui/packages/shadcn/src/utils/registry/index.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/src/utils/registry/index.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 4553
} | 85 |
import { promises as fs } from "fs"
import path from "path"
import { Config } from "@/src/utils/get-config"
import { highlighter } from "@/src/utils/highlighter"
import { spinner } from "@/src/utils/spinner"
import {
_createSourceFile,
_getQuoteChar,
} from "@/src/utils/updaters/update-tailwind-config"
import { ObjectLiteralExpression, SyntaxKind } from "ts-morph"
export async function updateTailwindContent(
content: string[],
config: Config,
options: {
silent?: boolean
}
) {
if (!content) {
return
}
options = {
silent: false,
...options,
}
const tailwindFileRelativePath = path.relative(
config.resolvedPaths.cwd,
config.resolvedPaths.tailwindConfig
)
const tailwindSpinner = spinner(
`Updating ${highlighter.info(tailwindFileRelativePath)}`,
{
silent: options.silent,
}
).start()
const raw = await fs.readFile(config.resolvedPaths.tailwindConfig, "utf8")
const output = await transformTailwindContent(raw, content, config)
await fs.writeFile(config.resolvedPaths.tailwindConfig, output, "utf8")
tailwindSpinner?.succeed()
}
export async function transformTailwindContent(
input: string,
content: string[],
config: Config
) {
const sourceFile = await _createSourceFile(input, config)
// Find the object with content property.
// This is faster than traversing the default export.
// TODO: maybe we do need to traverse the default export?
const configObject = sourceFile
.getDescendantsOfKind(SyntaxKind.ObjectLiteralExpression)
.find((node) =>
node
.getProperties()
.some(
(property) =>
property.isKind(SyntaxKind.PropertyAssignment) &&
property.getName() === "content"
)
)
// We couldn't find the config object, so we return the input as is.
if (!configObject) {
return input
}
addTailwindConfigContent(configObject, content)
return sourceFile.getFullText()
}
async function addTailwindConfigContent(
configObject: ObjectLiteralExpression,
content: string[]
) {
const quoteChar = _getQuoteChar(configObject)
const existingProperty = configObject.getProperty("content")
if (!existingProperty) {
const newProperty = {
name: "content",
initializer: `[${quoteChar}${content.join(
`${quoteChar}, ${quoteChar}`
)}${quoteChar}]`,
}
configObject.addPropertyAssignment(newProperty)
return configObject
}
if (existingProperty.isKind(SyntaxKind.PropertyAssignment)) {
const initializer = existingProperty.getInitializer()
// If property is an array, append.
if (initializer?.isKind(SyntaxKind.ArrayLiteralExpression)) {
for (const contentItem of content) {
const newValue = `${quoteChar}${contentItem}${quoteChar}`
// Check if the array already contains the value.
if (
initializer
.getElements()
.map((element) => element.getText())
.includes(newValue)
) {
continue
}
initializer.addElement(newValue)
}
}
return configObject
}
return configObject
}
| shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-tailwind-content.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/src/utils/updaters/update-tailwind-content.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 1145
} | 86 |
/**
* By default, Remix will handle generating the HTTP Response for you.
* You are free to delete this file if you'd like to, but if you ever want it revealed again, you can run `npx remix reveal`
* For more information, see https://remix.run/docs/en/main/file-conventions/entry.server
*/
import { PassThrough } from "node:stream";
import type { EntryContext } from "@remix-run/node";
import { createReadableStreamFromReadable } from "@remix-run/node";
import { RemixServer } from "@remix-run/react";
import { isbot } from "isbot";
import { renderToPipeableStream } from "react-dom/server";
const ABORT_DELAY = 5_000;
export default function handleRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return isbot(request.headers.get("user-agent"))
? handleBotRequest(
request,
responseStatusCode,
responseHeaders,
remixContext,
)
: handleBrowserRequest(
request,
responseStatusCode,
responseHeaders,
remixContext,
);
}
function handleBotRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
const { abort, pipe } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onAllReady() {
const body = new PassThrough();
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(createReadableStreamFromReadable(body), {
headers: responseHeaders,
status: responseStatusCode,
}),
);
pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
responseStatusCode = 500;
console.error(error);
},
},
);
setTimeout(abort, ABORT_DELAY);
});
}
function handleBrowserRequest(
request: Request,
responseStatusCode: number,
responseHeaders: Headers,
remixContext: EntryContext,
) {
return new Promise((resolve, reject) => {
const { abort, pipe } = renderToPipeableStream(
<RemixServer
context={remixContext}
url={request.url}
abortDelay={ABORT_DELAY}
/>,
{
onShellReady() {
const body = new PassThrough();
responseHeaders.set("Content-Type", "text/html");
resolve(
new Response(createReadableStreamFromReadable(body), {
headers: responseHeaders,
status: responseStatusCode,
}),
);
pipe(body);
},
onShellError(error: unknown) {
reject(error);
},
onError(error: unknown) {
console.error(error);
responseStatusCode = 500;
},
},
);
setTimeout(abort, ABORT_DELAY);
});
}
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/entry.server.tsx | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/entry.server.tsx",
"repo_id": "shadcn-ui/ui",
"token_count": 1283
} | 87 |
import { validateEmail } from "./utils";
test("validateEmail returns false for non-emails", () => {
expect(validateEmail(undefined)).toBe(false);
expect(validateEmail(null)).toBe(false);
expect(validateEmail("")).toBe(false);
expect(validateEmail("not-an-email")).toBe(false);
expect(validateEmail("n@")).toBe(false);
});
test("validateEmail returns true for emails", () => {
expect(validateEmail("[email protected]")).toBe(true);
});
| shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/utils.test.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/fixtures/frameworks/remix-indie-stack/app/utils.test.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 152
} | 88 |
import { Project, SyntaxKind } from "ts-morph"
import { beforeEach, describe, expect, test } from "vitest"
import {
buildTailwindThemeColorsFromCssVars,
nestSpreadProperties,
transformTailwindConfig,
unnestSpreadProperties,
} from "../../../src/utils/updaters/update-tailwind-config"
const SHARED_CONFIG = {
$schema: "https://ui.shadcn.com/schema.json",
style: "new-york",
rsc: true,
tsx: true,
tailwind: {
config: "tailwind.config.ts",
css: "app/globals.css",
baseColor: "slate",
cssVariables: true,
},
aliases: {
components: "@/components",
utils: "@/lib/utils",
},
resolvedPaths: {
cwd: ".",
tailwindConfig: "tailwind.config.ts",
tailwindCss: "app/globals.css",
components: "./components",
utils: "./lib/utils",
ui: "./components/ui",
},
}
describe("transformTailwindConfig -> darkMode property", () => {
test("should add darkMode property if not in config", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
}
export default config
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
expect(
await transformTailwindConfig(
`/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
}
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
expect(
await transformTailwindConfig(
`/** @type {import('tailwindcss').Config} */
const foo = {
bar: 'baz',
}
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {},
},
plugins: [],
}
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should append class to darkMode property if existing array", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: ["selector"],
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
}
export default config
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should preserve quote kind", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: ['selector', '[data-mode="dark"]'],
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
}
export default config
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should convert string to array and add class if darkMode is string", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: "selector",
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
}
export default config
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should work with multiple darkMode selectors", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: ['variant', [
'@media (prefers-color-scheme: dark) { &:not(.light *) }',
'&:is(.dark *)',
]],
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
}
export default config
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should not add darkMode property if already in config", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: ['class'],
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
}
export default config
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
darkMode: ['class', 'selector'],
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [],
}
export default config
`,
{
properties: [
{
name: "darkMode",
value: "class",
},
],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
})
describe("transformTailwindConfig -> plugin", () => {
test("should add plugin if not in config", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
}
export default config
`,
{
plugins: ['require("tailwindcss-animate")'],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should append plugin to existing array", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [require("@tailwindcss/typography")],
}
export default config
`,
{
plugins: ['require("tailwindcss-animate")'],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should not add plugin if already in config", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
backgroundImage: {
"gradient-radial": "radial-gradient(var(--tw-gradient-stops))",
"gradient-conic":
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
},
},
},
plugins: [require("@tailwindcss/typography"), require("tailwindcss-animate")],
}
export default config
`,
{
plugins: ["require('tailwindcss-animate')"],
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
})
describe("transformTailwindConfig -> theme", () => {
test("should add theme if not in config", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
}
export default config
`,
{
theme: {
extend: {
colors: {
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
},
},
},
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should merge existing theme", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
colors: {
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
},
},
},
}
export default config
`,
{
theme: {
extend: {
colors: {
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
},
},
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should keep spread assignments", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
colors: {
...defaultColors,
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
},
},
},
}
export default config
`,
{
theme: {
extend: {
colors: {
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
},
},
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should handle multiple properties", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
fontFamily: {
sans: ["var(--font-geist-sans)", ...fontFamily.sans],
mono: ["var(--font-mono)", ...fontFamily.mono],
},
colors: {
...defaultColors,
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
},
boxShadow: {
...defaultBoxShadow,
"3xl": "0 35px 60px -15px rgba(0, 0, 0, 0.3)",
},
borderRadius: {
"3xl": "2rem",
},
animation: {
...defaultAnimation,
"spin-slow": "spin 3s linear infinite",
},
},
},
}
export default config
`,
{
theme: {
extend: {
fontFamily: {
heading: ["var(--font-geist-sans)"],
},
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
},
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
test("should not make any updates running on already updated config", async () => {
const input = `import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
fontFamily: {
sans: ["var(--font-geist-sans)", ...fontFamily.sans],
mono: ["var(--font-mono)", ...fontFamily.mono],
},
colors: {
...defaultColors,
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
},
boxShadow: {
...defaultBoxShadow,
"3xl": "0 35px 60px -15px rgba(0, 0, 0, 0.3)",
},
borderRadius: {
"3xl": "2rem",
},
animation: {
...defaultAnimation,
"spin-slow": "spin 3s linear infinite",
},
},
},
}
export default config
`
const tailwindConfig = {
theme: {
extend: {
fontFamily: {
heading: ["var(--font-geist-sans)"],
},
colors: {
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
borderRadius: {
lg: "var(--radius)",
md: "calc(var(--radius) - 2px)",
sm: "calc(var(--radius) - 4px)",
},
animation: {
"accordion-down": "accordion-down 0.2s ease-out",
"accordion-up": "accordion-up 0.2s ease-out",
},
},
},
}
const output1 = await transformTailwindConfig(input, tailwindConfig, {
config: SHARED_CONFIG,
})
const output2 = await transformTailwindConfig(output1, tailwindConfig, {
config: SHARED_CONFIG,
})
const output3 = await transformTailwindConfig(output2, tailwindConfig, {
config: SHARED_CONFIG,
})
expect(output3).toBe(output1)
expect(output3).toBe(output2)
})
test("should keep quotes in strings", async () => {
expect(
await transformTailwindConfig(
`import type { Config } from 'tailwindcss'
const config: Config = {
content: [
"./pages/**/*.{js,ts,jsx,tsx,mdx}",
"./components/**/*.{js,ts,jsx,tsx,mdx}",
"./app/**/*.{js,ts,jsx,tsx,mdx}",
],
theme: {
extend: {
fontFamily: {
sans: ['Figtree', ...defaultTheme.fontFamily.sans],
},
colors: {
...defaultColors,
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
},
},
},
}
export default config
`,
{
theme: {
extend: {
colors: {
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
},
},
},
},
{
config: SHARED_CONFIG,
}
)
).toMatchSnapshot()
})
})
describe("nestSpreadProperties", () => {
let project: Project
beforeEach(() => {
project = new Project({ useInMemoryFileSystem: true })
})
function testTransformation(input: string, expected: string) {
const sourceFile = project.createSourceFile(
"test.ts",
`const config = ${input};`
)
const configObject = sourceFile.getFirstDescendantByKind(
SyntaxKind.ObjectLiteralExpression
)
if (!configObject) throw new Error("Config object not found")
nestSpreadProperties(configObject)
const result = configObject.getText()
expect(result.replace(/\s+/g, "")).toBe(expected.replace(/\s+/g, ""))
}
test("should nest spread properties", () => {
testTransformation(
`{ theme: { ...foo, bar: { ...baz, one: "two" }, other: { a: "b", ...c } } }`,
`{ theme: { ___foo: "...foo", bar: { ___baz: "...baz", one: "two" }, other: { a: "b", ___c: "...c" } } }`
)
})
test("should handle mixed property assignments", () => {
testTransformation(
`{ ...foo, a: 1, b() {}, ...bar, c: { ...baz } }`,
`{ ___foo: "...foo", a: 1, b() {}, ___bar: "...bar", c: { ___baz: "...baz" } }`
)
})
test("should handle objects with only spread properties", () => {
testTransformation(
`{ ...foo, ...bar, ...baz }`,
`{ ___foo: "...foo", ___bar: "...bar", ___baz: "...baz" }`
)
})
test("should handle property name conflicts", () => {
testTransformation(`{ foo: 1, ...foo }`, `{ foo: 1, ___foo: "...foo" }`)
})
test("should handle shorthand property names", () => {
testTransformation(`{ a, ...foo, b }`, `{ a, ___foo: "...foo", b }`)
})
test("should handle computed property names", () => {
testTransformation(
`{ ["computed"]: 1, ...foo }`,
`{ ["computed"]: 1, ___foo: "...foo" }`
)
})
})
describe("unnestSpreadProperties", () => {
let project: Project
beforeEach(() => {
project = new Project({ useInMemoryFileSystem: true })
})
function testTransformation(input: string, expected: string) {
const sourceFile = project.createSourceFile(
"test.ts",
`const config = ${input};`
)
const configObject = sourceFile.getFirstDescendantByKind(
SyntaxKind.ObjectLiteralExpression
)
if (!configObject) throw new Error("Config object not found")
unnestSpreadProperties(configObject)
const result = configObject.getText()
expect(result.replace(/\s+/g, "")).toBe(expected.replace(/\s+/g, ""))
}
test("should nest spread properties", () => {
testTransformation(
`{ theme: { ___foo: "...foo", bar: { ___baz: "...baz", one: "two" }, other: { a: "b", ___c: "...c" } } }`,
`{ theme: { ...foo, bar: { ...baz, one: "two" }, other: { a: "b", ...c } } }`
)
})
test("should handle mixed property assignments", () => {
testTransformation(
`{ ___foo: "...foo", a: 1, b() {}, ___bar: "...bar", c: { ___baz: "...baz" } }`,
`{ ...foo, a: 1, b() {}, ...bar, c: { ...baz } }`
)
})
test("should handle objects with only spread properties", () => {
testTransformation(
`{ ___foo: "...foo", ___bar: "...bar", ___baz: "...baz" }`,
`{ ...foo, ...bar, ...baz }`
)
})
test("should handle property name conflicts", () => {
testTransformation(`{ foo: 1, ___foo: "...foo" }`, `{ foo: 1, ...foo }`)
})
test("should handle shorthand property names", () => {
testTransformation(`{ a, ___foo: "...foo", b }`, `{ a, ...foo, b }`)
})
test("should handle computed property names", () => {
testTransformation(
`{ ["computed"]: 1, ___foo: "...foo" }`,
`{ ["computed"]: 1, ...foo }`
)
})
})
describe("buildTailwindThemeColorsFromCssVars", () => {
test("should inline color names", () => {
expect(
buildTailwindThemeColorsFromCssVars({
primary: "blue",
"primary-light": "skyblue",
"primary-dark": "navy",
secondary: "green",
accent: "orange",
"accent-hover": "darkorange",
"accent-active": "orangered",
})
).toEqual({
primary: {
DEFAULT: "hsl(var(--primary))",
light: "hsl(var(--primary-light))",
dark: "hsl(var(--primary-dark))",
},
secondary: "hsl(var(--secondary))",
accent: {
DEFAULT: "hsl(var(--accent))",
hover: "hsl(var(--accent-hover))",
active: "hsl(var(--accent-active))",
},
})
})
test("should not add a DEFAULT if not present", () => {
expect(
buildTailwindThemeColorsFromCssVars({
"primary-light": "skyblue",
"primary-dark": "navy",
secondary: "green",
accent: "orange",
"accent-hover": "darkorange",
"accent-active": "orangered",
})
).toEqual({
primary: {
light: "hsl(var(--primary-light))",
dark: "hsl(var(--primary-dark))",
},
secondary: "hsl(var(--secondary))",
accent: {
DEFAULT: "hsl(var(--accent))",
hover: "hsl(var(--accent-hover))",
active: "hsl(var(--accent-active))",
},
})
})
test("should build tailwind theme colors from css vars", () => {
expect(
buildTailwindThemeColorsFromCssVars({
background: "0 0% 100%",
foreground: "224 71.4% 4.1%",
card: "0 0% 100%",
"card-foreground": "224 71.4% 4.1%",
popover: "0 0% 100%",
"popover-foreground": "224 71.4% 4.1%",
primary: "220.9 39.3% 11%",
"primary-foreground": "210 20% 98%",
secondary: "220 14.3% 95.9%",
"secondary-foreground": "220.9 39.3% 11%",
muted: "220 14.3% 95.9%",
"muted-foreground": "220 8.9% 46.1%",
accent: "220 14.3% 95.9%",
"accent-foreground": "220.9 39.3% 11%",
destructive: "0 84.2% 60.2%",
"destructive-foreground": "210 20% 98%",
border: "220 13% 91%",
input: "220 13% 91%",
ring: "224 71.4% 4.1%",
})
).toEqual({
border: "hsl(var(--border))",
input: "hsl(var(--input))",
ring: "hsl(var(--ring))",
background: "hsl(var(--background))",
foreground: "hsl(var(--foreground))",
primary: {
DEFAULT: "hsl(var(--primary))",
foreground: "hsl(var(--primary-foreground))",
},
secondary: {
DEFAULT: "hsl(var(--secondary))",
foreground: "hsl(var(--secondary-foreground))",
},
destructive: {
DEFAULT: "hsl(var(--destructive))",
foreground: "hsl(var(--destructive-foreground))",
},
muted: {
DEFAULT: "hsl(var(--muted))",
foreground: "hsl(var(--muted-foreground))",
},
accent: {
DEFAULT: "hsl(var(--accent))",
foreground: "hsl(var(--accent-foreground))",
},
popover: {
DEFAULT: "hsl(var(--popover))",
foreground: "hsl(var(--popover-foreground))",
},
card: {
DEFAULT: "hsl(var(--card))",
foreground: "hsl(var(--card-foreground))",
},
})
})
})
| shadcn-ui/ui/packages/shadcn/test/utils/updaters/update-tailwind-config.test.ts | {
"file_path": "shadcn-ui/ui/packages/shadcn/test/utils/updaters/update-tailwind-config.test.ts",
"repo_id": "shadcn-ui/ui",
"token_count": 13043
} | 89 |
"use client"
import React, { useEffect, useState } from "react"
import { AnimatePresence, motion } from "framer-motion"
const AdBanner = () => {
const [isVisible, setIsVisible] = useState(true)
useEffect(() => {
const timer = setTimeout(() => {
setIsVisible(false)
}, 10000) // Close after 10 seconds
return () => clearTimeout(timer)
}, [])
const handleClose = () => {
setIsVisible(false)
}
return (
<AnimatePresence>
{isVisible && (
<motion.div
className="fixed bottom-0 left-0 right-0 sm:bottom-4 sm:right-4 sm:left-auto w-full sm:w-72 md:w-80 border-t sm:border sm:rounded-lg shadow-lg bg-white overflow-hidden"
initial={{ y: 100, opacity: 0 }}
animate={{ y: 0, opacity: 1 }}
exit={{ y: 100, opacity: 0 }}
transition={{ type: "spring", stiffness: 260, damping: 20 }}
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
>
<motion.div
className="absolute top-0 left-0 w-full h-1 bg-gradient-to-r from-purple-500 to-purple-700"
initial={{ scaleX: 0 }}
animate={{ scaleX: 1 }}
transition={{ duration: 2, repeat: Infinity }}
/>
<div className="p-4">
<div className="sm:block hidden">
<h2 className="text-lg font-bold mb-2 text-gray-800">
Need Custom Development?
</h2>
<p className="text-sm mb-2 text-gray-600">
We've got you covered!
</p>
<ul className="list-disc pl-4 space-y-1 text-sm text-gray-600">
<li>Custom landing pages</li>
<li>Full-stack web applications</li>
<li>Complete software solutions</li>
<li>24/7 expert support</li>
</ul>
</div>
<div className="sm:hidden flex items-center justify-between">
<div className="flex-1 mr-4">
<h2 className="text-base font-bold text-gray-800 leading-tight">
Need Custom Development?
</h2>
<p className="text-xs text-gray-600 mt-1">
We've got you covered!
</p>
</div>
<motion.button
className="flex-shrink-0 px-3 py-2 text-xs bg-black hover:bg-gray-700 text-white rounded whitespace-nowrap"
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
onClick={() => window.open("https://mvp.easyui.pro/", "_blank")}
>
Get Started
</motion.button>
</div>
<motion.button
className="w-full mt-4 py-2 text-sm bg-black hover:bg-gray-800 text-white rounded sm:block hidden"
whileHover={{ scale: 1.05 }}
whileTap={{ scale: 0.95 }}
onClick={() => window.open("https://mvp.easyui.pro/", "_blank")}
>
Get Started Now
</motion.button>
<p className="text-center mt-2 text-xs text-gray-500 sm:block hidden">
Simple pricing, no hidden fees
</p>
</div>
<motion.button
className="absolute top-2 right-2 text-gray-500 hover:text-gray-700"
whileHover={{ scale: 1.1 }}
whileTap={{ scale: 0.9 }}
onClick={handleClose}
>
</motion.button>
</motion.div>
)}
</AnimatePresence>
)
}
export default AdBanner | DarkInventor/easy-ui/components/ad-banner.tsx | {
"file_path": "DarkInventor/easy-ui/components/ad-banner.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 1850
} | 0 |
"use client";
import { AnimatePresence, motion } from "framer-motion";
import React, { useState } from "react";
import { useTheme } from 'next-themes';
interface AnimatedSubscribeButtonProps {
buttonTextColor?: string;
subscribeStatus: boolean;
initialText: React.ReactElement | string;
changeText: React.ReactElement | string;
}
export const AnimatedSubscribeButton: React.FC<
AnimatedSubscribeButtonProps
> = ({
subscribeStatus,
buttonTextColor,
changeText,
initialText,
}) => {
const [isSubscribed, setIsSubscribed] = useState<boolean>(subscribeStatus);
const { theme, systemTheme, resolvedTheme } = useTheme();
// Adjust button color based on the effective theme, defaulting to white for dark themes or unspecified themes, and black for light themes
const effectiveTheme = resolvedTheme || (theme === 'system' ? systemTheme : theme);
const buttonColor = effectiveTheme === "light" ? "#000000" : "#ffffff"; // Button color changes based on theme
const textColor = effectiveTheme === "light" ? "#ffffff" : "#000000"; // Text color is inverted based on theme for contrast
return (
<AnimatePresence mode="wait">
{isSubscribed ? (
<motion.button
className="relative flex w-[150px] cursor-pointer items-center justify-center rounded-md border-none p-[5px]"
onClick={() => setIsSubscribed(false)}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
style={{ backgroundColor: buttonColor, color: textColor, borderColor: textColor }}
>
<motion.span
key="action"
className="relative block h-full w-full font-semibold"
initial={{ y: -50 }}
animate={{ y: 0 }}
>
{changeText}
</motion.span>
</motion.button>
) : (
<motion.button
className="relative flex w-[150px] cursor-pointer items-center justify-center rounded-md border-none p-[5px]"
style={{ backgroundColor: buttonColor, color: textColor }}
onClick={() => setIsSubscribed(true)}
initial={{ opacity: 0 }}
animate={{ opacity: 1 }}
exit={{ opacity: 0 }}
>
<motion.span
key="reaction"
className="relative block font-semibold"
initial={{ x: 0 }}
exit={{ x: 50, transition: { duration: 0.1 } }}
>
{initialText}
</motion.span>
</motion.button>
)}
</AnimatePresence>
);
};
| DarkInventor/easy-ui/components/magicui/animated-subscribe-button.tsx | {
"file_path": "DarkInventor/easy-ui/components/magicui/animated-subscribe-button.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 985
} | 1 |
// "use client"
// import Link from "next/link"
// import { CheckIcon, ChevronRight, ChevronRightIcon } from "lucide-react"
// import { siteConfig } from "@/config/site"
// import { Button, buttonVariants } from "@/components/ui/button"
// import { Icons } from "@/components/icons"
// import { MainNav } from "@/components/main-nav"
// import { ThemeToggle } from "@/components/theme-toggle"
// import { AnimatedSubscribeButton } from "./magicui/animated-subscribe-button"
// import { cn } from "@/lib/utils"
// export function SiteHeader() {
// return (
// <header className="sticky top-0 z-50 w-full bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 p-1">
// <div className="container flex h-14 max-w-screen-2xl items-center">
// <MainNav />
// <div className="flex flex-1 items-center justify-end space-x-4">
// <nav className="flex items-center space-x-2">
// <div className="sm:block hidden lg:block">
// <Button
// variant="ghost"
// size="icon"
// onClick={() =>
// window.open(
// "https://discord.gg/7yTP7KGK",
// "_blank"
// )
// }
// >
// <Icons.discord
// width="23"
// height={23}
// className="text-gray-500 dark:text-gray-600"
// />
// </Button>
// <Button
// variant="ghost"
// size="icon"
// onClick={() =>
// window.open(
// "https://github.com/DarkInventor/easy-ui",
// "_blank"
// )
// }
// >
// <Icons.github
// width="20"
// className="text-gray-500 dark:text-gray-600"
// />
// </Button>
// <Button
// variant="ghost"
// size="icon"
// onClick={() =>
// window.open(
// "https://x.com/kathanmehtaa",
// "_blank"
// )
// }
// >
// <Icons.twitter width="20" className="text-gray-500 dark:text-gray-600" />
// </Button>
// <ThemeToggle />
// </div>
// <a
// href="https://premium.easyui.pro/"
// target="_blank"
// rel="noopener noreferrer"
// className={cn(
// buttonVariants({
// variant: "default",
// size: "sm",
// }),
// "gap-2 whitespace-pre md:flex",
// "group relative text-sm font-semibold ring-offset-inherit transition-all duration-150 ease-in-out hover:ring-2 hover:ring-black hover:ring-offset-2 hover:ring-offset-current dark:hover:ring-neutral-50"
// )}
// >
// Get Easy UI Premium
// <ChevronRight className="ml-1 size-4 shrink-0 transition-all duration-300 ease-out group-hover:translate-x-1" />
// </a>
// {/* } */}
// {/* changeText={
// <a className="group inline-flex items-center" href="/login">
// Login{" "}
// <ChevronRightIcon className="ml-1 h-4 w-4 transition-transform duration-300 group-hover:translate-x-1" />
// </a>
// }
// /> */}
// </nav>
// </div>
// </div>
// </header>
// )
// }
"use client"
import React, { useState } from "react"
import Link from "next/link"
import {
CheckIcon,
ChevronRight,
ChevronRightIcon,
Menu,
X,
} from "lucide-react"
import { siteConfig } from "@/config/site"
import { cn } from "@/lib/utils"
import { Button, buttonVariants } from "@/components/ui/button"
import { Icons } from "@/components/icons"
import { MainNav } from "@/components/main-nav"
import { ThemeToggle } from "@/components/theme-toggle"
import { AnimatedSubscribeButton } from "./magicui/animated-subscribe-button"
import { Badge } from "./ui/badge"
export function SiteHeader() {
const [isMenuOpen, setIsMenuOpen] = useState(false)
const toggleMenu = () => {
setIsMenuOpen(!isMenuOpen)
}
return (
<header className="sticky top-0 z-50 w-full bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 p-1">
<div className="container flex h-14 max-w-screen-2xl items-center">
{/* Hamburger menu for small and medium screens */}
<button className="lg:hidden mr-4 " onClick={toggleMenu}>
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" className="lucide lucide-panel-left-open h-6 w-6"><rect width="18" height="18" x="3" y="3" rx="2"></rect><path d="M9 3v18"></path><path d="m14 9 3 3-3 3"></path></svg>
</button>
{/* Logo for large screens */}
{/* <Link href="/" className="hidden lg:flex items-center space-x-2">
<Icons.logo />
<span className="font-bold">{siteConfig.name}</span>
</Link> */}
{/* Main navigation for large screens */}
<div className="hidden lg:block ">
<MainNav />
</div>
{/* Right-side content */}
<div className="flex flex-1 items-center justify-end space-x-4">
<nav className="flex items-center space-x-2">
<div className="hidden lg:flex items-center space-x-2">
<Button
variant="ghost"
size="icon"
onClick={() =>
window.open("https://discord.gg/7yTP7KGK", "_blank")
}
>
<Icons.discord
width="23"
height={23}
className="text-gray-500 dark:text-gray-600"
/>
</Button>
<Button
variant="ghost"
size="icon"
onClick={() =>
window.open(
"https://github.com/DarkInventor/easy-ui",
"_blank"
)
}
>
<Icons.github
width="20"
className="text-gray-500 dark:text-gray-600"
/>
</Button>
<Button
variant="ghost"
size="icon"
onClick={() =>
window.open("https://x.com/kathanmehtaa", "_blank")
}
>
<Icons.twitter
width="20"
className="text-gray-500 dark:text-gray-600"
/>
</Button>
<ThemeToggle />
</div>
<a
href="https://premium.easyui.pro/"
target="_blank"
rel="noopener noreferrer"
className={cn(
buttonVariants({
variant: "default",
size: "sm",
}),
"gap-2 whitespace-pre md:flex",
"group relative text-sm font-semibold ring-offset-inherit transition-all duration-150 ease-in-out hover:ring-2 hover:ring-black hover:ring-offset-2 hover:ring-offset-current dark:hover:ring-neutral-50"
)}
>
Get Easy UI Premium
<ChevronRight className="ml-1 size-4 shrink-0 transition-all duration-300 ease-out group-hover:translate-x-1" />
</a>
</nav>
</div>
</div>
{/* Side menu for small and medium screens */}
<div
className={`fixed inset-y-0 left-0 z-50 w-64 bg-white text-black dark:bg-black dark:text-white transform z-50 ${
isMenuOpen ? "translate-x-0" : "-translate-x-full"
} transition-transform duration-300 ease-in-out lg:hidden`}
>
<div className="flex flex-col h-full p-0 py-6 z-60">
<div className="flex items-center justify-between mb-0 m-2 z-60">
<Link href="/" className="mr-6 flex items-center space-x-2">
<img
src="https://pub-0cd6f9d4131f4f79ac40219248ae64db.r2.dev/logo.svg"
className="size-7"
alt="Logo"
/>
<span className="font-bold sm:inline-block">
{siteConfig.name}
</span>
<Badge className="hidden sm:inline-block" variant="secondary">
Beta
</Badge>
</Link>
<button onClick={toggleMenu}>
<X className="h-6 w-6" />
</button>
</div>
<nav className="flex flex-col space-y-4 bg-white text-black dark:bg-black dark:text-white ml-0 py-10 pl-4 z-60">
<Link href="/" className="text-foreground hover:text-foreground/80 text-sm">
Home
</Link>
<Link
href="/templates"
className="text-foreground hover:text-foreground/80 text-sm"
>
Templates
</Link>
<Link
href="/component"
className="text-foreground hover:text-foreground/80 text-sm"
>
Components
</Link>
<Link href="https://premium.easyui.pro/" target="_blank" className="text-foreground hover:text-foreground/80 text-sm inline-flex items-center">Premium Templates<Icons.externalLink className="ml-2 size-4" /></Link>
<Link href="https://mvp.easyui.pro/" target="_blank" className="text-foreground hover:text-foreground/80 text-sm inline-flex items-center">Easy MVP<Icons.externalLink className="ml-2 size-4" /></Link>
<p className="mt-auto flex flex-col space-y-4 leading-7 tracking-tight text-xs text-muted-foreground dark:text-gray-400 bg-white font-semibold dark:bg-black z-60"> Socials</p>
<Button
variant="ghost"
onClick={() =>
window.open("https://discord.gg/7yTP7KGK", "_blank")
}
className="flex items-start justify-start !px-0 !h-4 "
>
<Icons.discord className="mr-2 h-4 w-4" />
Discord
</Button>
<Button
variant="ghost"
onClick={() =>
window.open("https://github.com/DarkInventor/easy-ui", "_blank")
}
className="flex items-start justify-start !px-0 !h-4 "
>
<Icons.github className="mr-2 h-4 w-4" />
GitHub
</Button>
<Button
variant="ghost"
onClick={() =>
window.open("https://x.com/kathanmehtaa", "_blank")
}
className="flex items-start justify-start !px-0 !h-4 border-b pb-20"
>
<Icons.twitter className="mr-2 h-4 w-4" />
Twitter
</Button>
<div className="flex justify-center mt-10 rounded-lg border-gray-200 dark:border-gray-700 pb-4">
<ThemeToggle />
</div>
{/* </div> */}
</nav>
</div>
</div>
</header>
)
}
| DarkInventor/easy-ui/components/site-header.tsx | {
"file_path": "DarkInventor/easy-ui/components/site-header.tsx",
"repo_id": "DarkInventor/easy-ui",
"token_count": 6194
} | 2 |
"use client";
import type { ReactNode } from "react";
import { ThemeProvider } from "@/components/theme-provider";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
interface ProvidersProps {
children: ReactNode;
}
export default function Providers({ children }: ProvidersProps) {
const queryClient = new QueryClient();
return (
<QueryClientProvider client={queryClient}>
<ThemeProvider
attribute="class"
defaultTheme="system"
enableSystem
disableTransitionOnChange
>
{children}
</ThemeProvider>
</QueryClientProvider>
);
}
| alifarooq9/rapidlaunch/apps/www/src/components/providers.tsx | {
"file_path": "alifarooq9/rapidlaunch/apps/www/src/components/providers.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 288
} | 3 |
"use client";
import { SubscribeBtn } from "@/app/(app)/(user)/org/billing/_components/subscribe-btn";
import {
AlertDialog,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
import { useState } from "react";
type SwitchPlanModalProps = {
variantId: number | undefined;
lastCardDigits: string;
cardBrand: string;
currencySymbol: string;
price: number;
currencyCode: string;
planName: string;
status: string;
};
export function SwitchPlanModal({
cardBrand,
currencyCode,
currencySymbol,
lastCardDigits,
planName,
price,
variantId,
status
}: SwitchPlanModalProps) {
const [isOpen, setIsOpen] = useState<boolean>(false);
return (
<AlertDialog open={isOpen} onOpenChange={(o) => setIsOpen(o)}>
<AlertDialogTrigger asChild>
{status === "active" ? (
<Button variant="outline" className="w-full">
Switch to {currencySymbol}
{price} {currencyCode} per month
</Button>
) : (
<Button variant="outline" className="w-full">
Subscribe to {currencySymbol}
{price} {currencyCode} per month
</Button>
)}
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>
Are you sure you want to {status === "active" ? "switch" : "subscribe"} to{" "} {planName} plan?
</AlertDialogTitle>
<AlertDialogDescription>
{status === "active" ? (
<p>
You are currently subscribed to a different plan. By switching to the <strong>{planName} plan</strong>, your {cardBrand} card ending in {lastCardDigits} will be charged <strong>{price} {currencyCode}</strong> upon confirmation.
</p>
) : (
<p>
By subscribing to the <strong>{planName} plan</strong>, you will be charged <strong>{price} {currencyCode}</strong> upon confirmation. This will be a recurring charge until you cancel your subscription.
</p>
)}
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<SubscribeBtn variantId={variantId}>{status === "active" ? "Switch" : "Subscribe"}</SubscribeBtn>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/switch-plan-modal.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/billing/_components/switch-plan-modal.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 1461
} | 4 |
import { AppPageShell } from "@/app/(app)/_components/page-shell";
import { orgMembersPageConfig } from "@/app/(app)/(user)/org/members/_constants/page-config";
import { getPaginatedOrgMembersQuery } from "@/server/actions/organization/queries";
import type { SearchParams } from "@/types/data-table";
import { z } from "zod";
import { MembersTable } from "./_components/members-table";
type UsersPageProps = {
searchParams: SearchParams;
};
const searchParamsSchema = z.object({
page: z.coerce.number().default(1),
per_page: z.coerce.number().default(10),
sort: z.string().optional(),
email: z.string().optional(),
status: z.string().optional(),
role: z.string().optional(),
operator: z.string().optional(),
});
export default async function OrgMembersPage({ searchParams }: UsersPageProps) {
const search = searchParamsSchema.parse(searchParams);
const membersPromise = getPaginatedOrgMembersQuery(search);
return (
<AppPageShell
title={orgMembersPageConfig.title}
description={orgMembersPageConfig.description}
>
<div className="w-full space-y-5">
<MembersTable membersPromise={membersPromise} />
</div>
</AppPageShell>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/page.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/(user)/org/members/page.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 473
} | 5 |
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
} from "@/components/ui/dialog";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Icons } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { useAwaitableTransition } from "@/hooks/use-awaitable-transition";
import { createOrgMutation } from "@/server/actions/organization/mutations";
import { zodResolver } from "@hookform/resolvers/zod";
import { useMutation } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
import type { Dispatch, SetStateAction } from "react";
import { useForm } from "react-hook-form";
import { toast } from "sonner";
import { z } from "zod";
const createOrgFormSchema = z.object({
name: z
.string()
.trim()
.min(3, "Name must be at least 3 characters long")
.max(50, "Name must be at most 50 characters long"),
email: z.string().email("Invalid email address"),
});
export type CreateOrgFormSchema = z.infer<typeof createOrgFormSchema>;
type CreateOrgFormProps = {
open: boolean;
setOpen: Dispatch<SetStateAction<boolean>>;
};
export function CreateOrgForm({ open, setOpen }: CreateOrgFormProps) {
const router = useRouter();
const form = useForm<CreateOrgFormSchema>({
resolver: zodResolver(createOrgFormSchema),
defaultValues: {
name: "",
email: "",
},
});
const { mutateAsync, isPending: isMutatePending } = useMutation({
mutationFn: ({ name, email }: { name: string; email: string }) =>
createOrgMutation({ name, email }),
});
const [isPending, startAwaitableTransition] = useAwaitableTransition();
const onSubmit = async (values: CreateOrgFormSchema) => {
try {
await mutateAsync(values);
await startAwaitableTransition(() => {
router.refresh();
});
setOpen(false);
form.reset();
toast.success("Organization created successfully");
} catch (error) {
toast.error(
(error as { message?: string })?.message ??
"Organization could not be created",
);
}
};
return (
<Dialog open={open} onOpenChange={(o) => setOpen(o)}>
<DialogContent>
<DialogHeader>
<DialogTitle>Create Organization</DialogTitle>
<DialogDescription>
Create a new organization for your team to collaborate
and work together.
</DialogDescription>
</DialogHeader>
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="space-y-3"
>
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Org Email</FormLabel>
<FormControl>
<Input
placeholder="[email protected]"
{...field}
/>
</FormControl>
<FormDescription>
Enter the email of your organization.
This could be your personal email or a
shared email.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<FormField
control={form.control}
name="name"
render={({ field }) => (
<FormItem>
<FormLabel>Org Name</FormLabel>
<FormControl>
<Input
placeholder="Ali's Org"
{...field}
/>
</FormControl>
<FormDescription>
Enter the name of your organization.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<DialogFooter>
<DialogClose asChild>
<Button variant="outline">Cancel</Button>
</DialogClose>
<Button
disabled={isPending || isMutatePending}
type="submit"
className="gap-2"
>
{isPending || isMutatePending ? (
<Icons.loader className="h-4 w-4" />
) : null}
<span>Create</span>
</Button>
</DialogFooter>
</form>
</Form>
</DialogContent>
</Dialog>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/create-org-form.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/create-org-form.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 3539
} | 6 |
import { Icons } from "@/components/ui/icons";
import { siteUrls } from "@/config/urls";
import Link from "next/link";
import { cn } from "@/lib/utils";
import { UserDropdown } from "@/app/(app)/_components/user-dropdown";
import { ScrollArea, ScrollBar } from "@/components/ui/scroll-area";
import { SidebarNav } from "@/app/(app)/_components/sidebar-nav";
import { getUser } from "@/server/auth";
import {
OrgSelectDropdown,
type UserOrgs,
} from "@/app/(app)/_components/org-select-dropdown";
import { getOrganizations } from "@/server/actions/organization/queries";
import { Skeleton } from "@/components/ui/skeleton";
type SideNavProps = {
sidebarNavIncludeIds?: string[];
sidebarNavRemoveIds?: string[];
showOrgSwitcher?: boolean;
showLogo?: boolean;
};
/**
* @purpose The sidebar component contains the sidebar navigation and the user dropdown.
* to add a new navigation item, you can add a new object to the navigation array in the @see /src/config/dashboard.ts file
* to customize the user dropdown, you can add a new object to the navigation array in the @see /src/config/user-dropdown.ts file
*
* fell free to customize the sidebar component as you like
*/
export async function Sidebar({
sidebarNavIncludeIds,
sidebarNavRemoveIds,
showOrgSwitcher = true,
showLogo = true,
}: SideNavProps) {
const user = await getUser();
const { currentOrg, userOrgs } = await getOrganizations();
const myOrgs = userOrgs.filter((org) => org.ownerId === user?.id);
const sharedOrgs = userOrgs.filter((org) => org.ownerId !== user?.id);
const urgOrgsData: UserOrgs[] = [
{
heading: "My Orgs",
items: myOrgs,
},
{
heading: "Shared Orgs",
items: sharedOrgs,
},
];
return (
<aside className={cn("h-full w-full")}>
{showLogo && (
<div className={cn("flex h-16 items-center justify-between")}>
<Link
href={siteUrls.dashboard.home}
className={cn(
"z-10 transition-transform hover:scale-90",
)}
>
<Icons.logo
className="text-xl"
iconProps={{ className: "w-6 h-6 fill-primary" }}
/>
</Link>
</div>
)}
<div className="py-2">
<UserDropdown user={user} />
</div>
{showOrgSwitcher && (
<div className="py-2">
<OrgSelectDropdown
userOrgs={urgOrgsData}
currentOrg={currentOrg}
/>
</div>
)}
<ScrollArea style={{ height: "calc(100vh - 10.5rem)" }}>
<div className="h-full w-full py-2 pb-10">
<SidebarNav
sidebarNavIncludeIds={sidebarNavIncludeIds}
sidebarNavRemoveIds={sidebarNavRemoveIds}
/>
<ScrollBar orientation="vertical" />
</div>
</ScrollArea>
</aside>
);
}
export function SidebarLoading({
showOrgSwitcher = true,
}: {
showOrgSwitcher?: boolean;
}) {
return (
<aside className={cn("h-full w-full")}>
<div className={cn(" flex h-16 items-center justify-between")}>
<Link
href={siteUrls.home}
className={cn("z-10 transition-transform hover:scale-90")}
>
<Icons.logo
className="text-xl"
iconProps={{ className: "w-6 h-6 fill-primary" }}
/>
</Link>
</div>
<div className="py-2">
<Skeleton className="h-9 w-full rounded-md" />
</div>
{showOrgSwitcher && (
<div className="py-2">
<Skeleton className="h-9 w-full rounded-md" />
</div>
)}
<ScrollArea style={{ height: "calc(100vh - 10.5rem)" }}>
<div className="h-full w-full space-y-2 py-2">
{[1, 2, 3, 4, 5].map((i) => (
<Skeleton key={i} className="h-8 w-full rounded-md" />
))}
<ScrollBar orientation="vertical" />
</div>
</ScrollArea>
</aside>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/sidebar.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/_components/sidebar.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 2427
} | 7 |
import React from "react";
import { AppLayoutShell } from "@/app/(app)/_components/layout-shell";
import { sidebarConfig } from "@/config/sidebar";
type AppLayoutProps = {
children: React.ReactNode;
};
export default function AdminLayout({ children }: AppLayoutProps) {
// these are the ids of the sidebar nav items to include in the sidebar specifically @get ids from the sidebar config
const sideNavIncludedIds: string[] = [sidebarConfig.navIds.admin];
return (
<AppLayoutShell
sideNavIncludedIds={sideNavIncludedIds}
showOrgSwitcher={false}
>
{children}
</AppLayoutShell>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/layout.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/layout.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 245
} | 8 |
"use client";
import { Button } from "@/components/ui/button";
export const DownloadCsvBtn = ({ data }: { data: string }) => {
const downloadCsv = () => {
const blob = new Blob([data], { type: "text/csv" });
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = "waitlist.csv";
link.click();
URL.revokeObjectURL(url);
};
return (
<Button variant="secondary" onClick={downloadCsv}>
Download CSV
</Button>
);
};
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/waitlist/_components/download-csv-btn.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(app)/admin/waitlist/_components/download-csv-btn.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 244
} | 9 |
import { WebPageWrapper } from "@/app/(web)/_components/general-components";
import { Badge } from "@/components/ui/badge";
import { format } from "date-fns";
import Image from "next/image";
import { notFound } from "next/navigation";
import { type Metadata } from "next";
import { blogs } from "@/app/source";
import { useMDXComponents } from "mdx-components";
import { DocsBody } from "fumadocs-ui/page";
export const dynamic = "force-static";
type BlogSlugPageProps = {
params: {
slug: string[];
};
};
export default async function BlogSlugPage({ params }: BlogSlugPageProps) {
const blog = blogs.getPage(params.slug);
if (blog == null) {
notFound();
}
const MDX = blog.data.exports.default;
const components = useMDXComponents();
return (
<WebPageWrapper className="relative max-w-3xl flex-row items-start gap-8">
<article className="w-full space-y-10">
<div className="space-y-4">
<h1 className="scroll-m-20 font-heading text-4xl font-bold">
{blog.data.title}
</h1>
<div className="relative aspect-video max-h-[350px] w-full overflow-hidden rounded-md bg-muted/60">
<Image
src={blog.data.thumbnail}
alt={blog.data.title}
className="rounded-md"
fill
/>
</div>
{blog.data.tags && blog.data.tags.length > 0 && (
<div className="flex flex-wrap gap-2">
{blog.data.tags.map((tag) => (
<Badge variant="outline" key={tag}>
{tag}
</Badge>
))}
</div>
)}
<p className="text-sm text-muted-foreground">
{format(new Date(blog.data.publishedAt), "PPP")} {" "}
{blog.data.readTime} read
</p>
{blog.data.exports.lastModified && (
<p className="text-sm text-muted-foreground">
Last updated at{" "}
{format(
new Date(blog.data.exports.lastModified),
"PPP",
)}
</p>
)}
</div>
<DocsBody>
<MDX components={components} />
</DocsBody>
</article>
</WebPageWrapper>
);
}
export async function generateStaticParams() {
return blogs.getPages().map((page) => ({
slug: page.slugs,
}));
}
export function generateMetadata({ params }: { params: { slug?: string[] } }) {
const page = blogs.getPage(params.slug);
if (page == null) notFound();
return {
title: page.data.title,
description: page.data.description,
} satisfies Metadata;
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/(web)/blogs/[...slug]/page.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/(web)/blogs/[...slug]/page.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 1761
} | 10 |
"use client";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zodResolver } from "@hookform/resolvers/zod";
import {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import Link from "next/link";
import { siteUrls } from "@/config/urls";
import { Icons } from "@/components/ui/icons";
import { Input } from "@/components/ui/input";
import { Button } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { SocialLogins } from "@/app/auth/_components/social-logins";
import { useState } from "react";
import { signIn } from "next-auth/react";
import { toast } from "sonner";
const formSchema = z.object({
email: z.string().email("Please enter a valid email address"),
});
type formSchemaType = z.infer<typeof formSchema>;
type AuthFormProps = {
type: "signup" | "login";
};
export function AuthForm({ type }: AuthFormProps) {
const form = useForm<formSchemaType>({
resolver: zodResolver(formSchema),
defaultValues: {
email: "",
},
});
const [isLoading, setIsLoading] = useState(false);
const onSubmit = async (data: formSchemaType) => {
setIsLoading(true);
try {
await signIn("email", {
email: data.email,
callbackUrl: siteUrls.dashboard.home,
redirect: false,
});
toast.success("Check your email for the magic link", {
description: "also check your spam folder if you don't see it.",
});
} catch (error) {
toast.error("An error occurred. Please try again later.");
} finally {
setIsLoading(false);
}
};
return (
<Form {...form}>
<form
onSubmit={form.handleSubmit(onSubmit)}
className="bg w-full max-w-sm space-y-6"
>
<div className="flex flex-col items-center space-y-4">
<Link
href={siteUrls.home}
className="flex w-fit items-center transition-transform hover:scale-90"
>
<Icons.logoIcon className="h-10 w-10 fill-primary" />
</Link>
<div className="flex flex-col items-center space-y-1">
<h1 className="text-center text-2xl font-medium">
{type === "signup"
? " Create an account"
: "Login to your account"}
</h1>
<Link
href={
type === "signup"
? siteUrls.auth.login
: siteUrls.auth.signup
}
className="text-center text-sm text-muted-foreground underline underline-offset-4"
>
{type === "signup"
? "Already have an account? Login"
: "Don't have an account? SignUp"}
</Link>
</div>
</div>
<div className="space-y-3">
<FormField
control={form.control}
name="email"
render={({ field }) => (
<FormItem>
<FormLabel>Email</FormLabel>
<FormControl>
<Input
className="bg-background"
placeholder="[email protected]"
{...field}
/>
</FormControl>
<FormDescription>
We'll never share your email with
anyone else.
</FormDescription>
<FormMessage />
</FormItem>
)}
/>
<Button
disabled={isLoading}
aria-disabled={isLoading}
type="submit"
className="w-full gap-2"
>
{isLoading && <Icons.loader className="h-4 w-4" />}
<span>Continue with Email</span>
</Button>
</div>
<div className="relative flex items-center justify-center">
<Separator className="w-full" />
<p className="absolute bg-background px-2 text-sm font-medium text-muted-foreground">
OR
</p>
</div>
<SocialLogins />
</form>
</Form>
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/auth/_components/auth-form.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/auth/_components/auth-form.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 3059
} | 11 |
import { siteUrls } from "@/config/urls";
import type { MetadataRoute } from "next";
export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: "*",
allow: "/",
},
sitemap: `${siteUrls.publicUrl}/sitemap.xml`,
};
}
| alifarooq9/rapidlaunch/starterkits/saas/src/app/robots.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/app/robots.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 136
} | 12 |
import * as React from "react";
import { cva, type VariantProps } from "class-variance-authority";
import { cn } from "@/lib/utils";
const badgeVariants = cva(
"inline-flex items-center rounded-md border font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
{
variants: {
variant: {
default:
"border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80",
secondary:
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
destructive:
"border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80",
outline: "text-foreground",
background: "bg-background text-background-foreground",
success: "border-transparent bg-green-500 text-white",
info: "border-transparent bg-yellow-200 text-black",
},
size: {
sm: "text-xs px-2 py-0.5",
md: "text-sm px-2.5 py-1",
lg: "text-base px-4 py-2",
},
},
defaultVariants: {
variant: "default",
size: "sm",
},
},
);
export interface BadgeProps
extends React.HTMLAttributes<HTMLDivElement>,
VariantProps<typeof badgeVariants> {}
function Badge({ className, variant, size, ...props }: BadgeProps) {
return (
<div
className={cn(badgeVariants({ variant, size }), className)}
{...props}
/>
);
}
export { Badge, badgeVariants };
| alifarooq9/rapidlaunch/starterkits/saas/src/components/ui/badge.tsx | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/components/ui/badge.tsx",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 799
} | 13 |
/**
* This file is used to store the testimonials for the homepage.
* The testimonials are stored as an array of arrays of arrays.
* Each array represents a column of testimonials.
* Each inner array represents a row of testimonials.
* Each testimonial is an object with a body and author property.
*
* @note add your testimonials evenly
*/
type Testimonial = {
body: string;
author: {
name: string;
handle: string;
imageUrl: string;
logoUrl?: string;
};
};
export const featuredTestimonial: Testimonial = {
body: "Integer id nunc sit semper purus. Bibendum at lacus ut arcu blandit montes vitae auctor libero. Hac condimentum dignissim nibh vulputate ut nunc. Amet nibh orci mi venenatis blandit vel et proin. Non hendrerit in vel ac diam.",
author: {
name: "Brenna Goyette",
handle: "brennagoyette",
imageUrl:
"https://images.unsplash.com/photo-1550525811-e5869dd03032?ixlib=rb-=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=1024&h=1024&q=80",
logoUrl: "https://tailwindui.com/img/logos/savvycal-logo-gray-900.svg",
},
};
export const testimonials: Testimonial[][][] = [
[
[
{
body: "Laborum quis quam. Dolorum et ut quod quia. Voluptas numquam delectus nihil. Aut enim doloremque et ipsam.",
author: {
name: "Leslie Alexander",
handle: "lesliealexander",
imageUrl:
"https://images.unsplash.com/photo-1494790108377-be9c29b29330?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
},
},
{
body: "Aut reprehenderit voluptatem eum asperiores beatae id. Iure molestiae ipsam ut officia rem nulla blanditiis.",
author: {
name: "Lindsay Walton",
handle: "lindsaywalton",
imageUrl:
"https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
},
},
// More testimonials...
],
[
{
body: "Aut reprehenderit voluptatem eum asperiores beatae id. Iure molestiae ipsam ut officia rem nulla blanditiis.",
author: {
name: "Lindsay Walton",
handle: "lindsaywalton",
imageUrl:
"https://images.unsplash.com/photo-1517841905240-472988babdf9?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
},
},
// More testimonials...
],
],
[
[
{
body: "Voluptas quos itaque ipsam in voluptatem est. Iste eos blanditiis repudiandae. Earum deserunt enim molestiae ipsum perferendis recusandae saepe corrupti.",
author: {
name: "Tom Cook",
handle: "tomcook",
imageUrl:
"https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
},
},
// More testimonials...
],
[
{
body: "Molestias ea earum quos nostrum doloremque sed. Quaerat quasi aut velit incidunt excepturi rerum voluptatem minus harum.",
author: {
name: "Leonard Krasner",
handle: "leonardkrasner",
imageUrl:
"https://images.unsplash.com/photo-1519345182560-3f2917c472ef?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
},
},
{
body: "Voluptas quos itaque ipsam in voluptatem est. Iste eos blanditiis repudiandae. Earum deserunt enim molestiae ipsum perferendis recusandae saepe corrupti.",
author: {
name: "Tom Cook",
handle: "tomcook",
imageUrl:
"https://images.unsplash.com/photo-1472099645785-5658abf4ff4e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=facearea&facepad=2&w=256&h=256&q=80",
},
},
// More testimonials...
],
],
];
| alifarooq9/rapidlaunch/starterkits/saas/src/config/testimonials.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/config/testimonials.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 2495
} | 14 |
"use server";
import { pricingPlans } from "@/config/pricing";
import { getOrgSubscription } from "@/server/actions/subscription/query";
import { db } from "@/server/db";
import { subscriptions, webhookEvents } from "@/server/db/schema";
import { configureLemonSqueezy } from "@/server/lemonsqueezy";
import { webhookHasData, webhookHasMeta } from "@/validations/lemonsqueezy";
import {
cancelSubscription,
updateSubscription,
} from "@lemonsqueezy/lemonsqueezy.js";
import { eq } from "drizzle-orm";
import { revalidatePath } from "next/cache";
type NewWebhookEvent = typeof webhookEvents.$inferInsert;
type NewSubscription = typeof subscriptions.$inferInsert;
export async function storeWebhookEvent(
eventName: string,
body: NewWebhookEvent["body"],
) {
const returnedValue = await db
.insert(webhookEvents)
.values({
eventName,
processed: false,
body,
})
.returning();
return returnedValue[0];
}
/**
* Processes a webhook event and updates the corresponding data in the database.
* @param webhookEvent - The webhook event to process.
* @returns A Promise that resolves when the processing is complete.
* @throws An error if the webhook event is not found in the database or if there is an error during processing.
*/
export async function processWebhookEvent(webhookEvent: NewWebhookEvent) {
configureLemonSqueezy();
const dbwebhookEvent = await db
.select()
.from(webhookEvents)
.where(eq(webhookEvents.id, webhookEvent.id!));
if (dbwebhookEvent.length < 1) {
throw new Error(
`Webhook event #${webhookEvent.id} not found in the database.`,
);
}
let processingError = "";
const eventBody = webhookEvent.body;
if (!webhookHasMeta(eventBody)) {
processingError = "Event body is missing the 'meta' property.";
} else if (webhookHasData(eventBody)) {
if (webhookEvent.eventName.startsWith("subscription_payment_")) {
// Save subscription invoices; eventBody is a SubscriptionInvoice
// Not implemented.
} else if (webhookEvent.eventName.startsWith("subscription_")) {
// Save subscription events; obj is a Subscription
const attributes = eventBody.data.attributes;
const variantId = attributes.variant_id as string;
// We assume that the Plan table is up to date.
const plan = pricingPlans.find(
(p) =>
p.variantId?.monthly === Number(variantId) ||
p.variantId?.yearly === Number(variantId),
);
if (!plan) {
processingError = `Plan with variantId ${variantId} not found.`;
} else {
// Update the subscription in the database.
const updateData: NewSubscription = {
lemonSqueezyId: eventBody.data.id,
orderId: attributes.order_id as number,
orgId: eventBody.meta.custom_data.org_id,
variantId: Number(variantId),
};
// Create/update subscription in the database.
try {
await db
.insert(subscriptions)
.values(updateData)
.onConflictDoUpdate({
target: subscriptions.lemonSqueezyId,
set: updateData,
});
} catch (error) {
processingError = `Failed to upsert Subscription #${updateData.lemonSqueezyId} to the database.`;
console.error(error);
}
}
} else if (webhookEvent.eventName.startsWith("order_")) {
// Save orders; eventBody is a "Order"
/* Not implemented */
} else if (webhookEvent.eventName.startsWith("license_")) {
// Save license keys; eventBody is a "License key"
/* Not implemented */
}
// Update the webhook event in the database.
await db
.update(webhookEvents)
.set({
processed: true,
processingError,
})
.where(eq(webhookEvents.id, webhookEvent.id!));
}
}
/**
* This action will change the plan of a subscription on Lemon Squeezy.
*/
export async function changePlan(
currentVariantId: number,
newVariantId: number,
) {
configureLemonSqueezy();
// Get user subscriptions
const subscription = await getOrgSubscription();
if (!subscription) {
throw new Error(
`No subscription with plan id #${currentVariantId} was found.`,
);
}
// Send request to Lemon Squeezy to change the subscription.
const updatedSub = await updateSubscription(subscription.lemonSqueezyId, {
variantId: newVariantId,
invoiceImmediately: true,
// @ts-expect-error -- null is a valid value for pause
pause: null,
cancelled: false,
});
// Save in db
try {
await db
.update(subscriptions)
.set({
lemonSqueezyId: updatedSub.data?.data.id,
variantId: newVariantId,
})
.where(
eq(subscriptions.lemonSqueezyId, subscription.lemonSqueezyId),
);
} catch (error) {
throw new Error(
`Failed to update Subscription #${subscription.lemonSqueezyId} in the database.`,
);
}
revalidatePath("/");
return updatedSub;
}
export async function cancelPlan() {
configureLemonSqueezy();
const subscription = await getOrgSubscription();
if (!subscription) {
throw new Error("No subscription found.");
}
const cancelSub = await cancelSubscription(subscription.lemonSqueezyId);
// Save in db
try {
await db
.update(subscriptions)
.set({
lemonSqueezyId: cancelSub.data?.data.id,
variantId: cancelSub.data?.data.attributes.variant_id,
})
.where(
eq(subscriptions.lemonSqueezyId, subscription.lemonSqueezyId),
);
} catch (error) {
throw new Error(
`Failed to update Subscription #${subscription.lemonSqueezyId} in the database.`,
);
}
revalidatePath("/");
return cancelSub;
}
export async function pausePlan() {
configureLemonSqueezy();
const subscription = await getOrgSubscription();
if (!subscription) {
throw new Error("No subscription found.");
}
const returnedSub = await updateSubscription(subscription.lemonSqueezyId, {
pause: {
mode: "void",
},
});
// Update the db
try {
await db
.update(subscriptions)
.set({
lemonSqueezyId: returnedSub.data?.data.id,
variantId: returnedSub.data?.data.attributes.variant_id,
})
.where(
eq(subscriptions.lemonSqueezyId, subscription.lemonSqueezyId),
);
} catch (error) {
throw new Error(
`Failed to pause Subscription #${subscription.lemonSqueezyId} in the database.`,
);
}
revalidatePath("/");
return returnedSub;
}
export async function resumePlan() {
configureLemonSqueezy();
const subscription = await getOrgSubscription();
if (!subscription) {
throw new Error("No subscription found.");
}
const returnedSub = await updateSubscription(subscription.lemonSqueezyId, {
cancelled: false,
// @ts-expect-error -- null is a valid value for pause
pause: null,
});
// Update the db
try {
await db
.update(subscriptions)
.set({
lemonSqueezyId: returnedSub.data?.data.id,
variantId: returnedSub.data?.data.attributes.variant_id,
})
.where(
eq(subscriptions.lemonSqueezyId, subscription.lemonSqueezyId),
);
} catch (error) {
throw new Error(
`Failed to resume Subscription #${subscription.lemonSqueezyId} in the database.`,
);
}
revalidatePath("/");
return returnedSub;
}
| alifarooq9/rapidlaunch/starterkits/saas/src/server/actions/subscription/mutations.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/server/actions/subscription/mutations.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 3756
} | 15 |
/**
* Check if the value is an object.
*/
function isObject(value: unknown): value is Record<string, unknown> {
return typeof value === "object" && value !== null;
}
/**
* Typeguard to check if the object has a 'meta' property
* and that the 'meta' property has the correct shape.
*/
export function webhookHasMeta(obj: unknown): obj is {
meta: {
event_name: string;
custom_data: {
user_id: string;
org_id: string;
};
};
} {
if (
isObject(obj) &&
isObject(obj.meta) &&
typeof obj.meta.event_name === "string" &&
isObject(obj.meta.custom_data) &&
typeof obj.meta.custom_data.user_id === "string" &&
typeof obj.meta.custom_data.org_id === "string"
) {
return true;
}
return false;
}
/**
* Typeguard to check if the object has a 'data' property and the correct shape.
*
* @param obj - The object to check.
* @returns True if the object has a 'data' property.
*/
export function webhookHasData(obj: unknown): obj is {
data: {
attributes: Record<string, unknown> & {
first_subscription_item: {
id: number;
price_id: number;
is_usage_based: boolean;
};
};
id: string;
};
} {
return (
isObject(obj) &&
"data" in obj &&
isObject(obj.data) &&
"attributes" in obj.data
);
}
| alifarooq9/rapidlaunch/starterkits/saas/src/validations/lemonsqueezy.ts | {
"file_path": "alifarooq9/rapidlaunch/starterkits/saas/src/validations/lemonsqueezy.ts",
"repo_id": "alifarooq9/rapidlaunch",
"token_count": 643
} | 16 |
import Main from '@/components/dashboard/main';
import { redirect } from 'next/navigation';
import { getUserDetails, getUser } from '@/utils/supabase/queries';
import { createClient } from '@/utils/supabase/server';
export default async function Account() {
const supabase = createClient();
const [user, userDetails] = await Promise.all([
getUser(supabase),
getUserDetails(supabase)
]);
if (!user) {
return redirect('/dashboard/signin');
}
return <Main user={user} userDetails={userDetails} />;
}
| horizon-ui/shadcn-nextjs-boilerplate/app/dashboard/main/page.tsx | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/app/dashboard/main/page.tsx",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 167
} | 17 |
'use client';
import {Button} from '@/components/ui/button';
import { signInWithOAuth } from '@/utils/auth-helpers/client';
import { type Provider } from '@supabase/supabase-js';
import { FcGoogle } from "react-icons/fc";
import { useState } from 'react';
import { Input } from '../ui/input';
type OAuthProviders = {
name: Provider;
displayName: string;
icon: JSX.Element;
};
export default function OauthSignIn() {
const oAuthProviders: OAuthProviders[] = [
{
name: 'google',
displayName: 'Google',
icon: <FcGoogle className="h-5 w-5" />
}
/* Add desired OAuth providers here */
];
const [isSubmitting, setIsSubmitting] = useState(false);
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
setIsSubmitting(true); // Disable the button while the request is being handled
await signInWithOAuth(e);
setIsSubmitting(false);
};
return (
<div className="mt-8">
{oAuthProviders.map((provider) => (
<form
key={provider.name}
className="pb-2"
onSubmit={(e) => handleSubmit(e)}
>
<Input type="hidden" name="provider" value={provider.name} />
<Button
variant="outline"
type="submit"
className="w-full text-zinc-950 py-6 dark:text-white"
>
<span className="mr-2">{provider.icon}</span>
<span>{provider.displayName}</span>
</Button>
</form>
))}
</div>
);
}
| horizon-ui/shadcn-nextjs-boilerplate/components/auth-ui/OauthSignIn.tsx | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/components/auth-ui/OauthSignIn.tsx",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 645
} | 18 |
'use client';
export default function Footer() {
return (
<div className="z-[3] flex flex-col items-center justify-between mt-auto pb-[30px] md:px-0 lg:flex-row">
<ul className="flex flex-row">
<li className="mr-4 md:mr-[44px]">
<a
className="text-[10px] font-medium text-zinc-950 dark:text-zinc-400 lg:text-sm"
target="_blank"
href="https://horizon-ui.notion.site/Terms-Conditions-c671e573673746e19d2fc3e4cba0c161"
>
Terms & Conditions
</a>
</li>
<li className="mr-4 md:mr-[44px]">
<a
className="text-[10px] font-medium text-zinc-950 dark:text-zinc-400 lg:text-sm"
target="_blank"
href="https://horizon-ui.notion.site/Privacy-Policy-c22ff04f55474ae3b35ec45feca62bad"
>
Privacy Policy
</a>
</li>
<li className="mr-4 md:mr-[44px]">
<a
className="text-[10px] font-medium text-zinc-950 dark:text-zinc-400 lg:text-sm"
target="_blank"
href="https://horizon-ui.notion.site/End-User-License-Agreement-8fb09441ea8c4c08b60c37996195a6d5"
>
License
</a>
</li>
<li>
<a
className="text-[10px] font-medium text-zinc-950 dark:text-zinc-400 lg:text-sm"
target="_blank"
href="https://horizon-ui.notion.site/Refund-Policy-1b0983287b92486cb6b18071b2343ac9"
>
Refund Policy
</a>
</li>
</ul>
</div>
);
}
| horizon-ui/shadcn-nextjs-boilerplate/components/footer/FooterAuthDefault.tsx | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/components/footer/FooterAuthDefault.tsx",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 880
} | 19 |
import endent from 'endent';
import {
createParser,
ParsedEvent,
ReconnectInterval,
} from 'eventsource-parser';
const createPrompt = (topic: string, words: string, essayType: string) => {
const data = (topic: any, words: string, essayType: string) => {
return endent`
You are an expert formal essay writer and generator.
You know very well all types of essays. Generate an formal ${essayType} essay about ${topic}, which has a number of maximum ${words} words.
The generated content should NOT be longer than ${words} words.
The essay must be in markdown format but not rendered, it must include all markdown characteristics. The title must be bold, and there should be a between every paragraph.
Do not include informations about console logs or print messages.
`;
};
if (essayType) {
return data(topic, words, essayType);
}
};
export async function OpenAIStream (
topic: string,
essayType: string,
words: string,
model: string,
key: string | undefined,
) {
const prompt = createPrompt(topic, words, essayType);
const system = { role: 'system', content: prompt };
const res = await fetch(`https://api.openai.com/v1/chat/completions`, {
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${key || process.env.NEXT_PUBLIC_OPENAI_API_KEY}`,
},
method: 'POST',
body: JSON.stringify({
model,
messages: [system],
temperature: 0,
stream: true,
}),
});
const encoder = new TextEncoder();
const decoder = new TextDecoder();
if (res.status !== 200) {
const statusText = res.statusText;
const result = await res.body?.getReader().read();
throw new Error(
`OpenAI API returned an error: ${
decoder.decode(result?.value) || statusText
}`,
);
}
const stream = new ReadableStream({
async start(controller) {
const onParse = (event: ParsedEvent | ReconnectInterval) => {
if (event.type === 'event') {
const data = event.data;
if (data === '[DONE]') {
controller.close();
return;
}
try {
const json = JSON.parse(data);
const text = json.choices[0].delta.content;
const queue = encoder.encode(text);
controller.enqueue(queue);
} catch (e) {
controller.error(e);
}
}
};
const parser = createParser(onParse);
for await (const chunk of res.body as any) {
parser.feed(decoder.decode(chunk));
}
},
});
return stream;
};
| horizon-ui/shadcn-nextjs-boilerplate/utils/streams/essayStream.ts | {
"file_path": "horizon-ui/shadcn-nextjs-boilerplate/utils/streams/essayStream.ts",
"repo_id": "horizon-ui/shadcn-nextjs-boilerplate",
"token_count": 1008
} | 20 |
#!/bin/sh
# Disable concurent to run `check-types` after ESLint in lint-staged
cd "$(dirname "$0")/.." && npx --no lint-staged --concurrent false
| ixartz/SaaS-Boilerplate/.husky/pre-commit | {
"file_path": "ixartz/SaaS-Boilerplate/.husky/pre-commit",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 54
} | 21 |
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
out: './migrations',
schema: './src/models/Schema.ts',
dialect: 'postgresql',
dbCredentials: {
url: process.env.DATABASE_URL ?? '',
},
verbose: true,
strict: true,
});
| ixartz/SaaS-Boilerplate/drizzle.config.ts | {
"file_path": "ixartz/SaaS-Boilerplate/drizzle.config.ts",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 99
} | 22 |
import type { MetadataRoute } from 'next';
import { getBaseUrl } from '@/utils/Helpers';
export default function robots(): MetadataRoute.Robots {
return {
rules: {
userAgent: '*',
allow: '/',
},
sitemap: `${getBaseUrl()}/sitemap.xml`,
};
}
| ixartz/SaaS-Boilerplate/src/app/robots.ts | {
"file_path": "ixartz/SaaS-Boilerplate/src/app/robots.ts",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 108
} | 23 |
import type * as LabelPrimitive from '@radix-ui/react-label';
import { Slot } from '@radix-ui/react-slot';
import * as React from 'react';
import type { ControllerProps, FieldPath, FieldValues } from 'react-hook-form';
import { Controller, FormProvider } from 'react-hook-form';
import { Label } from '@/components/ui/label';
import { cn } from '@/utils/Helpers';
import { FormFieldContext, FormItemContext, useFormField } from './useFormField';
const Form = FormProvider;
const FormField = <
TFieldValues extends FieldValues = FieldValues,
TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>,
>({
...props
}: ControllerProps<TFieldValues, TName>) => {
// eslint-disable-next-line react-hooks/exhaustive-deps
const formFieldName = React.useMemo(() => ({ name: props.name }), []);
return (
<FormFieldContext.Provider value={formFieldName}>
<Controller {...props} />
</FormFieldContext.Provider>
);
};
const FormItem = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => {
const id = React.useId();
// eslint-disable-next-line react-hooks/exhaustive-deps
const formItemId = React.useMemo(() => ({ id }), []);
return (
<FormItemContext.Provider value={formItemId}>
<div ref={ref} className={cn('space-y-2', className)} {...props} />
</FormItemContext.Provider>
);
});
FormItem.displayName = 'FormItem';
const FormLabel = React.forwardRef<
React.ElementRef<typeof LabelPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof LabelPrimitive.Root>
>(({ className, ...props }, ref) => {
const { error, formItemId } = useFormField();
return (
<Label
ref={ref}
className={cn(error && 'text-destructive', className)}
htmlFor={formItemId}
{...props}
/>
);
});
FormLabel.displayName = 'FormLabel';
const FormControl = React.forwardRef<
React.ElementRef<typeof Slot>,
React.ComponentPropsWithoutRef<typeof Slot>
>(({ ...props }, ref) => {
const { error, formItemId, formDescriptionId, formMessageId }
= useFormField();
return (
<Slot
ref={ref}
id={formItemId}
aria-describedby={
!error
? `${formDescriptionId}`
: `${formDescriptionId} ${formMessageId}`
}
aria-invalid={!!error}
{...props}
/>
);
});
FormControl.displayName = 'FormControl';
const FormDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => {
const { formDescriptionId } = useFormField();
return (
<p
ref={ref}
id={formDescriptionId}
className={cn('text-sm text-muted-foreground', className)}
{...props}
/>
);
});
FormDescription.displayName = 'FormDescription';
const FormMessage = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, children, ...props }, ref) => {
const { error, formMessageId } = useFormField();
const body = error ? String(error?.message) : children;
if (!body) {
return null;
}
return (
<p
ref={ref}
id={formMessageId}
className={cn('text-sm font-medium text-destructive', className)}
{...props}
>
{body}
</p>
);
});
FormMessage.displayName = 'FormMessage';
export {
Form,
FormControl,
FormDescription,
FormField,
FormItem,
FormLabel,
FormMessage,
};
| ixartz/SaaS-Boilerplate/src/components/ui/form.tsx | {
"file_path": "ixartz/SaaS-Boilerplate/src/components/ui/form.tsx",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 1253
} | 24 |
import Link from 'next/link';
import { useTranslations } from 'next-intl';
import React from 'react';
export const CenteredFooter = (props: {
logo: React.ReactNode;
name: string;
iconList: React.ReactNode;
legalLinks: React.ReactNode;
children: React.ReactNode;
}) => {
const t = useTranslations('Footer');
return (
<div className="flex flex-col items-center text-center">
{props.logo}
<ul className="mt-4 flex gap-x-8 text-lg max-sm:flex-col [&_a:hover]:opacity-100 [&_a]:opacity-60">
{props.children}
</ul>
<ul className="mt-4 flex flex-row gap-x-5 text-muted-foreground [&_svg:hover]:text-primary [&_svg:hover]:opacity-100 [&_svg]:size-5 [&_svg]:fill-current [&_svg]:opacity-60">
{props.iconList}
</ul>
<div className="mt-6 flex w-full items-center justify-between gap-y-2 border-t pt-3 text-sm text-muted-foreground max-md:flex-col">
<div>
{` Copyright ${new Date().getFullYear()} ${props.name}. `}
{t.rich('designed_by', {
author: () => (
<Link
className="text-blue-500 hover:text-blue-600"
href="https://creativedesignsguru.com"
>
Creative Designs Guru
</Link>
),
})}
{/*
* PLEASE READ THIS SECTION
* I'm an indie maker with limited resources and funds, I'll really appreciate if you could have a link to my website.
* The link doesn't need to appear on every pages, one link on one page is enough.
* For example, in the `About` page. Thank you for your support, it'll mean a lot to me.
*/}
</div>
<ul className="flex gap-x-4 font-medium [&_a:hover]:opacity-100 [&_a]:opacity-60">
{props.legalLinks}
</ul>
</div>
</div>
);
};
| ixartz/SaaS-Boilerplate/src/features/landing/CenteredFooter.tsx | {
"file_path": "ixartz/SaaS-Boilerplate/src/features/landing/CenteredFooter.tsx",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 849
} | 25 |
import type { PLAN_ID } from '@/utils/AppConfig';
import type { EnumValues } from './Enum';
export type PlanId = EnumValues<typeof PLAN_ID>;
export const BILLING_INTERVAL = {
MONTH: 'month',
YEAR: 'year',
} as const;
export type BillingInterval = EnumValues<typeof BILLING_INTERVAL>;
export const SUBSCRIPTION_STATUS = {
ACTIVE: 'active',
PENDING: 'pending',
} as const;
// PricingPlan is currently only used for Pricing section of the landing page.
// If you need a real Stripe subscription payment with checkout page, customer portal, webhook, etc.
// You can check out the Next.js Boilerplate Pro at: https://nextjs-boilerplate.com/pro-saas-starter-kit
// On top of that, you'll get access to real example of SaaS application with Next.js, TypeScript, Tailwind CSS, and more.
// You can find a live demo at: https://pro-demo.nextjs-boilerplate.com
export type PricingPlan = {
id: PlanId;
price: number;
interval: BillingInterval;
testPriceId: string; // Use for testing
devPriceId: string;
prodPriceId: string;
features: {
teamMember: number;
website: number;
storage: number;
transfer: number;
};
};
export type IStripeSubscription = {
stripeSubscriptionId: string | null;
stripeSubscriptionPriceId: string | null;
stripeSubscriptionStatus: string | null;
stripeSubscriptionCurrentPeriodEnd: number | null;
};
export type PlanDetails =
| {
isPaid: true;
plan: PricingPlan;
stripeDetails: IStripeSubscription;
} | {
isPaid: false;
plan: PricingPlan;
stripeDetails?: undefined;
};
| ixartz/SaaS-Boilerplate/src/types/Subscription.ts | {
"file_path": "ixartz/SaaS-Boilerplate/src/types/Subscription.ts",
"repo_id": "ixartz/SaaS-Boilerplate",
"token_count": 516
} | 26 |
const DEFAULT_ATTRS = require('./tools/build-icons/render/default-attrs.json');
module.exports = {
root: true,
env: {
browser: true,
node: true,
},
extends: ['airbnb-base', 'prettier'],
plugins: ['import', '@html-eslint'],
rules: {
'no-console': 'off',
'no-param-reassign': 'off',
'no-shadow': 'off',
'no-use-before-define': 'off',
'import/no-extraneous-dependencies': [
'error',
{
devDependencies: ['**/*.test.js', '**/*.spec.js', '**/scripts/**'],
},
],
'import/extensions': [
'error',
{
pattern: {
mjs: 'always',
json: 'always',
},
},
],
},
parserOptions: {
tsconfigRootDir: __dirname,
project: ['./docs/tsconfig.json', './packages/*/tsconfig.json'],
ecmaVersion: 'latest',
sourceType: 'module',
},
overrides: [
{
files: ['./icons/*.svg'],
parser: '@html-eslint/parser',
rules: {
'@html-eslint/require-doctype': 'off',
'@html-eslint/no-duplicate-attrs': 'error',
'@html-eslint/no-inline-styles': 'error',
'@html-eslint/require-attrs': [
'error',
...Object.entries(DEFAULT_ATTRS).map(([attr, value]) => ({
tag: 'svg',
attr,
value: String(value),
})),
],
'@html-eslint/indent': ['error', 2],
'@html-eslint/no-multiple-empty-lines': ['error', { max: 0 }],
'@html-eslint/no-extra-spacing-attrs': [
'error',
{
enforceBeforeSelfClose: true,
},
],
'@html-eslint/require-closing-tags': [
'error',
{
selfClosing: 'always',
allowSelfClosingCustom: true,
},
],
'@html-eslint/element-newline': 'error',
'@html-eslint/no-trailing-spaces': 'error',
'@html-eslint/quotes': 'error',
},
},
],
};
| lucide-icons/lucide/.eslintrc.js | {
"file_path": "lucide-icons/lucide/.eslintrc.js",
"repo_id": "lucide-icons/lucide",
"token_count": 1020
} | 27 |
export type IconContent = [icon: string, src: string];
async function generateZip(icons: IconContent[]) {
const JSZip = (await import('jszip')).default;
const zip = new JSZip();
const addingZipPromises = icons.map(([name, src]) => zip.file(`${name}.svg`, src));
await Promise.all(addingZipPromises);
return zip.generateAsync({ type: 'blob' });
}
export default generateZip;
| lucide-icons/lucide/docs/.vitepress/lib/generateZip.ts | {
"file_path": "lucide-icons/lucide/docs/.vitepress/lib/generateZip.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 124
} | 28 |
import Fuse from 'fuse.js';
import { shallowRef, computed, Ref } from 'vue';
const useSearch = <T>(
query: Ref<string>,
collection: Ref<T[]>,
keys: Fuse.FuseOptionKeyObject<T>[] = [],
) => {
const index = shallowRef(
new Fuse(collection.value, {
threshold: 0.2,
keys,
}),
);
const results = computed(() => {
index.value.setCollection(collection.value);
if (query.value) {
return index.value.search(query.value).map((result) => result.item);
}
if (keys.length !== 0) {
const mainKey = keys[0].name;
return collection.value.sort((a, b) => {
const aString = a[mainKey as keyof T] as string;
const bString = b[mainKey as keyof T] as string;
return aString.localeCompare(bString);
});
}
return collection.value;
});
return results;
};
export default useSearch;
| lucide-icons/lucide/docs/.vitepress/theme/composables/useSearch.ts | {
"file_path": "lucide-icons/lucide/docs/.vitepress/theme/composables/useSearch.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 346
} | 29 |
import App from './App.js?raw'
import styles from '../../../basics/examples/styles.css?raw'
import IconCss from './icon.css?raw'
const files = {
'App.js': {
code: App,
active: true,
},
'icon.css': {
code: IconCss,
readOnly: false,
},
'styles.css': {
code: styles,
hidden: true
},
}
export default files
| lucide-icons/lucide/docs/guide/advanced/examples/filled-icon-example/files.ts | {
"file_path": "lucide-icons/lucide/docs/guide/advanced/examples/filled-icon-example/files.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 142
} | 30 |
import { Smile } from "lucide-react";
function App() {
return (
<div className="app">
<Smile color="#3e9392" />
</div>
);
}
export default App; | lucide-icons/lucide/docs/guide/basics/examples/color-icon/App.js | {
"file_path": "lucide-icons/lucide/docs/guide/basics/examples/color-icon/App.js",
"repo_id": "lucide-icons/lucide",
"token_count": 68
} | 31 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<style>
.path {
stroke: #2D3748;
}
@media (prefers-color-scheme: dark) {
.path {
stroke: #fff;
}
}
</style>
<path d="M14 12C14 9.79086 12.2091 8 10 8C7.79086 8 6 9.79086 6 12C6 16.4183 9.58172 20 14 20C18.4183 20 22 16.4183 22 12C22 8.446 20.455 5.25285 18 3.05557" class="path"/>
<path d="M10 12C10 14.2091 11.7909 16 14 16C16.2091 16 18 14.2091 18 12C18 7.58172 14.4183 4 10 4C5.58172 4 2 7.58172 2 12C2 15.5841 3.57127 18.8012 6.06253 21" stroke="#F56565" />
</svg>
| lucide-icons/lucide/docs/public/favicon.svg | {
"file_path": "lucide-icons/lucide/docs/public/favicon.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 354
} | 32 |
<svg width="36" height="30" viewBox="0 0 24 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="m14.2 0-2.7 4.6L9 0H0l11.5 20L23.1 0h-8.9Z" fill="#41B883"/>
<path d="m14.2 0-2.7 4.6L9 0H4.6l7 12 6.9-12h-4.3Z" fill="#34495E"/>
</svg>
| lucide-icons/lucide/docs/public/framework-logos/vue.svg | {
"file_path": "lucide-icons/lucide/docs/public/framework-logos/vue.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 138
} | 33 |
import path from 'path';
import fs from 'fs';
import { getIconMetaData } from '@lucide/build-icons';
import { getCurrentDirPath } from '@lucide/helpers';
const currentDir = process.cwd();
const scriptDir = getCurrentDirPath(import.meta.url);
const iconMetaData = await getIconMetaData(path.resolve(scriptDir, '../icons'));
const iconAliasesRedirectRoutes = Object.entries(iconMetaData)
.filter(([, { aliases }]) => aliases?.length)
.map(([iconName, { aliases }]) => {
aliases = aliases.map((alias) => (typeof alias === 'object' ? alias.name : alias));
const aliasRouteMatches = aliases.join('|');
return {
src: `/icons/(${aliasRouteMatches})`,
status: 302,
headers: {
Location: `/icons/${iconName}`,
},
};
});
const vercelRouteConfig = {
version: 3,
overrides: {},
cleanUrls: true,
routes: [
{
handle: 'filesystem',
},
{
src: '(?<url>/api/.*)',
dest: '/__nitro?url=$url',
},
...iconAliasesRedirectRoutes,
],
};
const output = JSON.stringify(vercelRouteConfig, null, 2);
const vercelOutputJSON = path.resolve(currentDir, '.vercel/output/config.json');
fs.writeFileSync(vercelOutputJSON, output, 'utf-8');
| lucide-icons/lucide/docs/scripts/writeVercelOutput.mjs | {
"file_path": "lucide-icons/lucide/docs/scripts/writeVercelOutput.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 466
} | 34 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<rect width="20" height="5" x="2" y="3" rx="1" />
<path d="M4 8v11a2 2 0 0 0 2 2h2" />
<path d="M20 8v11a2 2 0 0 1-2 2h-2" />
<path d="m9 15 3-3 3 3" />
<path d="M12 12v9" />
</svg>
| lucide-icons/lucide/icons/archive-restore.svg | {
"file_path": "lucide-icons/lucide/icons/archive-restore.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 194
} | 35 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M17 11h1a3 3 0 0 1 0 6h-1" />
<path d="M9 12v6" />
<path d="M13 12v6" />
<path d="M14 7.5c-1 0-1.44.5-3 .5s-2-.5-3-.5-1.72.5-2.5.5a2.5 2.5 0 0 1 0-5c.78 0 1.57.5 2.5.5S9.44 2 11 2s2 1.5 3 1.5 1.72-.5 2.5-.5a2.5 2.5 0 0 1 0 5c-.78 0-1.5-.5-2.5-.5Z" />
<path d="M5 8v12a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V8" />
</svg>
| lucide-icons/lucide/icons/beer.svg | {
"file_path": "lucide-icons/lucide/icons/beer.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 305
} | 36 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="11.9" r="2" />
<path d="M6.7 3.4c-.9 2.5 0 5.2 2.2 6.7C6.5 9 3.7 9.6 2 11.6" />
<path d="m8.9 10.1 1.4.8" />
<path d="M17.3 3.4c.9 2.5 0 5.2-2.2 6.7 2.4-1.2 5.2-.6 6.9 1.5" />
<path d="m15.1 10.1-1.4.8" />
<path d="M16.7 20.8c-2.6-.4-4.6-2.6-4.7-5.3-.2 2.6-2.1 4.8-4.7 5.2" />
<path d="M12 13.9v1.6" />
<path d="M13.5 5.4c-1-.2-2-.2-3 0" />
<path d="M17 16.4c.7-.7 1.2-1.6 1.5-2.5" />
<path d="M5.5 13.9c.3.9.8 1.8 1.5 2.5" />
</svg>
| lucide-icons/lucide/icons/biohazard.svg | {
"file_path": "lucide-icons/lucide/icons/biohazard.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 411
} | 37 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z" />
<path d="m7 16.5-4.74-2.85" />
<path d="m7 16.5 5-3" />
<path d="M7 16.5v5.17" />
<path d="M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z" />
<path d="m17 16.5-5-3" />
<path d="m17 16.5 4.74-2.85" />
<path d="M17 16.5v5.17" />
<path d="M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z" />
<path d="M12 8 7.26 5.15" />
<path d="m12 8 4.74-2.85" />
<path d="M12 13.5V8" />
</svg>
| lucide-icons/lucide/icons/boxes.svg | {
"file_path": "lucide-icons/lucide/icons/boxes.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 478
} | 38 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m9.5 7.5-2 2a4.95 4.95 0 1 0 7 7l2-2a4.95 4.95 0 1 0-7-7Z" />
<path d="M14 6.5v10" />
<path d="M10 7.5v10" />
<path d="m16 7 1-5 1.37.68A3 3 0 0 0 19.7 3H21v1.3c0 .46.1.92.32 1.33L22 7l-5 1" />
<path d="m8 17-1 5-1.37-.68A3 3 0 0 0 4.3 21H3v-1.3a3 3 0 0 0-.32-1.33L2 17l5-1" />
</svg>
| lucide-icons/lucide/icons/candy.svg | {
"file_path": "lucide-icons/lucide/icons/candy.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 281
} | 39 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M2.27 21.7s9.87-3.5 12.73-6.36a4.5 4.5 0 0 0-6.36-6.37C5.77 11.84 2.27 21.7 2.27 21.7zM8.64 14l-2.05-2.04M15.34 15l-2.46-2.46" />
<path d="M22 9s-1.33-2-3.5-2C16.86 7 15 9 15 9s1.33 2 3.5 2S22 9 22 9z" />
<path d="M15 2s-2 1.33-2 3.5S15 9 15 9s2-1.84 2-3.5C17 3.33 15 2 15 2z" />
</svg>
| lucide-icons/lucide/icons/carrot.svg | {
"file_path": "lucide-icons/lucide/icons/carrot.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 283
} | 40 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M16.75 12h3.632a1 1 0 0 1 .894 1.447l-2.034 4.069a1 1 0 0 1-1.708.134l-2.124-2.97" />
<path d="M17.106 9.053a1 1 0 0 1 .447 1.341l-3.106 6.211a1 1 0 0 1-1.342.447L3.61 12.3a2.92 2.92 0 0 1-1.3-3.91L3.69 5.6a2.92 2.92 0 0 1 3.92-1.3z" />
<path d="M2 19h3.76a2 2 0 0 0 1.8-1.1L9 15" />
<path d="M2 21v-4" />
<path d="M7 9h.01" />
</svg>
| lucide-icons/lucide/icons/cctv.svg | {
"file_path": "lucide-icons/lucide/icons/cctv.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 307
} | 41 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="8" cy="8" r="6" />
<path d="M18.09 10.37A6 6 0 1 1 10.34 18" />
<path d="M7 6h1v4" />
<path d="m16.71 13.88.7.71-2.82 2.82" />
</svg>
| lucide-icons/lucide/icons/coins.svg | {
"file_path": "lucide-icons/lucide/icons/coins.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 174
} | 42 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<ellipse cx="12" cy="5" rx="9" ry="3" />
<path d="M3 5V19A9 3 0 0 0 15 21.84" />
<path d="M21 5V8" />
<path d="M21 12L18 17H22L19 22" />
<path d="M3 12A9 3 0 0 0 14.59 14.87" />
</svg>
| lucide-icons/lucide/icons/database-zap.svg | {
"file_path": "lucide-icons/lucide/icons/database-zap.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 194
} | 43 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M12 22c6.23-.05 7.87-5.57 7.5-10-.36-4.34-3.95-9.96-7.5-10-3.55.04-7.14 5.66-7.5 10-.37 4.43 1.27 9.95 7.5 10z" />
</svg>
| lucide-icons/lucide/icons/egg.svg | {
"file_path": "lucide-icons/lucide/icons/egg.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 174
} | 44 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m21 21-6-6m6 6v-4.8m0 4.8h-4.8" />
<path d="M3 16.2V21m0 0h4.8M3 21l6-6" />
<path d="M21 7.8V3m0 0h-4.8M21 3l-6 6" />
<path d="M3 7.8V3m0 0h4.8M3 3l6 6" />
</svg>
| lucide-icons/lucide/icons/expand.svg | {
"file_path": "lucide-icons/lucide/icons/expand.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 211
} | 45 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m10 18 3-3-3-3" />
<path d="M14 2v4a2 2 0 0 0 2 2h4" />
<path d="M4 11V4a2 2 0 0 1 2-2h9l5 5v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h7" />
</svg>
| lucide-icons/lucide/icons/file-symlink.svg | {
"file_path": "lucide-icons/lucide/icons/file-symlink.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 196
} | 46 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M8 2c3 0 5 2 8 2s4-1 4-1v11" />
<path d="M4 22V4" />
<path d="M4 15s1-1 4-1 5 2 8 2" />
<line x1="2" x2="22" y1="2" y2="22" />
</svg>
| lucide-icons/lucide/icons/flag-off.svg | {
"file_path": "lucide-icons/lucide/icons/flag-off.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 178
} | 47 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M10 10 4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-1.272-2.542" />
<path d="M10 2v2.343" />
<path d="M14 2v6.343" />
<path d="M8.5 2h7" />
<path d="M7 16h9" />
<line x1="2" x2="22" y1="2" y2="22" />
</svg>
| lucide-icons/lucide/icons/flask-conical-off.svg | {
"file_path": "lucide-icons/lucide/icons/flask-conical-off.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 228
} | 48 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<line x1="6" x2="10" y1="11" y2="11" />
<line x1="8" x2="8" y1="9" y2="13" />
<line x1="15" x2="15.01" y1="12" y2="12" />
<line x1="18" x2="18.01" y1="10" y2="10" />
<path d="M17.32 5H6.68a4 4 0 0 0-3.978 3.59c-.006.052-.01.101-.017.152C2.604 9.416 2 14.456 2 16a3 3 0 0 0 3 3c1 0 1.5-.5 2-1l1.414-1.414A2 2 0 0 1 9.828 16h4.344a2 2 0 0 1 1.414.586L17 18c.5.5 1 1 2 1a3 3 0 0 0 3-3c0-1.545-.604-6.584-.685-7.258-.007-.05-.011-.1-.017-.151A4 4 0 0 0 17.32 5z" />
</svg>
| lucide-icons/lucide/icons/gamepad-2.svg | {
"file_path": "lucide-icons/lucide/icons/gamepad-2.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 366
} | 49 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="5" cy="6" r="3" />
<path d="M5 9v12" />
<circle cx="19" cy="18" r="3" />
<path d="m15 9-3-3 3-3" />
<path d="M12 6h5a2 2 0 0 1 2 2v7" />
</svg>
| lucide-icons/lucide/icons/git-pull-request-arrow.svg | {
"file_path": "lucide-icons/lucide/icons/git-pull-request-arrow.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 179
} | 50 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M3 7V5c0-1.1.9-2 2-2h2" />
<path d="M17 3h2c1.1 0 2 .9 2 2v2" />
<path d="M21 17v2c0 1.1-.9 2-2 2h-2" />
<path d="M7 21H5c-1.1 0-2-.9-2-2v-2" />
<rect width="7" height="5" x="7" y="7" rx="1" />
<rect width="7" height="5" x="10" y="12" rx="1" />
</svg>
| lucide-icons/lucide/icons/group.svg | {
"file_path": "lucide-icons/lucide/icons/group.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 253
} | 51 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M12 3V2" />
<path d="M5 10a7.1 7.1 0 0 1 14 0" />
<path d="M4 10h16" />
<path d="M2 14h12a2 2 0 1 1 0 4h-2" />
<path d="m15.4 17.4 3.2-2.8a2 2 0 0 1 2.8 2.9l-3.6 3.3c-.7.8-1.7 1.2-2.8 1.2h-4c-1.1 0-2.1-.4-2.8-1.2L5 18" />
<path d="M5 14v7H2" />
</svg>
| lucide-icons/lucide/icons/hand-platter.svg | {
"file_path": "lucide-icons/lucide/icons/hand-platter.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 266
} | 52 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M7 22a5 5 0 0 1-2-4" />
<path d="M7 16.93c.96.43 1.96.74 2.99.91" />
<path d="M3.34 14A6.8 6.8 0 0 1 2 10c0-4.42 4.48-8 10-8s10 3.58 10 8a7.19 7.19 0 0 1-.33 2" />
<path d="M5 18a2 2 0 1 0 0-4 2 2 0 0 0 0 4z" />
<path d="M14.33 22h-.09a.35.35 0 0 1-.24-.32v-10a.34.34 0 0 1 .33-.34c.08 0 .15.03.21.08l7.34 6a.33.33 0 0 1-.21.59h-4.49l-2.57 3.85a.35.35 0 0 1-.28.14z" />
</svg>
| lucide-icons/lucide/icons/lasso-select.svg | {
"file_path": "lucide-icons/lucide/icons/lasso-select.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 325
} | 53 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M6 20a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2" />
<path d="M8 18V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v14" />
<path d="M10 20h4" />
<circle cx="16" cy="20" r="2" />
<circle cx="8" cy="20" r="2" />
</svg>
| lucide-icons/lucide/icons/luggage.svg | {
"file_path": "lucide-icons/lucide/icons/luggage.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 225
} | 54 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M17 17H4a2 2 0 0 1-2-2V5c0-1.5 1-2 1-2" />
<path d="M22 15V5a2 2 0 0 0-2-2H9" />
<path d="M8 21h8" />
<path d="M12 17v4" />
<path d="m2 2 20 20" />
</svg>
| lucide-icons/lucide/icons/monitor-off.svg | {
"file_path": "lucide-icons/lucide/icons/monitor-off.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 192
} | 55 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M8 2v4" />
<path d="M12 2v4" />
<path d="M16 2v4" />
<path d="M16 4h2a2 2 0 0 1 2 2v2" />
<path d="M20 12v2" />
<path d="M20 18v2a2 2 0 0 1-2 2h-1" />
<path d="M13 22h-2" />
<path d="M7 22H6a2 2 0 0 1-2-2v-2" />
<path d="M4 14v-2" />
<path d="M4 8V6a2 2 0 0 1 2-2h2" />
<path d="M8 10h6" />
<path d="M8 14h8" />
<path d="M8 18h5" />
</svg>
| lucide-icons/lucide/icons/notepad-text-dashed.svg | {
"file_path": "lucide-icons/lucide/icons/notepad-text-dashed.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 308
} | 56 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M5.8 11.3 2 22l10.7-3.79" />
<path d="M4 3h.01" />
<path d="M22 8h.01" />
<path d="M15 2h.01" />
<path d="M22 20h.01" />
<path d="m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10" />
<path d="m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17" />
<path d="m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7" />
<path d="M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z" />
</svg>
| lucide-icons/lucide/icons/party-popper.svg | {
"file_path": "lucide-icons/lucide/icons/party-popper.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 419
} | 57 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M18.5 8c-1.4 0-2.6-.8-3.2-2A6.87 6.87 0 0 0 2 9v11a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-8.5C22 9.6 20.4 8 18.5 8" />
<path d="M2 14h20" />
<path d="M6 14v4" />
<path d="M10 14v4" />
<path d="M14 14v4" />
<path d="M18 14v4" />
</svg>
| lucide-icons/lucide/icons/piano.svg | {
"file_path": "lucide-icons/lucide/icons/piano.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 238
} | 58 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M17.8 19.2 16 11l3.5-3.5C21 6 21.5 4 21 3c-1-.5-3 0-4.5 1.5L13 8 4.8 6.2c-.5-.1-.9.1-1.1.5l-.3.5c-.2.5-.1 1 .3 1.3L9 12l-2 3H4l-1 1 3 2 2 3 1-1v-3l3-2 3.5 5.3c.3.4.8.5 1.3.3l.5-.2c.4-.3.6-.7.5-1.2z" />
</svg>
| lucide-icons/lucide/icons/plane.svg | {
"file_path": "lucide-icons/lucide/icons/plane.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 250
} | 59 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M16.466 7.5C15.643 4.237 13.952 2 12 2 9.239 2 7 6.477 7 12s2.239 10 5 10c.342 0 .677-.069 1-.2" />
<path d="m15.194 13.707 3.814 1.86-1.86 3.814" />
<path d="M19 15.57c-1.804.885-4.274 1.43-7 1.43-5.523 0-10-2.239-10-5s4.477-5 10-5c4.838 0 8.873 1.718 9.8 4" />
</svg>
| lucide-icons/lucide/icons/rotate-3d.svg | {
"file_path": "lucide-icons/lucide/icons/rotate-3d.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 251
} | 60 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M3 11v3a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-3" />
<path d="M12 19H4a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1h16a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-3.83" />
<path d="m3 11 7.77-6.04a2 2 0 0 1 2.46 0L21 11H3Z" />
<path d="M12.97 19.77 7 15h12.5l-3.75 4.5a2 2 0 0 1-2.78.27Z" />
</svg>
| lucide-icons/lucide/icons/sandwich.svg | {
"file_path": "lucide-icons/lucide/icons/sandwich.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 263
} | 61 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m12.5 17-.5-1-.5 1h1z" />
<path d="M15 22a1 1 0 0 0 1-1v-1a2 2 0 0 0 1.56-3.25 8 8 0 1 0-11.12 0A2 2 0 0 0 8 20v1a1 1 0 0 0 1 1z" />
<circle cx="15" cy="12" r="1" />
<circle cx="9" cy="12" r="1" />
</svg>
| lucide-icons/lucide/icons/skull.svg | {
"file_path": "lucide-icons/lucide/icons/skull.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 213
} | 62 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M16 3h5v5" />
<path d="M8 3H3v5" />
<path d="M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3" />
<path d="m15 9 6-6" />
</svg>
| lucide-icons/lucide/icons/split.svg | {
"file_path": "lucide-icons/lucide/icons/split.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 169
} | 63 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M15.236 22a3 3 0 0 0-2.2-5" />
<path d="M16 20a3 3 0 0 1 3-3h1a2 2 0 0 0 2-2v-2a4 4 0 0 0-4-4V4" />
<path d="M18 13h.01" />
<path d="M18 6a4 4 0 0 0-4 4 7 7 0 0 0-7 7c0-5 4-5 4-10.5a4.5 4.5 0 1 0-9 0 2.5 2.5 0 0 0 5 0C7 10 3 11 3 17c0 2.8 2.2 5 5 5h10" />
</svg>
| lucide-icons/lucide/icons/squirrel.svg | {
"file_path": "lucide-icons/lucide/icons/squirrel.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 260
} | 64 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M15.5 3H5a2 2 0 0 0-2 2v14c0 1.1.9 2 2 2h14a2 2 0 0 0 2-2V8.5L15.5 3Z" />
<path d="M14 3v4a2 2 0 0 0 2 2h4" />
<path d="M8 13h.01" />
<path d="M16 13h.01" />
<path d="M10 16s.8 1 2 1c1.3 0 2-1 2-1" />
</svg>
| lucide-icons/lucide/icons/sticker.svg | {
"file_path": "lucide-icons/lucide/icons/sticker.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 227
} | 65 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<circle cx="12" cy="12" r="4" />
<path d="M12 3v1" />
<path d="M12 20v1" />
<path d="M3 12h1" />
<path d="M20 12h1" />
<path d="m18.364 5.636-.707.707" />
<path d="m6.343 17.657-.707.707" />
<path d="m5.636 5.636.707.707" />
<path d="m17.657 17.657.707.707" />
</svg>
| lucide-icons/lucide/icons/sun-medium.svg | {
"file_path": "lucide-icons/lucide/icons/sun-medium.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 239
} | 66 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m10 11 11 .9a1 1 0 0 1 .8 1.1l-.665 4.158a1 1 0 0 1-.988.842H20" />
<path d="M16 18h-5" />
<path d="M18 5a1 1 0 0 0-1 1v5.573" />
<path d="M3 4h8.129a1 1 0 0 1 .99.863L13 11.246" />
<path d="M4 11V4" />
<path d="M7 15h.01" />
<path d="M8 10.1V4" />
<circle cx="18" cy="18" r="2" />
<circle cx="7" cy="15" r="5" />
</svg>
| lucide-icons/lucide/icons/tractor.svg | {
"file_path": "lucide-icons/lucide/icons/tractor.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 281
} | 67 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" />
<path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" />
<line x1="8" x2="8" y1="2" y2="5" />
<line x1="2" x2="5" y1="8" y2="8" />
<line x1="16" x2="16" y1="19" y2="22" />
<line x1="19" x2="22" y1="16" y2="16" />
</svg>
| lucide-icons/lucide/icons/unlink.svg | {
"file_path": "lucide-icons/lucide/icons/unlink.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 312
} | 68 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5" />
<rect x="2" y="6" width="14" height="12" rx="2" />
</svg>
| lucide-icons/lucide/icons/video.svg | {
"file_path": "lucide-icons/lucide/icons/video.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 167
} | 69 |
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
>
<path d="M22 8.35V20a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V8.35A2 2 0 0 1 3.26 6.5l8-3.2a2 2 0 0 1 1.48 0l8 3.2A2 2 0 0 1 22 8.35Z" />
<path d="M6 18h12" />
<path d="M6 14h12" />
<rect width="12" height="12" x="6" y="10" />
</svg>
| lucide-icons/lucide/icons/warehouse.svg | {
"file_path": "lucide-icons/lucide/icons/warehouse.svg",
"repo_id": "lucide-icons/lucide",
"token_count": 222
} | 70 |
const defaultAttributes = {
xmlns: 'http://www.w3.org/2000/svg',
width: 24,
height: 24,
viewBox: '0 0 24 24',
fill: 'none',
stroke: 'currentColor',
strokeWidth: 2,
strokeLinecap: 'round',
strokeLinejoin: 'round',
};
export const childDefaultAttributes = {
fill: defaultAttributes.fill,
stroke: defaultAttributes.stroke,
strokeWidth: defaultAttributes.strokeWidth,
strokeLinecap: defaultAttributes.strokeLinecap,
strokeLinejoin: defaultAttributes.strokeLinejoin,
};
export default defaultAttributes;
| lucide-icons/lucide/packages/lucide-react-native/src/defaultAttributes.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-react-native/src/defaultAttributes.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 164
} | 71 |
import path from 'path';
// eslint-disable-next-line import/no-extraneous-dependencies
import getIconMetaData from '@lucide/build-icons/utils/getIconMetaData.mjs';
const ICONS_DIR = path.resolve(process.cwd(), '../../icons');
export default async function getAliasesEntryNames() {
const metaJsonFiles = await getIconMetaData(ICONS_DIR);
const iconWithAliases = Object.values(metaJsonFiles).filter(({ aliases }) => aliases != null);
const aliases = iconWithAliases.flatMap(({ aliases }) => aliases);
return aliases
.map((alias) => (typeof alias === 'string' ? alias : alias.name))
.map((alias) => path.join('src/icons', `${alias}.ts`));
}
| lucide-icons/lucide/packages/lucide-react/scripts/getAliasesEntryNames.mjs | {
"file_path": "lucide-icons/lucide/packages/lucide-react/scripts/getAliasesEntryNames.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 213
} | 72 |
import { expect, afterEach } from 'vitest';
import { cleanup } from '@solidjs/testing-library';
import '@testing-library/jest-dom/vitest';
import htmlSerializer from 'jest-serializer-html';
expect.addSnapshotSerializer(htmlSerializer);
afterEach(() => {
cleanup();
});
| lucide-icons/lucide/packages/lucide-solid/tests/setupVitest.js | {
"file_path": "lucide-icons/lucide/packages/lucide-solid/tests/setupVitest.js",
"repo_id": "lucide-icons/lucide",
"token_count": 90
} | 73 |
import { describe, it, expect } from 'vitest';
import { render } from '@testing-library/vue';
import { airVent } from './testIconNodes';
import { Icon } from '../src/lucide-vue-next';
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-vue-next/tests/Icon.spec.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-vue-next/tests/Icon.spec.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 331
} | 74 |
export * from './icons';
export * as icons from './icons';
export * from './aliases';
| lucide-icons/lucide/packages/lucide-vue/src/lucide-vue.ts | {
"file_path": "lucide-icons/lucide/packages/lucide-vue/src/lucide-vue.ts",
"repo_id": "lucide-icons/lucide",
"token_count": 27
} | 75 |
import fs from 'fs';
import path from 'path';
import { readSvgDirectory, writeSvgFile } from '../tools/build-helpers/helpers.mjs';
import processSvg from './render/processSvg.mjs';
const ICONS_DIR = path.resolve(process.cwd(), 'icons');
console.log(`Optimizing SVGs...`);
const svgFiles = readSvgDirectory(ICONS_DIR);
svgFiles.forEach((svgFile) => {
const content = fs.readFileSync(path.join(ICONS_DIR, svgFile));
processSvg(content, svgFile).then((svg) => writeSvgFile(svgFile, ICONS_DIR, svg));
});
| lucide-icons/lucide/scripts/optimizeSvgs.mjs | {
"file_path": "lucide-icons/lucide/scripts/optimizeSvgs.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 191
} | 76 |
/* eslint-disable import/prefer-default-export */
/**
* djb2 hashing function
*
* @param {string} string
* @param {number} seed
* @returns {string} A hashed string of 6 characters
*/
export const hash = (string, seed = 5381) => {
let i = string.length;
while (i) {
// eslint-disable-next-line no-bitwise, no-plusplus
seed = (seed * 33) ^ string.charCodeAt(--i);
}
// eslint-disable-next-line no-bitwise
return (seed >>> 0).toString(36).substr(0, 6);
};
| lucide-icons/lucide/tools/build-helpers/src/hash.mjs | {
"file_path": "lucide-icons/lucide/tools/build-helpers/src/hash.mjs",
"repo_id": "lucide-icons/lucide",
"token_count": 176
} | 77 |
import { type Change, changes } from "content";
import dayjs from "dayjs";
import { type Metadata } from "next";
function ChangeCard(change: Change) {
return (
<article className="prose prose-slate mb-8 dark:prose-invert">
<h2 className=" mb-0 text-3xl font-semibold tracking-tight transition-colors">
{change.title}
</h2>
<time className=" text-sm text-muted-foreground" dateTime={change.date}>
{dayjs(change.date).format("MMM DD YYYY")}
</time>
<div dangerouslySetInnerHTML={{ __html: change.content }} />
</article>
);
}
export const metadata: Metadata = {
title: "Changelog",
description: "All the latest updates, improvements, and fixes.",
};
export default function Changelog() {
const posts = changes.sort((a, b) =>
dayjs(a.date).isAfter(dayjs(b.date)) ? -1 : 1
);
return (
<div className="container min-h-screen py-8">
<h1 className="text-4xl font-bold tracking-tight lg:text-5xl">
Changelog
</h1>
<p className="mb-10 mt-2.5 text-xl text-muted-foreground">
All the latest updates, improvements, and fixes.
</p>
<div className="space-y-10">
{posts.map((change, idx) => (
<ChangeCard key={idx} {...change} />
))}
</div>
</div>
);
}
| moinulmoin/chadnext/src/app/[locale]/changelog/page.tsx | {
"file_path": "moinulmoin/chadnext/src/app/[locale]/changelog/page.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 545
} | 78 |
import { Skeleton } from "~/components/ui/skeleton";
export default function Loading() {
return <Skeleton className="h-[500px] max-w-2xl rounded-md" />;
}
| moinulmoin/chadnext/src/app/[locale]/dashboard/settings/loading.tsx | {
"file_path": "moinulmoin/chadnext/src/app/[locale]/dashboard/settings/loading.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 55
} | 79 |
import Image from "next/image";
import Link from "next/link";
import { Suspense } from "react";
import { siteConfig } from "~/config/site";
import LocaleToggler from "../shared/locale-toggler";
import ThemeToggle from "../shared/theme-toggle";
export default function Footer() {
return (
<footer className="md:py- relative z-10 w-full border-t py-4">
<div className="container flex items-center justify-between gap-4 md:h-14 md:flex-row">
<div className="flex flex-col items-center gap-4 md:flex-row md:gap-2">
<Image
src="/chad-next.png"
alt="ChadNext logo"
width="24"
height="24"
className="hidden h-6 w-6 rounded-sm object-contain md:inline-block"
/>
<p className="text-center text-sm leading-loose text-muted-foreground md:text-left">
Developed by{" "}
<Link
href={siteConfig().links.twitter}
target="_blank"
rel="noreferrer"
className="font-medium underline underline-offset-4"
>
Moinul Moin
</Link>
</p>
</div>
<div className=" space-x-5">
<Suspense>
<LocaleToggler />
</Suspense>
<ThemeToggle />
</div>
</div>
</footer>
);
}
| moinulmoin/chadnext/src/components/layout/footer.tsx | {
"file_path": "moinulmoin/chadnext/src/components/layout/footer.tsx",
"repo_id": "moinulmoin/chadnext",
"token_count": 662
} | 80 |
Subsets and Splits