0.1.2 • Published 6 years ago

takeyajs v0.1.2

Weekly downloads
5
License
MIT
Repository
github
Last release
6 years ago

Takeya

A lightweight javascript event calendar.

Note

This package is still under development. The api won't change much; however, the inner working need some refactoring.

Example

https://takeya-c718d.firebaseapp.com

Install

yarn add takeyajs
#or
npm i --save takeyajs

Usage

Create a calendar instance

import Calendar from 'takeyajs'

// pass in a HTML element
const c = new Calendar(document.getElementById('calendar'))

For styles import the scss file

@import "~takeyajs/dist/style"

Calendar methods

// render the month view
c.renderMonth()

// render the agenda view
c.renderAgenda()

// render the agenda view with predefined row length
c.renderAgenda(5)

// render the next view
c.next()

// render the previous view
c.prev()

// get title
c.getTitle() 

// add events
const events = [
    {
        id: "1",
        title: "hey",
        start: 1520704919,
        end: 1520705929
    },
    {
        id: "2",
        title: "sup",
        start: 1520604919,
        end: 1520605929
    }
]
c.setEvents(events)

// remove events
c.removeEvents()

// remove event
const id = "1"
c.removeEvent(id)

Event listeners

// listen for day click
window.addEventListener('calendar-day-click', (e) => {
    console.log(e.detail.date) // --> "03/06/2018"
})

// listen for event clicks
window.addEventListener('calendar-event-click', (e) => {
    console.log(e.detail.event) // --> { id: "2", title: "sup", start: 1520604919, end: 1520605929}
})
0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago