All Projects โ†’ nhn โ†’ toast-ui.react-calendar

nhn / toast-ui.react-calendar

Licence: MIT License
TOAST UI Calendar wrapper for React.js

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to toast-ui.react-calendar

nepali-datetime
Python's core datetime inspired nepali datetime (BS date & NPT) package ๐Ÿ‡ณ๐Ÿ‡ต
Stars: โœญ 36 (-76%)
Mutual labels:  calendar
yii2-fullcalendar
Yii 2 component for easy fullcalendar integration
Stars: โœญ 21 (-86%)
Mutual labels:  calendar
github-issue-due-dates-action
๐Ÿ“† GitHub Issue Due Dates Action
Stars: โœญ 63 (-58%)
Mutual labels:  calendar
Calendar
A calendar picker component, based on jQuery.
Stars: โœญ 49 (-67.33%)
Mutual labels:  calendar
react-activity-calendar
A React component to display activity data in a calendar (heatmap)
Stars: โœญ 69 (-54%)
Mutual labels:  calendar
tsdav
WebDAV, CALDAV, and CARDDAV client for Nodejs and the Browser
Stars: โœญ 33 (-78%)
Mutual labels:  calendar
ionic4-datepicker
Ionic 4 Datepicker component
Stars: โœญ 78 (-48%)
Mutual labels:  calendar
darim
๐Ÿ• A private journal service that supports client-side encryption
Stars: โœญ 33 (-78%)
Mutual labels:  calendar
modoboa-radicale
The Radicale frontend of Modoboa
Stars: โœญ 18 (-88%)
Mutual labels:  calendar
calendar
R interface to iCal (.ics files)
Stars: โœญ 30 (-80%)
Mutual labels:  calendar
scalendar
Drag and Drop your tasks and reminders based on a weekly calendar with a clean, minimal interface and zero clutter ๐Ÿ—“ ๐Ÿ’ฏ Built with React DnD ๐Ÿ’ป
Stars: โœญ 42 (-72%)
Mutual labels:  calendar
groupoffice
Group Office groupware and CRM
Stars: โœญ 80 (-46.67%)
Mutual labels:  calendar
remarkable-calendar-creator
Create calendars to display on a reMarkable device as the suspend screen or to write notes on, including events from your own online iCal calendar
Stars: โœญ 28 (-81.33%)
Mutual labels:  calendar
summit-app-ios
The official app for the OpenStack Summit
Stars: โœญ 35 (-76.67%)
Mutual labels:  calendar
ioBroker.trashschedule
Calculates trash pickup dates by using an ical calendar
Stars: โœญ 20 (-86.67%)
Mutual labels:  calendar
react-native-slideable-calendar-strip
A react native calendar strip that support swipe!
Stars: โœญ 86 (-42.67%)
Mutual labels:  calendar
webcalendar
WebCalendar is a PHP application used to maintain a calendar for a single user or an intranet group of users. It can also be configured as an event calendar.
Stars: โœญ 113 (-24.67%)
Mutual labels:  calendar
react-native-beautiful-timeline
Fully customizable, beautifully designed Timeline for React Native.
Stars: โœญ 111 (-26%)
Mutual labels:  calendar
fscalendar-ios-binding
Xamarin Binding Library - FSCalendar for iOS https://github.com/WenchaoD/FSCalendar
Stars: โœญ 12 (-92%)
Mutual labels:  calendar
CalendarView
ๆ—ฅๅŽ†ๆŽงไปถ
Stars: โœญ 14 (-90.67%)
Mutual labels:  calendar

TOAST UI Calendar for React

This is a React component wrapping TOAST UI Calendar.

github version npm version license PRs welcome code with hearth by NHN

๐Ÿšฉ Table of Contents

Collect statistics on the use of open source

React Wrapper of TOAST UI Calendar applies Google Analytics (GA) to collect statistics on the use of open source, in order to identify how widely TOAST UI Calendar is used throughout the world. It also serves as important index to determine the future course of projects. location.hostname (e.g. > โ€œui.toast.com") is to be collected and the sole purpose is nothing but to measure statistics on the usage. To disable GA, use the usageStatistics props like the example below.

<Calendar
  usageStatistics={false}
/>

Or, include tui-code-snippet.js (v1.4.0 or later) and then immediately write the options as follows:

tui.usageStatistics = false;

๐Ÿ’พ Install

Using npm

npm install --save @toast-ui/react-calendar

๐Ÿ“Š Usage

We provide a simple example and you can start right away.

Import

You can use Toast UI Calendar for React as a ECMAScript module or a CommonJS module. As this module does not contain CSS files, you should import tui-calendar.css from tui-calendar/dist manually.

  • Using ECMAScript module
import Calendar from '@toast-ui/react-calendar';
import 'tui-calendar/dist/tui-calendar.css';

// If you use the default popups, use this.
import 'tui-date-picker/dist/tui-date-picker.css';
import 'tui-time-picker/dist/tui-time-picker.css';
  • Using CommonJS module
var Calendar = require('@toast-ui/react-calendar');
require('tui-calendar/dist/tui-calendar.css');

// If you use the default popups, use this.
require('tui-date-picker/dist/tui-date-picker.css');
require('tui-time-picker/dist/tui-time-picker.css');

Props

We are supported in the form of props for Options of TOAST UI Calendar. Each name of props is same options of Toast UI Calendar except view is for defaultView of option. Additionally you can set schedules using schedules of prop.

const myTheme = {
  // Theme object to extends default dark theme.
};

const MyComponent = () => (
  <Calendar
    height="900px"
    calendars={[
      {
        id: '0',
        name: 'Private',
        bgColor: '#9e5fff',
        borderColor: '#9e5fff'
      },
      {
        id: '1',
        name: 'Company',
        bgColor: '#00a9ff',
        borderColor: '#00a9ff'
      }
    ]}
    disableDblClick={true}
    disableClick={false}
    isReadOnly={false}
    month={{
      startDayOfWeek: 0
    }}
    schedules={[
      {
        id: '1',
        calendarId: '0',
        title: 'TOAST UI Calendar Study',
        category: 'time',
        dueDateClass: '',
        start: today.toISOString(),
        end: getDate('hours', today, 3, '+').toISOString()
      },
      {
        id: '2',
        calendarId: '0',
        title: 'Practice',
        category: 'milestone',
        dueDateClass: '',
        start: getDate('date', today, 1, '+').toISOString(),
        end: getDate('date', today, 1, '+').toISOString(),
        isReadOnly: true
      },
      {
        id: '3',
        calendarId: '0',
        title: 'FE Workshop',
        category: 'allday',
        dueDateClass: '',
        start: getDate('date', today, 2, '-').toISOString(),
        end: getDate('date', today, 1, '-').toISOString(),
        isReadOnly: true
      },
      {
        id: '4',
        calendarId: '0',
        title: 'Report',
        category: 'time',
        dueDateClass: '',
        start: today.toISOString(),
        end: getDate('hours', today, 1, '+').toISOString()
      }
    ]}
    scheduleView
    taskView
    template={{
      milestone(schedule) {
        return `<span style="color:#fff;background-color: ${schedule.bgColor};">${
          schedule.title
        }</span>`;
      },
      milestoneTitle() {
        return 'Milestone';
      },
      allday(schedule) {
        return `${schedule.title}<i class="fa fa-refresh"></i>`;
      },
      alldayTitle() {
        return 'All Day';
      }
    }}
    theme={myTheme}
    timezones={[
      {
        timezoneOffset: 540,
        displayLabel: 'GMT+09:00',
        tooltip: 'Seoul'
      },
      {
        timezoneOffset: -420,
        displayLabel: 'GMT-08:00',
        tooltip: 'Los Angeles'
      }
    ]}
    useDetailPopup
    useCreationPopup
    view={selectedView} // You can also set the `defaultView` option.
    week={{
      showTimezoneCollapseButton: true,
      timezonesCollapsed: true
    }}
  />
);

Theme

You can write your own theme object. Link - See "themeConfig"

โš ๏ธ Note for passing props

The calendar component check deep equality of props when re-rendered. However, for performance and to avoid unnecessary re-rendering, it's recommended to extract props to the outside of the component or memoize them with useMemo when props don't have to be affected by component state changes.

For more information, check this issue.

const calendars = [
  {
    id: '0',
    name: 'Private',
    bgColor: '#9e5fff',
    borderColor: '#9e5fff'
  },
  {
    id: '1',
    name: 'Company',
    bgColor: '#00a9ff',
    borderColor: '#00a9ff'
  }
];

// Especially avoid to declare the `template` prop inside the component.
const template = {
  milestone(schedule) {
    return `<span style="color:#fff;background-color: ${schedule.bgColor};">${
            schedule.title
    }</span>`;
  },
  milestoneTitle() {
    return 'Milestone';
  },
  allday(schedule) {
    return `${schedule.title}<i class="fa fa-refresh"></i>`;
  },
  alldayTitle() {
    return 'All Day';
  }
};

function MyCalendar() {
  // ...
  
  return (
    <Calendar
      // ...
      calendars={calendars}
      template={template}
    />
  )
}

Instance Methods

For using instance methods of TOAST UI Calendar, first thing to do is creating Refs of wrapper component using createRef(). But the wrapper component does not provide a way to call instance methods of TOAST UI Calendar directly. Instead, you can call getInstance() method of the wrapper component to get the instance, and call the methods on it.

const calendarOptions = {
  // sort of option properties.
};

class MyComponent extends React.Component {
  calendarRef = React.createRef();

  handleClickNextButton = () => {
    const calendarInstance = this.calendarRef.current.getInstance();

    calendarInstance.next();
  };

  render() {
    return (
      <>
        <Calendar
          ref={this.calendarRef}
          {...calendarOptions}
        />
        <button onClick={this.handleClickNextButton}>Go next!</button>
      </>
    );
  }
}

Getting the root element

An instance of the wrapper component also provides a handy method for getting the root element. If you want to manipulate the root element directly, you can call getRootElement to get the element.

class MyComponent extends React.Component {
  calendarRef = React.createRef();

  handleClickButton = () => {
    this.calendarRef.current.getRootElement().classList.add('calendar-root');
  };

  render() {
    return (
      <>
        <Calendar
          ref={this.calendarRef}
          {...calendarOptions}
        />
        <button onClick={this.handleClickButton}>Click!</button>
      </>
    );
  }
}

Event

All the events of TOAST UI Calendar are supported in the form of on[EventName] props. The first letter of each event name should be capitalized. For example, for using mousedown event you can use onMousedown prop like the example below.

class MyComponent extends React.Component {
  handleClickDayname = (ev) => {
    // view : week, day
    console.group('onClickDayname');
    console.log(ev.date);
    console.groupEnd();
  };

  render() {
    return (
      <Calendar
        onClickDayname={this.handleClickDayname}
      />
    );
  }
}

๐Ÿ”ง Pull Request Steps

TOAST UI products are open source, so you can create a pull request(PR) after you fix issues. Run npm scripts and develop yourself with the following process.

Setup

Fork develop branch into your personal repository. Clone it to local computer. Install node modules. Before starting development, you should check to haveany errors.

$ git clone https://github.com/{your-personal-repo}/[[repo name]].git
$ cd [[repo name]]
$ npm install

Develop

Let's start development!

Pull Request

Before PR, check to test lastly and then check any errors. If it has no error, commit and then push it!

For more information on PR's step, please see links of Contributing section.

๐Ÿ’ฌ Contributing

๐Ÿ“œ License

This software is licensed under the MIT ยฉ NHN.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].