1.3.7 • Published 3 years ago

agenda-rc v1.3.7

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

Agenda React Component

Capture d’écran du 2021-07-09 09-39-02

Description

An Agenda component for your React application. Display a list of events and offer the possibility to create new or modify these events.

Offer the possibility to customise options and colors of the component.

Installation

Use npm install agenda-rc to install the package You need to download input-moment.min.css and add it as a css link in your html page

Utilisation

Props

PropsDescriptionTypeOptional
eventListList of events which will be displayed in the agendaArrayfalse
languageLanguage of the text displayedString ("en" or "fr")true (fr by default)
themeIndex of the color theme (see material palette + white and black)numbertrue
settingsList of settings of the appObjecttrue
handlersList of function to update value of different props (no need to update the props of the component)Objectfalse
tagsListList of tagsObjectfalse(but can be empty)
eventColorsDefault List of colors for eventsListtrue
timeRangeMinimal time division (must be : 5, 10, 15, 20, 30 or 60)Numbertrue (default : 5)

Settings

Settings object props

NameDescriptionTypeOptional
settingsModifDefined wich options can be changed within the componentObjectfalse
tableUsed to know during how much month before and after the events are givenObjectfalse
titleInformations about the titleObjectfalse
allowCreationTell if we can create new eventsBooleantrue (default : true)
allowModificationTell if we can modify existing event (delete included)Booleantrue (default : true)
allowTagsallow the creation of tagsObjecttrue (default : true)

settingsModif

SettingsModif object props

NameDescriptionTypeOptional
allowedAllow the possibility to acces change the settings in the componentBooleanfalse
allowColorAllow to change the event color rangeBooleantrue (default : true )
allowTimeRangeAllow to change the time divisionBooleantrue (default : true )
allowThemeChangeAllow to change the themeBooleantrue (default : true )

table

Table object props

NameDescriptionTypeOptional
beforeNumber of month rendered before today dateNumberfalse
afterNumber of month rendered after today dateNumberfalse
totalNumber total of month renderedNumberfalse

title

Title object props

NameDescriptionTypeOptional
isImageTell if you want to use an image instead of a text for the titleBooleanfalse
valueTitle or path to the imageStringfalse
hasLogoTell if ther is a logo to render before the titleBooleanfalse
logoPathPath to the logoStringfalse

Handlers

List of function to update value of different props (no need to update the props of the component)

NameDescriptionTypeOptional
handleEventFunction to return the events modified or createdfunctionfalse
handleColorsFunction to return the color rangefunctiontrue
handleTimeRangeFunction to return the time divisionfunctiontrue
handleTagListFunction to return the tagsfunctiontrue
handleThemeFunction to return the themefunctiontrue

Example

import Agenda from 'agenda-rc'

//Needed for the css to work because of semantic ui (can be imported once in the top container)
import 'semantic-ui-css/semantic.min.css'

const settings = {
      //settings window alowed options
      settingsModif: {
         //allow general setting modif
         allowed: true,
         //allow color change in settings(true by default)
         allowColor: true,
         //allow change of timeRange
         allowTimeRange: true,
         //allow theme color change
         allowThemeChange: true
      },
      //settings link to the eventList
      table: {
         //number of months before given
         before: 1,
         //number of months after given
         after: 11,
         //number total of months
         total: 12
      },
      //title otpions
      title: {
         //is the title an image and no a text
         isImage: false,
         //text of the title or link to the image
         value: 'Calendrier',
         //does it have logo
         hasLogo: false,
         //logo path
         logoPath: 'https://react.semantic-ui.com/images/wireframe/image.png'
      },
      //creation and modification options
      //allow creation of event
      allowCreation: true,
      //allow modification of events
      allowModification: true,
      //allow the creation of tags
      allowTags : true
   }

  //list of events to be displayed
  const eventList = [
    //exemple of event:
    {
               title: '', // title of the event
               color: '', //color of the event
               start: moment, //start moment (from moment)
               end: moment, //end moment
               icon: '', //name of the icon from semantic ui to be associated (optional)
               key: '', //the unique key correspoding to the event
               place: '', //name of the place where the eventit take place
               tags: [], // list of the keys of the tags associated to this event
               description: '' // the description of the event
            }
  ]

  //list of handlers to permit changes from the agenda
  //handle the change of differents value (take the new value for parameters)
  const handlers = {
      handleEvent: function, //for the eventList
      handleColors: function, // for the colorsList
      handleTimeRange: function, // for the timeRange
      handleTagList: function, // for the tagList
      handleTheme: function // for the theme
   }

   //List of tags
   const tagsList = {
   //can be empty, tags can be created when events are created / modified
   //else is on the format
      key: { //the key of the tag (must be unique)
         name: '', //the name displayed
         color: '' //the color, must be one element of : red, orange, yellow, olive, green, teal, blue, violet, purple, pink, brown, grey, black
      }
   }

   //array of default color (in hexaDecimal) for events(optional)
   const eventColors = ['#000', '#f00', '#0f0', '#00f']

   //minimal time range (multiple of 5 and one hour can be easily divided in equals part of this time range) must be : 5, 10, 15, 20, 30 or 60
   const timeRange = 15

   .
   .
   .


   ReactDOM.render(<Calendar eventList={eventList} language="en" theme={1} settings={settings} handlers={handlers} tagsList={tagsList} eventColors={eventColors} timeRange={timeRange} />, document.querySelector('#root'))