2.0.1 • Published 2 years ago

react-calendar-mg v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

React Calendar MG

Hello, I'm Magdeil, and this is my first published library, I hope it can help you in your projects.

This library uses momet as a dependency, to facilitate the use of the calendar.

They can download the repository, modify and improve it, they can also fork it.

To start the project locally

yarn install
or
npm install

yarn start
or
npm start

For the build. yarn build or npm build

Getting started

Compatibility

Your project needs to use React 16.11 or later.

Props Calendar

Prop nameDescriptionDefault valueExample values
disabledDatesReceives a string array that disables the days of the month passed as a parameter.true['2022-08-01','2022-08-02',]
onChangeDateFunction called when the user clicks on the calendar day they want to select using the useState hook.n/aconst [selectedHour, setSelectedHour] = useState(null);
colorReceives parameter in string format, rgb, hex, to change the color of the days in the calendar.blackred rgb(19 152 211) rgba(0 0 0 / 76%) #035251c2
borderColorReceives parameter in string format, rgb, hex, to change the color of the calendar border.rgb(19 152 211)red rgb(19 152 211) rgba(0 0 0 / 76%) #035251c2

Props Hour

Prop nameDescriptionDefault valueExample values
openingHourIt receives as a parameter a string that indicates the initial hour.true - 08:0008:00
closingHourIt receives as a parameter a string that indicates the closing time.true - 14:0018:00
colorReceives parameter in string format, rgb, hex, to change the color of the hours.blackred rgb(19 152 211) rgba(0 0 0 / 76%) #035251c2
onChangeHourFunction called when the user clicks on the calendar hour they want to select using the useState hook.n/aconst [selectedDay, setSelectedDay] = useState(null);
hoursDisabledIt receives as a parameter a string array that disables the hours that will not be available.true['10:00','10:30']

Usage

Here's an example of basic usage:

import React, { useState } from 'react';
import { Calendar, Hours } from 'react-calendar-mg';

function MyCalendar() {
  const [selectedHour, setSelectedHour] = useState(null);
  const [selectedDay, setSelectedDay] = useState(null);

const disabledDates = [
    '2022-08-01',
    '2022-08-02',
    '2022-08-03',
  ];

  const hoursDisabled = [
    '09:00',
    '09:30',
    '10:00',
  ];

  return (
	<div style={{ width: '50%', color: 'black', margin: 'auto', marginTop: '50px', }} >
      <Calendar onChangeDate={setSelectedHour} disabledDays={disabledDates} color="rgba(0 0 0 / 76%)" />
      <Hours onChangeHour={setSelectedDay} openingHour="09:00" closingHour="18:00" disabledHours={hoursDisabled} />
    </div>
  );
}

enter image description here

enter image description here

1.0.14

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago