-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@0.4.1: Requested primitives added (#10)
See linked issue for a complete list and comments
- Loading branch information
1 parent
9a0a7d7
commit 053acb9
Showing
17 changed files
with
1,439 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use client' | ||
import React from 'react' | ||
import * as AvatarPrimitive from '@radix-ui/react-avatar' | ||
|
||
import { cn } from '../util' | ||
|
||
const Avatar = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
'relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
Avatar.displayName = AvatarPrimitive.Root.displayName | ||
|
||
const AvatarImage = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Image>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Image> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Image | ||
ref={ref} | ||
className={cn('aspect-square h-full w-full', className)} | ||
{...props} | ||
/> | ||
)) | ||
AvatarImage.displayName = AvatarPrimitive.Image.displayName | ||
|
||
const AvatarFallback = React.forwardRef< | ||
React.ElementRef<typeof AvatarPrimitive.Fallback>, | ||
React.ComponentPropsWithoutRef<typeof AvatarPrimitive.Fallback> | ||
>(({ className, ...props }, ref) => ( | ||
<AvatarPrimitive.Fallback | ||
ref={ref} | ||
className={cn( | ||
'flex h-full w-full items-center justify-center rounded-full bg-muted', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
AvatarFallback.displayName = AvatarPrimitive.Fallback.displayName | ||
|
||
export { Avatar, AvatarImage, AvatarFallback } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
"use client" | ||
import React from "react" | ||
|
||
import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons" | ||
import { DayPicker } from "react-day-picker" | ||
|
||
import { cn } from "../util" | ||
import { buttonVariants } from "./button" | ||
|
||
export type CalendarProps = React.ComponentProps<typeof DayPicker> | ||
|
||
function Calendar({ | ||
className, | ||
classNames, | ||
showOutsideDays = true, | ||
...props | ||
}: CalendarProps) { | ||
return ( | ||
<DayPicker | ||
showOutsideDays={showOutsideDays} | ||
className={cn("p-3", className)} | ||
classNames={{ | ||
months: "flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0", | ||
month: "space-y-4", | ||
caption: "flex justify-center pt-1 relative items-center", | ||
caption_label: "text-sm font-medium", | ||
nav: "space-x-1 flex items-center", | ||
nav_button: cn( | ||
buttonVariants({ variant: "outline" }), | ||
"h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100" | ||
), | ||
nav_button_previous: "absolute left-1", | ||
nav_button_next: "absolute right-1", | ||
table: "w-full border-collapse space-y-1", | ||
head_row: "flex", | ||
head_cell: | ||
"text-muted-1 rounded-md w-8 font-normal text-[0.8rem]", | ||
row: "flex w-full mt-2", | ||
cell: cn( | ||
"relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-level-1 [&:has([aria-selected].day-outside)]:bg-level-1/50 [&:has([aria-selected].day-range-end)]:rounded-r-md", | ||
props.mode === "range" | ||
? "[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md" | ||
: "[&:has([aria-selected])]:rounded-md" | ||
), | ||
day: cn( | ||
buttonVariants({ variant: "ghost" }), | ||
"h-8 w-8 p-0 font-normal aria-selected:opacity-100" | ||
), | ||
day_range_start: "day-range-start", | ||
day_range_end: "day-range-end", | ||
day_selected: | ||
"bg-primary text-primary-fg hover:bg-primary hover:text-primary-fg focus:bg-primary focus:text-primary-fg", | ||
day_today: "bg-accent text-primary-fg", | ||
day_outside: | ||
"day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-1 aria-selected:opacity-30", | ||
day_disabled: "text-muted-foreground opacity-50", | ||
day_range_middle: | ||
"aria-selected:bg-accent aria-selected:text-primary-fg", | ||
day_hidden: "invisible", | ||
...classNames, | ||
}} | ||
components={{ | ||
IconLeft: ({ ...props }) => <ChevronLeftIcon className="h-4 w-4" />, | ||
IconRight: ({ ...props }) => <ChevronRightIcon className="h-4 w-4" />, | ||
}} | ||
{...props} | ||
/> | ||
) | ||
} | ||
Calendar.displayName = "Calendar" | ||
|
||
export default Calendar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
'use client' | ||
import React from 'react' | ||
import * as CheckboxPrimitive from '@radix-ui/react-checkbox' | ||
import { Check } from 'lucide-react' | ||
|
||
import { cn } from '../util' | ||
|
||
const Checkbox = React.forwardRef< | ||
React.ElementRef<typeof CheckboxPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> | ||
>(({ className, ...props }, ref) => ( | ||
<CheckboxPrimitive.Root | ||
ref={ref} | ||
className={cn( | ||
'peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background ' + | ||
'focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring ' + | ||
'focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 ' + | ||
'data-[state=checked]:bg-primary data-[state=checked]:text-primary-fg', | ||
className | ||
)} | ||
{...props} | ||
> | ||
<CheckboxPrimitive.Indicator | ||
className={cn('flex items-center justify-center text-current')} | ||
> | ||
<Check className='h-4 w-4' /> | ||
</CheckboxPrimitive.Indicator> | ||
</CheckboxPrimitive.Root> | ||
)) | ||
Checkbox.displayName = CheckboxPrimitive.Root.displayName | ||
|
||
export default Checkbox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
"use client" | ||
import React from "react" | ||
|
||
import { type DialogProps } from "@radix-ui/react-dialog" | ||
import { Command as CommandPrimitive } from "cmdk" | ||
import { Search } from "lucide-react" | ||
|
||
import { cn } from "../util" | ||
import { Dialog, DialogContent } from "./dialog" | ||
|
||
const Command = React.forwardRef< | ||
React.ElementRef<typeof CommandPrimitive>, | ||
React.ComponentPropsWithoutRef<typeof CommandPrimitive> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive | ||
ref={ref} | ||
className={cn( | ||
"flex h-full w-full flex-col overflow-hidden rounded-md bg-level-1 text-foreground", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
Command.displayName = CommandPrimitive.displayName | ||
|
||
interface CommandDialogProps extends DialogProps {} | ||
|
||
const CommandDialog = ({ children, ...props }: CommandDialogProps) => { | ||
return ( | ||
<Dialog {...props}> | ||
<DialogContent className="overflow-hidden p-0 shadow-lg"> | ||
<Command className="[&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-1 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-group]]:px-2 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5"> | ||
{children} | ||
</Command> | ||
</DialogContent> | ||
</Dialog> | ||
) | ||
} | ||
|
||
const CommandInput = React.forwardRef< | ||
React.ElementRef<typeof CommandPrimitive.Input>, | ||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Input> | ||
>(({ className, ...props }, ref) => ( | ||
<div className="flex items-center border-b px-3" cmdk-input-wrapper=""> | ||
<Search className="mr-2 h-4 w-4 shrink-0 opacity-50" /> | ||
<CommandPrimitive.Input | ||
ref={ref} | ||
className={cn( | ||
"flex h-11 w-full rounded-md bg-transparent py-3 text-sm outline-none placeholder:text-muted-2 disabled:cursor-not-allowed disabled:opacity-50", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
</div> | ||
)) | ||
|
||
CommandInput.displayName = CommandPrimitive.Input.displayName | ||
|
||
const CommandList = React.forwardRef< | ||
React.ElementRef<typeof CommandPrimitive.List>, | ||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.List> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.List | ||
ref={ref} | ||
className={cn("max-h-[300px] overflow-y-auto overflow-x-hidden", className)} | ||
{...props} | ||
/> | ||
)) | ||
|
||
CommandList.displayName = CommandPrimitive.List.displayName | ||
|
||
const CommandEmpty = React.forwardRef< | ||
React.ElementRef<typeof CommandPrimitive.Empty>, | ||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Empty> | ||
>((props, ref) => ( | ||
<CommandPrimitive.Empty | ||
ref={ref} | ||
className="py-6 text-center text-sm" | ||
{...props} | ||
/> | ||
)) | ||
|
||
CommandEmpty.displayName = CommandPrimitive.Empty.displayName | ||
|
||
const CommandGroup = React.forwardRef< | ||
React.ElementRef<typeof CommandPrimitive.Group>, | ||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Group> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.Group | ||
ref={ref} | ||
className={cn( | ||
"overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
|
||
CommandGroup.displayName = CommandPrimitive.Group.displayName | ||
|
||
const CommandSeparator = React.forwardRef< | ||
React.ElementRef<typeof CommandPrimitive.Separator>, | ||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Separator> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.Separator | ||
ref={ref} | ||
className={cn("-mx-1 h-px bg-border", className)} | ||
{...props} | ||
/> | ||
)) | ||
CommandSeparator.displayName = CommandPrimitive.Separator.displayName | ||
|
||
const CommandItem = React.forwardRef< | ||
React.ElementRef<typeof CommandPrimitive.Item>, | ||
React.ComponentPropsWithoutRef<typeof CommandPrimitive.Item> | ||
>(({ className, ...props }, ref) => ( | ||
<CommandPrimitive.Item | ||
ref={ref} | ||
className={cn( | ||
"relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
)) | ||
|
||
CommandItem.displayName = CommandPrimitive.Item.displayName | ||
|
||
const CommandShortcut = ({ | ||
className, | ||
...props | ||
}: React.HTMLAttributes<HTMLSpanElement>) => { | ||
return ( | ||
<span | ||
className={cn( | ||
"ml-auto text-xs tracking-widest text-muted-foreground", | ||
className | ||
)} | ||
{...props} | ||
/> | ||
) | ||
} | ||
CommandShortcut.displayName = "CommandShortcut" | ||
|
||
export { | ||
Command, | ||
CommandDialog, | ||
CommandInput, | ||
CommandList, | ||
CommandEmpty, | ||
CommandGroup, | ||
CommandItem, | ||
CommandShortcut, | ||
CommandSeparator, | ||
} |
Oops, something went wrong.