0.0.12 • Published 9 months ago

react-weekview v0.0.12

Weekly downloads
-
License
-
Repository
github
Last release
9 months ago

React WeekView

A React component and hook for creating week view calendars.

You can use the useWeekView hooks for creating a fully customized week calendar or use the WeekView component.

Demo: react-weekview.vercel.app

Quick Features

  • Headless hook for building customized designs
  • Prestyled and customizable component
  • Minimal dependency (only date-fns)
  • Simple, not bloated

Example

# npm
npm install react-weekview

# yarn
yarn add react-weekview
// use the hook and build the design yourself
const { days, nextWeek, previousWeek, goToToday, viewTitle } = useWeekView({
  disabledCell(date) {
    return isBefore(date, new Date());
  },
  disabledWeek(startDayOfWeek) {
    return isBefore(startDayOfWeek, startOfWeek(new Date()));
  },
});

// or use the component
<WeekView />;

useWeekView

Props

proptypedefaultdescription
initialDate?Datenew Date()Initial date to start from
minuteStep?number30How many minutes should there be between the generated cells
weekStartsOn0 \| 1 \| 2 \| 3 \| 4 \| 5 \| 61the index of the first day of the week (0 - Sunday)
localedate-fns Localedate-fns defaultA locale object
disabledCell?(date: Date) => boolean-A function for determining the cells that cannot be selected
disabledDay?(date: Date) => boolean-A function for determining the days that cannot be selected
disabledWeek?(startDayOfWeek: Date) => boolean-A function for determining the weeks that cannot be viewed

Returns

fieldtypedescription
daysDaysAn array of days and hours for the active week
weekNumberstringWeek number of the active week
viewTitlestringMonth and year of the active week
nextWeek() => voidGo to next week
previousWeek() => voidGo to previous week
goToToday() => voidGo to current week

<WeekView />

Props

...useWeekView props | prop | type | default | description | | :------------- | :------------------------------------------------------------ | :----------------- | :----------------------------------------------------------- | | events | ?Event[] | - | Event list to display on the calendar | | onCellClick | ?(cell: Cell) => void | - | Cell click callback | | onEventClick | ?(evet: Event) => void | - | Event click callback |

0.0.12

9 months ago

0.0.11

9 months ago

0.0.10

9 months ago

0.0.9

9 months ago

0.0.8

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4

9 months ago

0.0.3

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago