0.2.1 • Published 3 years ago

easy-vue-calendar v0.2.1

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

easy-vue-calendar

Project setup

npm i --save easy-vue-calendar

Example to use

<template>
    <EasyCalendar 
      :items="items"
      @dayClicked="dayClicked"
      @itemClicked="itemClicked"
      @prevMonthClicked="prevMonthClicked"
      @nextMonthClicked="nextMonthClicked"
      v-model="daySelected"
    />
</template>

<script>
    import EasyCalendar from 'easy-vue-calendar'
    export default {
        components: {
            EasyCalendar
        }
        data () {
            return {
                items: [
                    {
                        title: 'test',
                        day: '2020-06-10',
                        background: '#000',
                        color: '#FFF',
                        // Other data...
                    }
                ],
                daySelected: '2020-03-15'
            }
        },
        methods: {
            dayClicked ($event) {
                console.log($event)
            },

            itemClicked ($event) {
                console.log($event)
            },

            prevMonthClicked($event) {
                console.log($event)
            },

            nextMonthClicked ($event) {
                console.log($event)
            }
        },
    }
</script>

Items are the events that can be passed to the calendar. It is an array type and can be passed any data (To be retrieved later), however some data needs to have its particularities.

Data that needs to be respected

NameDescription
titleThe title that will appear on the label
dataThe day the label will fit
colorThe font color of the label
backgroundThe background color of the label

Language support

<template>
    <EasyCalendar 
      :items="items"
      @dayClicked="dayClicked"
      @itemClicked="itemClicked"
      @prevMonthClicked="prevMonthClicked"
      @nextMonthClicked="nextMonthClicked"
      :showButtonsHeader="true"
      textButtonNext="Next"    <--- Add
      textButtonPrev="Prev"    <--- Add
      :weeks="weeks"           <--- Add
      :months="months"         <--- Add
    />
</template>

<script>
    import EasyCalendar from 'easy-vue-calendar'
    export default {
        name: 'App',
        components: {
            EasyCalendar
        },
        data () {
            return {
                items: [
                    {
                        title: 'teste',
                        day: '2020-06-10'
                    }
                ],
                weeks: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
                months: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
            }
        }
    }
</script>

Props

NameTypeDefaultExample
itemsarray[]
showButtonsHeaderbooleantrue
showButtonAddbooleantrue
weeksarray'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'
monthsarray'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'
minimalistbooleanfalse
disabledDaysarray[]"2021-03-20", "2021-03-10"

Events

NameReturn
dayClickedan object as long as the day clicked
itemClickedan object containing the title and day of the item clicked
prevMonthClickeda json object with the start date and end date shown on the calendar
nextMonthClickeda json object with the start date and end date shown on the calendar

API

<template>
    <EasyCalendar 
      ...
      ref="calendar"
    />


</template>

<script>
    import EasyCalendar from 'easy-vue-calendar'
    export default {
        name: 'App',
        components: {
            EasyCalendar
        },
        ...

        methods: {
            nextMonth () {
                this.$refs.calendar.nextMonth() // <--- change next month
            },
            prevMonth () {
                this.$refs.calendar.prevMonth() // <--- change prev month
            }
        }
    }
</script>
0.2.1

3 years ago

0.2.0

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.6

3 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago

0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.6

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago