2.2.1 • Published 6 months ago

react-custom-calendars v2.2.1

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

react-custom-calendars

It provides calendar data that you can customize and use as you wish. (in React)

alt text alt text alt text

Installation

npm

npm i react-custom-calendars

yarn

yarn add react-custom-calendars

Example

import { MonthCalendar } from "react-custom-calendars";

function App() {
  const { monthCalendarData } = MonthCalendar("dd");

  return (
    <ul>
      {monthCalendarData.map((weeks) => (
        <li
          style={{
            listStyle: "none",
            display: "flex",
            gap: "10px",
          }}
        >
          {weeks.map((date) => (
            <p style={{ width: "20px" }}>{date}</p>
          ))}
        </li>
      ))}
    </ul>
  );
}

export default App;

MonthCalendar

  • You can return date data in monthly calendar format.
  • In a week, the last date of the previous month or the start date of the next month is returned as 0.
    • If you want to use the included data, you can use WeekCalendar.
  • example
// MonthCalendar example
const { currentDate, monthCalendarData, moveToPeriod, moveToNext, moveToPrev } =
  MonthCalendar("dd");

// Move to next month
moveToNext();
// Move to previous month
moveToPrev();
// Move 3 months forward
moveToPeriod(3);

Argument

namerequiredtypeDescriptionExample
formatOstringFormat of returned dateyyyy-MM-dd, dd, ...
currentDateXDateStandard for date data to be returned (if there is no value, today's date is returned)new Date(2024, 8, 15)

Return

nametypeDescription
currentDateDateStandard for date data to be returned
setCurrentDatefunctionA function that changes the currentDate, which is the reference point of the monthly date to be returned
monthCalendarDatastring[][]Data that can be displayed on a calendar based on currentDate
moveToPeriodfunctionMoves the calendar by specified number of months. Positive numbers move forward, negative numbers move backward (e.g., moveToPeriod(1) moves to next month, moveToPeriod(-2) moves back two months)
moveToNextfunctionMoves the calendar to the next month currentDate
moveToPrevfunctionMoves the calendar to the previous month currentDate

WeekCalendar

  • You can use this when you want to include the last dates of the previous month within a week, or the start dates of the next month.
  • example
// WeekCalendar example
const {
  currentDate,
  weekDates,
  monthlyWeekGrid,
  moveToPeriod,
  moveToNext,
  moveToPrev,
} = WeekCalendar("dd");

// Move to next week
moveToNext();
// Move to previous week
moveToPrev();
// Move 2 weeks forward
moveToPeriod(2);

Argument

namerequiredtypeDescriptionExample
formatOstringFormat of returned dateyyyy-MM-dd, dd, ...
currentDateXDateStandard for date data to be returned (if there is no value, today's date is returned)new Date(2024, 8, 15)

Return

nametypeDescription
currentDateDateStandard for date data to be returned
setCurrentDatefunctionA function that changes the currentDate, which is the reference point of the weekly date to be returned
weekDatesstring[]Simple array of dates for current week (Sunday to Saturday)
monthlyWeekGridstring[][]Grid format data that includes dates from adjacent months
moveToPeriodstring[]Moves the calendar by specified number of weeks. Positive numbers move forward, negative numbers move backward (e.g., moveToPeriod(1) moves to next week, moveToPeriod(-2) moves back two weeks)
moveToNextstring[]Moves the calendar to the next week currentDate
moveToPrevstring[]Moves the calendar to the previous week currentDate

LICENSE

  • MIT
2.2.1

6 months ago

2.2.0

6 months ago

2.1.0

6 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.0.0

11 months ago

0.1.0

11 months ago

0.0.4

11 months ago

0.0.3

11 months ago

0.0.2

11 months ago

0.0.1

11 months ago