Skip to content

Commit

Permalink
add calendar dropdow to calendar view controls
Browse files Browse the repository at this point in the history
  • Loading branch information
vassbence committed Oct 18, 2024
1 parent d1b4350 commit 1d48119
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
17 changes: 10 additions & 7 deletions src/components/Calendar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { IconButton } from '../IconButton/index.js'
import { Field, getTitleField } from '../../utils/common.js'
import { CalendarItem } from './CalendarItem.js'
import { ScrollArea } from '../ScrollArea/index.js'
import { CalendarDropdown } from '../DateInput/index.js'

type CalendarVariant = 'monthly' | 'weekly' | '2-weekly'

Expand Down Expand Up @@ -569,13 +570,15 @@ function CalendarControls({
)
}}
/>
<Button variant="ghost">
{variant === 'monthly' && format(value, 'MMMM yyyy')}
{variant === '2-weekly' &&
`${format(startOfWeek(value, { weekStartsOn: 1 }), 'MMM d yyyy')} - ${format(addDays(startOfWeek(value, { weekStartsOn: 1 }), 13), 'MMM d yyyy')}`}
{variant === 'weekly' &&
`${format(startOfWeek(value, { weekStartsOn: 1 }), 'MMM d yyyy')} - ${format(addDays(startOfWeek(value, { weekStartsOn: 1 }), 6), 'MMM d yyyy')}`}
</Button>
<CalendarDropdown value={value} onChange={onChange} variant="date">
<Button variant="ghost">
{variant === 'monthly' && format(value, 'MMMM yyyy')}
{variant === '2-weekly' &&
`${format(startOfWeek(value, { weekStartsOn: 1 }), 'MMM d yyyy')} - ${format(addDays(startOfWeek(value, { weekStartsOn: 1 }), 13), 'MMM d yyyy')}`}
{variant === 'weekly' &&
`${format(startOfWeek(value, { weekStartsOn: 1 }), 'MMM d yyyy')} - ${format(addDays(startOfWeek(value, { weekStartsOn: 1 }), 6), 'MMM d yyyy')}`}
</Button>
</CalendarDropdown>
<IconButton
icon="arrow-right"
onClick={() => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/DateInput/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ function Calendar({
<div
ref={refs.setFloating}
style={{
zIndex: 2,
zIndex: 4,
position: 'relative',
width: 240,
borderRadius: radius[16],
Expand Down
2 changes: 1 addition & 1 deletion src/components/DateInput/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ function DateInput({
)
}

export { DateInput }
export { DateInput, Calendar as CalendarDropdown }
export type { DateInputProps }

0 comments on commit 1d48119

Please sign in to comment.