Skip to content

Commit a9bc6e9

Browse files
committed
fix: calendar theme
1 parent 645ccb4 commit a9bc6e9

File tree

8 files changed

+527
-512
lines changed

8 files changed

+527
-512
lines changed

components.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://ui.shadcn.com/schema.json",
3-
"style": "default",
3+
"style": "new-york-v4",
44
"rsc": true,
55
"tsx": true,
66
"tailwind": {

components/borrows/FormEditBorrow.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const FormSchema = z.object({
3333
returning: z
3434
.object({
3535
returned_at: z.string(),
36-
fine: z.number().nonnegative(),
36+
fine: z.coerce.number<number>().nonnegative(),
3737
})
3838
.optional(),
3939
})
@@ -103,6 +103,7 @@ export const FormEditBorrow: React.FC<{
103103
date > new Date(form.getValues('due_at')) ||
104104
date < new Date('1900-01-01')
105105
}
106+
captionLayout="dropdown"
106107
autoFocus
107108
/>
108109
<Input
@@ -163,6 +164,7 @@ export const FormEditBorrow: React.FC<{
163164
disabled={(date) =>
164165
date < new Date(form.getValues('borrowed_at'))
165166
}
167+
captionLayout="dropdown"
166168
autoFocus
167169
/>
168170
<TimeInput value={field.value} onChange={field.onChange} />
@@ -210,6 +212,7 @@ export const FormEditBorrow: React.FC<{
210212
disabled={(date) =>
211213
date < new Date(form.getValues('borrowed_at'))
212214
}
215+
captionLayout="dropdown"
213216
autoFocus
214217
/>
215218
<TimeInput

components/ui/button.tsx

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@ import { cva, type VariantProps } from 'class-variance-authority'
55
import { cn } from '@/lib/utils'
66

77
const buttonVariants = cva(
8-
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0',
8+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
99
{
1010
variants: {
1111
variant: {
12-
default: 'bg-primary text-primary-foreground hover:bg-primary/90',
12+
default:
13+
'bg-primary text-primary-foreground shadow-xs hover:bg-primary/90',
1314
destructive:
14-
'bg-destructive text-destructive-foreground hover:bg-destructive/90',
15+
'bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40 dark:bg-destructive/60',
1516
outline:
16-
'border border-input bg-background hover:bg-accent hover:text-accent-foreground',
17+
'border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50',
1718
secondary:
18-
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
19-
ghost: 'hover:bg-accent hover:text-accent-foreground',
19+
'bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80',
20+
ghost:
21+
'hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50',
2022
link: 'text-primary underline-offset-4 hover:underline',
2123
},
2224
size: {
23-
default: 'h-10 px-4 py-2',
24-
sm: 'h-9 rounded-md px-3',
25-
lg: 'h-11 rounded-md px-8',
26-
icon: 'h-10 w-10',
25+
default: 'h-9 px-4 py-2 has-[>svg]:px-3',
26+
sm: 'h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5',
27+
lg: 'h-10 rounded-md px-6 has-[>svg]:px-4',
28+
icon: 'size-9',
2729
},
2830
},
2931
defaultVariants: {
@@ -33,24 +35,25 @@ const buttonVariants = cva(
3335
}
3436
)
3537

36-
export interface ButtonProps
37-
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
38-
VariantProps<typeof buttonVariants> {
39-
asChild?: boolean
40-
}
38+
function Button({
39+
className,
40+
variant,
41+
size,
42+
asChild = false,
43+
...props
44+
}: React.ComponentProps<'button'> &
45+
VariantProps<typeof buttonVariants> & {
46+
asChild?: boolean
47+
}) {
48+
const Comp = asChild ? Slot : 'button'
4149

42-
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
43-
({ className, variant, size, asChild = false, ...props }, ref) => {
44-
const Comp = asChild ? Slot : 'button'
45-
return (
46-
<Comp
47-
className={cn(buttonVariants({ variant, size, className }))}
48-
ref={ref}
49-
{...props}
50-
/>
51-
)
52-
}
53-
)
54-
Button.displayName = 'Button'
50+
return (
51+
<Comp
52+
data-slot="button"
53+
className={cn(buttonVariants({ variant, size, className }))}
54+
{...props}
55+
/>
56+
)
57+
}
5558

5659
export { Button, buttonVariants }

components/ui/calendar.tsx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function Calendar({
2929
<DayPicker
3030
showOutsideDays={showOutsideDays}
3131
className={cn(
32-
'bg-background group/calendar p-3 [--cell-size:2rem] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
32+
'bg-background group/calendar p-3 [--cell-size:--spacing(8)] [[data-slot=card-content]_&]:bg-transparent [[data-slot=popover-content]_&]:bg-transparent',
3333
String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,
3434
String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,
3535
className
@@ -43,72 +43,72 @@ function Calendar({
4343
classNames={{
4444
root: cn('w-fit', defaultClassNames.root),
4545
months: cn(
46-
'relative flex flex-col gap-4 md:flex-row',
46+
'flex gap-4 flex-col md:flex-row relative',
4747
defaultClassNames.months
4848
),
49-
month: cn('flex w-full flex-col gap-4', defaultClassNames.month),
49+
month: cn('flex flex-col w-full gap-4', defaultClassNames.month),
5050
nav: cn(
51-
'absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1',
51+
'flex items-center gap-1 w-full absolute top-0 inset-x-0 justify-between',
5252
defaultClassNames.nav
5353
),
5454
button_previous: cn(
5555
buttonVariants({ variant: buttonVariant }),
56-
'h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50',
56+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
5757
defaultClassNames.button_previous
5858
),
5959
button_next: cn(
6060
buttonVariants({ variant: buttonVariant }),
61-
'h-[--cell-size] w-[--cell-size] select-none p-0 aria-disabled:opacity-50',
61+
'size-(--cell-size) aria-disabled:opacity-50 p-0 select-none',
6262
defaultClassNames.button_next
6363
),
6464
month_caption: cn(
65-
'flex h-[--cell-size] w-full items-center justify-center px-[--cell-size]',
65+
'flex items-center justify-center h-(--cell-size) w-full px-(--cell-size)',
6666
defaultClassNames.month_caption
6767
),
6868
dropdowns: cn(
69-
'flex h-[--cell-size] w-full items-center justify-center gap-1.5 text-sm font-medium',
69+
'w-full flex items-center text-sm font-medium justify-center h-(--cell-size) gap-1.5',
7070
defaultClassNames.dropdowns
7171
),
7272
dropdown_root: cn(
73-
'has-focus:border-ring border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] relative rounded-md border',
73+
'relative has-focus:border-ring border border-input shadow-xs has-focus:ring-ring/50 has-focus:ring-[3px] rounded-md',
7474
defaultClassNames.dropdown_root
7575
),
7676
dropdown: cn(
77-
'bg-popover absolute inset-0 opacity-0',
77+
'absolute bg-popover inset-0 opacity-0',
7878
defaultClassNames.dropdown
7979
),
8080
caption_label: cn(
8181
'select-none font-medium',
8282
captionLayout === 'label'
8383
? 'text-sm'
84-
: '[&>svg]:text-muted-foreground flex h-8 items-center gap-1 rounded-md pl-2 pr-1 text-sm [&>svg]:size-3.5',
84+
: 'rounded-md pl-2 pr-1 flex items-center gap-1 text-sm h-8 [&>svg]:text-muted-foreground [&>svg]:size-3.5',
8585
defaultClassNames.caption_label
8686
),
8787
table: 'w-full border-collapse',
8888
weekdays: cn('flex', defaultClassNames.weekdays),
8989
weekday: cn(
90-
'text-muted-foreground flex-1 select-none rounded-md text-[0.8rem] font-normal',
90+
'text-muted-foreground rounded-md flex-1 font-normal text-[0.8rem] select-none',
9191
defaultClassNames.weekday
9292
),
93-
week: cn('mt-2 flex w-full', defaultClassNames.week),
93+
week: cn('flex w-full mt-2', defaultClassNames.week),
9494
week_number_header: cn(
95-
'w-[--cell-size] select-none',
95+
'select-none w-(--cell-size)',
9696
defaultClassNames.week_number_header
9797
),
9898
week_number: cn(
99-
'text-muted-foreground select-none text-[0.8rem]',
99+
'text-[0.8rem] select-none text-muted-foreground',
100100
defaultClassNames.week_number
101101
),
102102
day: cn(
103-
'group/day relative aspect-square h-full w-full select-none p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md',
103+
'relative w-full h-full p-0 text-center [&:first-child[data-selected=true]_button]:rounded-l-md [&:last-child[data-selected=true]_button]:rounded-r-md group/day aspect-square select-none',
104104
defaultClassNames.day
105105
),
106106
range_start: cn(
107-
'bg-accent rounded-l-md',
107+
'rounded-l-md bg-accent',
108108
defaultClassNames.range_start
109109
),
110110
range_middle: cn('rounded-none', defaultClassNames.range_middle),
111-
range_end: cn('bg-accent rounded-r-md', defaultClassNames.range_end),
111+
range_end: cn('rounded-r-md bg-accent', defaultClassNames.range_end),
112112
today: cn(
113113
'bg-accent text-accent-foreground rounded-md data-[selected=true]:rounded-none',
114114
defaultClassNames.today
@@ -159,7 +159,7 @@ function Calendar({
159159
WeekNumber: ({ children, ...props }) => {
160160
return (
161161
<td {...props}>
162-
<div className="flex size-[--cell-size] items-center justify-center text-center">
162+
<div className="flex size-(--cell-size) items-center justify-center text-center">
163163
{children}
164164
</div>
165165
</td>
@@ -201,7 +201,7 @@ function CalendarDayButton({
201201
data-range-end={modifiers.range_end}
202202
data-range-middle={modifiers.range_middle}
203203
className={cn(
204-
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 flex aspect-square h-auto w-full min-w-[--cell-size] flex-col gap-1 font-normal leading-none data-[range-end=true]:rounded-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] [&>span]:text-xs [&>span]:opacity-70',
204+
'data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground data-[range-middle=true]:bg-accent data-[range-middle=true]:text-accent-foreground data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-ring/50 dark:hover:text-accent-foreground flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:ring-[3px] data-[range-end=true]:rounded-md data-[range-end=true]:rounded-r-md data-[range-middle=true]:rounded-none data-[range-start=true]:rounded-md data-[range-start=true]:rounded-l-md [&>span]:text-xs [&>span]:opacity-70',
205205
defaultClassNames.day,
206206
className
207207
)}

0 commit comments

Comments
 (0)