diff --git a/README.md b/README.md index 3b0b3f87..554770ec 100644 --- a/README.md +++ b/README.md @@ -139,6 +139,7 @@ export interface CalendarProps { showAdjacentMonths?: boolean sortedMonthView?: boolean showVerticalScrollIndicator?: boolean + timeslots?: number } ``` @@ -204,6 +205,7 @@ export interface CalendarProps { | `showWeekNumber` | no | `boolean` | Show week number. Week number will be shown at top left corner for week/day mode and at start of each row for month mode | | `weekNumberPrefix` | no | `string` | Prefix for week number. For month mode, the prefix will be shown in header row. | | `maxVisibleEventCount` | no | `number` | Maximum number of events to show in a cell in month view. If the number of events exceeds this value, the cell will show the `moreLabel`. Defaults to 3. | +| `timeslots` | no | `number` | Number of timeslots to render per Hour. Default to 0 | | `hourComponent` | no | `HourRenderer` | Custom hour renderer | ## EventRenderer diff --git a/src/components/CalendarBody.tsx b/src/components/CalendarBody.tsx index 9d201cf1..e0573926 100644 --- a/src/components/CalendarBody.tsx +++ b/src/components/CalendarBody.tsx @@ -78,6 +78,7 @@ interface CalendarBodyProps { enrichedEventsByDate?: Record enableEnrichedEvents?: boolean eventsAreSorted?: boolean + timeslots?: number hourComponent?: HourRenderer } @@ -114,6 +115,7 @@ function _CalendarBody({ enrichedEventsByDate, enableEnrichedEvents = false, eventsAreSorted = false, + timeslots = 0, hourComponent, }: CalendarBodyProps) { const scrollView = React.useRef(null) @@ -327,6 +329,7 @@ function _CalendarBody({ index={index} calendarCellStyle={calendarCellStyle} calendarCellAccessibilityProps={calendarCellAccessibilityProps} + timeslots={timeslots} /> ))} {_renderEvents(date)} diff --git a/src/components/CalendarContainer.tsx b/src/components/CalendarContainer.tsx index a9ea7bc3..0e7d6222 100644 --- a/src/components/CalendarContainer.tsx +++ b/src/components/CalendarContainer.tsx @@ -147,6 +147,7 @@ export interface CalendarContainerProps { * Default value is `false`. */ eventsAreSorted?: boolean + timeslots?: number hourComponent?: HourRenderer } @@ -216,6 +217,7 @@ function _CalendarContainer({ enableEnrichedEvents = false, eventsAreSorted = false, onSwipeEnd, + timeslots = 0, hourComponent, }: CalendarContainerProps) { // To ensure we have proper effect callback, use string to date comparision. @@ -451,6 +453,7 @@ function _CalendarContainer({ enrichedEventsByDate={enrichedEventsByDate} enableEnrichedEvents={enableEnrichedEvents} eventsAreSorted={eventsAreSorted} + timeslots={timeslots} hourComponent={hourComponent} /> diff --git a/src/components/HourGuideCell.tsx b/src/components/HourGuideCell.tsx index 010cac21..57adfa3a 100644 --- a/src/components/HourGuideCell.tsx +++ b/src/components/HourGuideCell.tsx @@ -15,6 +15,7 @@ interface HourGuideCellProps { index: number calendarCellStyle?: CalendarCellStyle calendarCellAccessibilityProps?: AccessibilityProps + timeslots: number } const _HourGuideCell = ({ @@ -26,6 +27,7 @@ const _HourGuideCell = ({ index, calendarCellStyle, calendarCellAccessibilityProps, + timeslots, }: HourGuideCellProps) => { const theme = useTheme() @@ -44,11 +46,28 @@ const _HourGuideCell = ({ style={[ u['border-l'], u['border-b'], - { borderColor: theme.palette.gray['200'] }, - { height: cellHeight }, + { + borderColor: theme.palette.gray['200'], + height: cellHeight, + justifyContent: 'space-evenly', + }, { ...getCalendarCellStyle(date.toDate(), index) }, ]} - /> + > + {Array.from({ length: timeslots }, (_, index) => ( + + ))} + ) } diff --git a/stories/desktop.stories.tsx b/stories/desktop.stories.tsx index 1d0a2e19..b998d9a4 100644 --- a/stories/desktop.stories.tsx +++ b/stories/desktop.stories.tsx @@ -248,6 +248,11 @@ storiesOf('showcase - Desktop', module) )) + .add('With timeslots', () => ( + + + + )) .add('RTL', () => { React.useEffect(() => { require('dayjs/locale/he')