-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
client: add date, calender, Skeleton and Seperator components
- Loading branch information
Showing
14 changed files
with
319 additions
and
2,554 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import * as SeparatorPrimitive from '@radix-ui/react-separator'; | ||
|
||
import { cn } from '@/lib'; | ||
|
||
export const Separator = React.forwardRef< | ||
React.ElementRef<typeof SeparatorPrimitive.Root>, | ||
React.ComponentPropsWithoutRef<typeof SeparatorPrimitive.Root> | ||
>(({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => ( | ||
<SeparatorPrimitive.Root | ||
ref={ref} | ||
decorative={decorative} | ||
orientation={orientation} | ||
className={cn('shrink-0 bg-border', orientation === 'horizontal' ? 'h-[1px] w-full' : 'h-full w-[1px]', className)} | ||
{...props} | ||
/> | ||
)); | ||
Separator.displayName = SeparatorPrimitive.Root.displayName; |
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,5 @@ | ||
import { cn } from '@/lib'; | ||
|
||
export function Skeleton({ className, ...props }: React.HTMLAttributes<HTMLDivElement>) { | ||
return <div className={cn('animate-pulse rounded-md bg-muted', className)} {...props} />; | ||
} |
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,67 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import { DayPicker } from 'react-day-picker'; | ||
|
||
import { cn } from '@/lib'; | ||
import { FaAngleLeft, FaAngleRight } from 'react-icons/fa'; | ||
|
||
export type CalendarProps = React.ComponentProps<typeof DayPicker>; | ||
|
||
function Calendar({ className, classNames, showOutsideDays = true, ...props }: CalendarProps) { | ||
function buttonVariants(arg0: { variant: string }): any { | ||
throw new Error('Function not implemented.'); | ||
} | ||
|
||
return ( | ||
<DayPicker | ||
showOutsideDays={showOutsideDays} | ||
className={cn('p-3', className)} | ||
classNames={{ | ||
months: 'flex flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0', | ||
month: 'space-y-4', | ||
caption: 'flex justify-center pt-1 relative items-center', | ||
caption_label: 'text-sm font-medium', | ||
nav: 'space-x-1 flex items-center', | ||
nav_button: cn( | ||
buttonVariants({ variant: 'outline' }), | ||
'h-7 w-7 bg-transparent p-0 opacity-50 hover:opacity-100' | ||
), | ||
nav_button_previous: 'absolute left-1', | ||
nav_button_next: 'absolute right-1', | ||
table: 'w-full border-collapse space-y-1', | ||
head_row: 'flex', | ||
head_cell: 'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem]', | ||
row: 'flex w-full mt-2', | ||
cell: cn( | ||
'relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected])]:bg-accent [&:has([aria-selected].day-outside)]:bg-accent/50 [&:has([aria-selected].day-range-end)]:rounded-r-md', | ||
props.mode === 'range' | ||
? '[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md' | ||
: '[&:has([aria-selected])]:rounded-md' | ||
), | ||
day: cn(buttonVariants({ variant: 'ghost' }), 'h-8 w-8 p-0 font-normal aria-selected:opacity-100'), | ||
day_range_start: 'day-range-start', | ||
day_range_end: 'day-range-end', | ||
day_selected: | ||
'bg-primary text-primary-foreground hover:bg-primary hover:text-primary-foreground focus:bg-primary focus:text-primary-foreground', | ||
day_today: 'bg-accent text-accent-foreground', | ||
day_outside: | ||
'day-outside text-muted-foreground opacity-50 aria-selected:bg-accent/50 aria-selected:text-muted-foreground aria-selected:opacity-30', | ||
day_disabled: 'text-muted-foreground opacity-50', | ||
day_range_middle: 'aria-selected:bg-accent aria-selected:text-accent-foreground', | ||
day_hidden: 'invisible', | ||
...classNames, | ||
}} | ||
components={ | ||
{ | ||
// IconLeft: ({ ...props }) => <FaAngleLeft className="h-4 w-4" />, | ||
// IconRight: ({ ...props }) => <FaAngleRight className="h-4 w-4" />, | ||
} | ||
} | ||
{...props} | ||
/> | ||
); | ||
} | ||
Calendar.displayName = 'Calendar'; | ||
|
||
export { 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 * as React from 'react'; | ||
import { format } from 'date-fns'; | ||
import { SlCalender } from 'react-icons/sl'; | ||
|
||
import { cn } from '@/lib'; | ||
import { Calendar } from './Calender'; | ||
import { Popover, PopoverContent, PopoverTrigger } from './PopOver'; | ||
import { AppButton } from '../forms'; | ||
|
||
export function DatePickerDemo() { | ||
const [date, setDate] = React.useState<Date>(); | ||
|
||
return ( | ||
<Popover> | ||
<PopoverTrigger asChild> | ||
<AppButton | ||
variant={'outline'} | ||
className={cn('w-[280px] justify-start text-left font-normal', !date && 'text-muted-foreground')} | ||
> | ||
<SlCalender className="mr-2 h-4 w-4" /> | ||
{date ? format(date, 'PPP') : <span>Pick a date</span>} | ||
</AppButton> | ||
</PopoverTrigger> | ||
<PopoverContent className="w-auto p-0"> | ||
<Calendar mode="single" selected={date} onSelect={setDate} /> | ||
{/* <Calendar mode="single" selected={date} onSelect={setDate} initialFocus /> */} | ||
</PopoverContent> | ||
</Popover> | ||
); | ||
} |
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,33 @@ | ||
'use client'; | ||
|
||
import * as React from 'react'; | ||
import * as PopoverPrimitive from '@radix-ui/react-popover'; | ||
|
||
import { cn } from '@/lib'; | ||
|
||
const Popover = PopoverPrimitive.Root; | ||
|
||
const PopoverTrigger = PopoverPrimitive.Trigger; | ||
|
||
const PopoverAnchor = PopoverPrimitive.Anchor; | ||
|
||
const PopoverContent = React.forwardRef< | ||
React.ElementRef<typeof PopoverPrimitive.Content>, | ||
React.ComponentPropsWithoutRef<typeof PopoverPrimitive.Content> | ||
>(({ className, align = 'center', sideOffset = 4, ...props }, ref) => ( | ||
<PopoverPrimitive.Portal> | ||
<PopoverPrimitive.Content | ||
ref={ref} | ||
align={align} | ||
sideOffset={sideOffset} | ||
className={cn( | ||
'z-50 w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2', | ||
className | ||
)} | ||
{...props} | ||
/> | ||
</PopoverPrimitive.Portal> | ||
)); | ||
PopoverContent.displayName = PopoverPrimitive.Content.displayName; | ||
|
||
export { Popover, PopoverTrigger, PopoverContent, PopoverAnchor }; |
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 |
---|---|---|
|
@@ -18,3 +18,4 @@ export default function PageError() { | |
</div> | ||
); | ||
} | ||
|
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.