1.1.0 • Published 7 months ago

react-native-weekly-view v1.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

react-native-weekly-view

Calendars made simple!

npm.io npm.io npm.io preview

Device mockups created at deviceframes.

Installation

Use npm or yarn.

npm install react-native-weekly-view
yarn add react-native-weekly-view

Usage

Import WeeklyView and add some events.

import { WeeklyView } from "react-native-weekly-view";

<WeeklyView
  events={EVENTS}
  onEventPress={(event) => {
    // Do something with the calendar event.
  }}
/>

The events should be formatted in the following way. Please check types at the bottom for more details.

const EVENTS = [
  {
    id: 1,
    isoStart: "2023-06-23T07:00:00.000+03:00",
    isoEnd: "2023-06-23T08:00:00.000+03:00",
    name: "Breakfast",
    icon: <Icon name={"food"} size={14} />,
    disabled: true,
  },
  {
    id: 2,
    isoStart: "2023-06-23T08:30:00.000+03:00",
    isoEnd: "2023-06-23T09:00:00.000+03:00",
    name: "Lunch",
    color: "pink",
    icon: <Icon name={"food"} size={14} />,
    disabled: false,
  }, ...]

Customization

WeeklyView is highly customizable and allows you to change colors, font sizes and much more through the following props:

  locale,
  timezone,
  theme,
  eventContainerStyle,
  style,
  timetableStartHour,
  timetableEndHour,
  intervalLengthMinutes,
  intervalHeight,
  translationWeek,
  showWeekend

Please check props below for more information. preview

Device mockup created at deviceframes.

Example

To run the example, clone the project git clone https://github.com/emilje/react-native-weekly-view.git, navigate into the example folder cd example and run npm i. If you want to run the project using Expo, also install expo npm i expo and when the installation is finished run npx expo start.

Development (Expo + Typescript)

Fork the project and install dependancies npm i. Create a new branch. In package.json switch the "main" to "node_modules/expo/AppEntry.js". Run npm start and have fun! Remember to change main field back to "dist/index.js" before making any pull requests. 👀

Props

NameTypeDescriptionRequired
eventsarrayAn array of calendarEvent objects. Check the types below.Yes
localestringIana subtag of a language - en, fi, hr, sv. Used to translate weekdays in the header. For more information: https://www.iana.org/assignments/language-subtag-registry/language-subtag-registryNo
onEventPressfunctionA callback function that has access to a clicked calendar event. (event) => { Do something cool here! }Yes
timezonestringIana timezone identifier - Europe/Helsinki for example.. You can see a list of the codes here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zonesNo
themestringYou can choose one of the premade themes "light" or "dark" and then customize them if needed. Defaults to dark themeNo
timetableStartHournumberAt which hour the timetable starts.No
timetableEndHournumberAt which hour the timetable ends.No
intervalLengthMinutesnumberMinutes between intervals.No
intervalHeightnumberVertical space between intervals.No
eventContainerStyleobjectStyle object used for customizing the events. Check the types below.No
styleobjectStyle object used for customizing the general look of the header and the timetable. Check the types below.No
translationWeekstringHow the word "Week" will appear.No
showWeekendboolean`Will hide saturday and sunday if false.|No

Types

calendarEvent

PropertyTypeDescriptionRequired
idnumber/stringUnique identifier of an eventYes
isoStartstringEvent start in ISO format - 1993-02-24T10:00:00.000+01:00Yes
isoEndstringEvent end in ISO format - 2023-02-24T11:00:00.000+01:00Yes
namestringName of the event. Appears under the icon in the calendar.Yes
disabledbooleanAffects how the event is rendered. Default is gray colored with a line through. Disabled color can be adjusted in props.Yes
iconJSX ElementA JSX element. Can be some custom component or an icon library component <MaterialCommunityIcons name="food-fork-drink" size={12} />No
colorstringChange the event background color. Useful for color coding events.No

eventContainerStyle

PropertyTypeDescriptionRequired
backgroundColorstringBackground color for all events non disabled events. Can be overriden in the calendarEvent object.No
disabledColorstringBackground color for a disabled/cancelled event.No
borderWidthnumber/undefinedChange the border width around an event. Undefined for no border.No
borderColorstringBorder color.No
borderRadiusnumberBorder radius.No
fontSizenumberFont size used for showing event name.No
textColorstringColor used for showing the event name.No

style

PropertyTypeDescriptionRequired
headerColorstringHeader background color.No
headerTextColorstringHeader text color.No
fontSizeHeadernumberHeader font size.No
timetableColorstringTimetable background color.No
timetableTextColorstringTimetable text color.No
fontSizeTimetablenumberTimetable font size.No
dropdownColorstringColor for the week dropdown.No
dropdownCurrentWeekColorstringBackground color of the current week in the list.No
accentColorstringColor of the current weekday highlight, week dropdown arrow color and the currently selected week eye icon colorNo
weekButtonColorstringColor of the week dropdown button.No
weekButtonIconColorstringColor of the down arrow circular background in the week dropdown button.No
dropdownSelectedWeekIconJSX ElementIcon next to the currently selected week in the dropdown.No
arrowColorstringColor of the left/right arrows.No
1.1.0

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago