Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

revo-calendar

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

revo-calendar

React Event Calendar Component

  • 3.2.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

revo-calendar

npm NPM npm bundle size

A modern-looking React Event Calendar component.

Very much inspired on Evo Calendar. If you're not using React on your project, I recommend this calendar plugin that runs on jQuery.

Demo 👀

Live Demo and Playground: https://gjmolter.github.io/revo-calendar

Install 📦

#NPM
npm i revo-calendar

#YARN
yarn add revo-calendar

Usage ✍️

//Import the component
import RevoCalendar from "revo-calendar";

const Index = () => {
  return <RevoCalendar {...props} />;
};

Available Props 🎛️

PropTypeDefaultDescriptionOptions
eventsarray[]List of events to be added to the calendarSee detailed explanation below
dateDatenew Date()Default current dateAny JS Date object
classNamestring''Adds extra CSS classes to the calendarAny class name
styleCSS-in-JS{}Adds extra CSS using CSS-in-JSAny CSS-in-JS
highlightTodaybooltrueIf true, will show a ring around today's date on calendartrue or false
langstring'en'Calendar's languageen, pt, fr, es, de, ru or any other if custom languages is used
primaryColorstring'#4F6995'Background color for the side panels and text color for current month nameHex, RGB, RGBA, CSS color name
secondaryColorstring'#4F6995'Calendar background color and side panels text colorHex, RGB, RGBA, CSS color name
todayColorstring'#4F6995'Color of today's highlight ring (Will only be used if highlightToday is trueHex, RGB, RGBA, CSS color name
textColorstring'#4F6995'Text color for weekday names and day numbersHex, RGB, RGBA, CSS color name
indicatorColorstring'orange'Text color for event indicatorHex, RGB, RGBA, CSS color name
animationSpeednumber300Speed in milliseconds for all transitions and animationsAny number
sidebarWidthnumber180Size in pixels of the left panel (month/year selection)Any number
detailWidthnumber280Size in pixels of the right panel (current day's events)Any number
showSidebarTogglerbooltrueIf true, will show left panel's toggling buttontrue or false
sidebarDefaultbooltrueIf true, will have left panel open by defaulttrue or false
showDetailTogglerbooltrueIf true, will show right panel's toggling buttontrue or false
detailDefaultbooltrueIf true, will have right panel open by defaulttrue or false
onePanelAtATimeboolfalseIf true, won't allow two panels to be open simultaneouslytrue or false
openDetailsOnDateSelectionbooltrueIf true, will open right panel when date is selectedtrue or false
timeFormat24booltrueIf true, will display dates in 24H format instead of 12 (21:41 instead of 9:41 PM)true or false
detailDateFormatstring'DD/MM/YYYY'The way that current selected date will be displayed on right panelAny string. See details below
languagesobjecttranslation object with en, pt, es, fr, ru and deIf the current supported languages are not enough or you want to modify one of the translations, you can add your own translations object. See details below
dateSelectedfunctiondate => {}Use this function to get current selected date on your parent componentAny function that receives an object with day, month and year keys
eventSelectedfunctionindex => {}Use this function to get clicked event's indexAny function that receives a number parameter (event index on events array)
allowDeleteEventboolfalseIf true, will display delete button when event is clickedtrue or false
allowAddEventboolfalseIf true, will display add event button on right paneltrue or false
addEventfunctiondate => {}Use this function to add Events to events arrayAny function that receives an object with day, month and year keys
deleteEventfunctionindex => {}Use this function to delete events from the events arrayAny function that receives a number parameter (index to be deleted from events array)

events Prop

events should receive an array of event objects. Events have two mandatory parameters and two optionals

Event object:

KeyTypeMandatoryDescrition
namestring✔️Event name
dateunix timestamp✔️13 character timestamp. Can be obtained from adding operator + before JS Date object.
allDayboolIf true, will ignore Date object's time and show allDay string from current language's translation object
extraobjectIf exists, will add one extra event information next to time. The object needs to contain strings: icon and text. icon will be passed as an svg path d parameter.

Example:

var events = [
  {
    name: "Buyout",
    date: Date.now(),
    allDay: true,
  },
  {
    name: "Reservation",
    date: 1594422992000,
    extra: {
      icon: "M20.822 18.096c-3.439-.794-6.64-1.49-5.09-4.418 4.72-8.912 1.251-13.678-3.732-13.678-5.082 0-8.464 4.949-3.732 13.678 1.597 2.945-1.725 3.641-5.09           4.418-3.073.71-3.188 2.236-3.178 4.904l.004 1h23.99l.004-.969c.012-2.688-.092-4.222-3.176-4.935z",
      text: "7 People",
    },
  },
];

The example's extra.icon will render this: person icon

languages Prop

You can create an object where each key is a language (key needs to match lang atribute), each language needs to have the keys: days, daysShort, daysMin, months, monthsShort, noEventForThisDay and allDay.

Here is an example of the Esperanto language:

const translations = {
  esperanto: {
    days: ["Dimanĉo", ..."Sabato"],
    daysShort: ["Dim", ..."Sab"],
    daysMin: ["Di", ..."Sa"],
    months: ["Januaro", ..."Decembro"],
    monthsShort: ["Jan", ..."Dec"],
    noEventForThisDay: "Neniu evento por ĉi tiu tago ... do ripozu!",
    allDay: "Tuta tago",
    addEvent: "Aldoni eventon",
    delete: "Forigi",
    eventTime: "Tempo de evento",
    previousYear: "Pasintjare",
    nextYear: "Venonta jaro",
    toggleSidebar: "Baskulu flanka kolumno",
    toggleDetails: "Ŝaltu Detalojn",
  },
};

To render the calendar using custom esperanto language, pass the translations object and the key to languages and lang respectivelly.

Example:

<RevoCalendar languages={translations} lang="esperanto" />

detailDateFormat Prop

detailDateFormat can be any string, with the following placeholders being replaced:

placeholderreplacementexample
MMMMFull month nameNovember
MMMShort month nameNov
MMMonth number11
DDDay number18
nthOrdinal day number18th
ddddWeekday nameThursday
dddShort weekday nameThu
ddTiny weekday nameTh
YYYYFull year1997
YYYear's last 2 digits97

Example

"MMM nth, YYYY" => "Nov 18th, 1997"

License

MIT © gjmolter

Keywords

FAQs

Package last updated on 26 Jul 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc