Coder Social home page Coder Social logo

geoffzhu / vue-event-calendar Goto Github PK

View Code? Open in Web Editor NEW
637.0 28.0 228.0 1.63 MB

A simple events calendar for Vue2, no dependencies except Vue2.

Home Page: http://geoffzhu.cn/vue-event-calendar/

HTML 0.89% Vue 58.48% JavaScript 40.63%
vue event-calendar vue-calendar

vue-event-calendar's Introduction

vue-event-calendar

A simple events calendar for Vue2, no dependencies except Vue2. responsive & mobile first. Live Demo Here

npm version

中文文档

Requirements

  • vue: ^2.0.0

Usage

install

 npm install vue-event-calendar --save

main.js

import 'vue-event-calendar/dist/style.css' //^1.1.10, CSS has been extracted as one file, so you can easily update it.
import vueEventCalendar from 'vue-event-calendar'
// locale can be 'zh' , 'en' , 'es', 'pt-br', 'ja', 'ko', 'fr', 'it', 'ru', 'de', 'vi', 'ua', 'no, 'no-nn'
Vue.use(vueEventCalendar, {locale: 'en'}) 

file.vue

<template>
  <vue-event-calendar :events="demoEvents"></vue-event-calendar>
</template>

<script>
export default {
  data () {
    return {
      demoEvents: [{
        date: '2016/11/12', // Required
        title: 'Foo' // Required
      }, {
        date: '2016/12/15',
        title: 'Bar',
        desc: 'description',
        customClass: 'disabled highlight' // Custom classes to an calendar cell
      }]
    }
  }
}
</script>

Custom date title

<template>
  <vue-event-calendar :title="title" :events="demoEvents" @dayChanged="handleDayChange"></vue-event-calendar>
</template>

In most cases, the default date string is enough,but when you want a custom date title, you can give a prop title. It is important to noticed that the title will be replaced with a static String you passed in. You need to monitor the dayChanged event and change the title by youself.

Customization event template

If you want customization event template. required Vue: ^2.1.0. Because I use new feature(Scoped Slots) of ^2.1.0

<template>
  <vue-event-calendar :events="demoEvents">
      <template scope="props">
        <div v-for="(event, index) in props.showEvents" class="event-item">
          <!-- In here do whatever you want, make you owner event template -->
          {{event}}
        </div>
      </template>
    </vue-event-calendar>
</template>

<script>
export default {
  data () {
    return {
      demoEvents: [{
        date: '2016/12/15',
        title: 'eat',
        desc: 'longlonglong description'
      },{
        date: '2016/11/12',
        title: 'this is a title'
      }]
    }
  }
}
</script>

Component Events

Can handle two Events, @day-changed and @month-changed, callback params like {date: '2017/06/23', events: []}.

<template>
  <vue-event-calendar
    :events="demoEvents"
    @day-changed="handleDayChanged"
    @month-changed="handleMonthChanged">
  </vue-event-calendar>
</template>

Options

  // When Vue.use, options
  {
    locale: 'en',
    color: 'black', //Set main color
    className: 'Custom className for current clicked date', // (default: 'selected-day')
    weekStartOn: 'week Start on which day'  // Can be: 1, 2, 3, 4, 5, 6, 0 (default: 0)
  }

API

// NextMonth
this.$EventCalendar.nextMonth()
// PreMonth
this.$EventCalendar.preMonth()
//ToDate
this.$EventCalendar.toDate('2016/11/12')

More in Demo Folder

Develop

npm run dev  //develop
npm run build //production

Change log

1.3.6 -> 1.4.0
  • Remove today background, use a small dot below the date
  • Increase the selected date style
1.4.0 -> 1.4.8
  • Add week start on

License

MIT

vue-event-calendar's People

Contributors

annibuliful avatar askogvold avatar barntarnst avatar daeghun avatar diegoaguilarf avatar fbove avatar geoffzhu avatar jbsness avatar kalidiagne avatar keizerdev avatar key60529 avatar lajosbencz avatar theanht1 avatar veloxy avatar zabaat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-event-calendar's Issues

Custom header for all events

Can you add please some props to set custom header to list in case of all events?
Or named slot just like you did for elements.
Thnx.

add spain calendar

How could I add the calendar in Spanish?
The week starts on Monday, not Sunday

Date Format

Hi! My date format is 2017-02-23, but you comparable with ${dateObj.getFullYear()}/${dateObj.getMonth()+1}/${dateObj.getDate() to mark today style, What is better solution ? Convert '-' to '/' in your component, or in my api? I prefer in your plugin, it become generic.

Week start on monday option

Would it be possible to add an option to choose whether the week starts on monday or not?

I would rather stick to the more modern version of the calendar which starts on monday and ends on Sunday.
I would change it myself and do a PR but I don't have enough experience with Vue Component to do so with confidence.

Thanks in advance for your anwser, and thanks for the awesome component!

Change the curYearMonth

Hi, guys how can i change in the calendar the curYearMonth for the MONTH but not de number but the name Example the calendar show < 03/2017 > A like change < APRIL/2017 > our < APRIL >. And
In which file i do this change.

Thank's

Support for IE

Hi,

Can you make a refinement for the calendar to run with Internet Explorer 11. It pushes the error "Object doesn't support property or method 'assign'". I don't know it's arising from ES 6 however I am using babel-cli but that does not correct it.

Best regards.

dayList:"(error during evaluation)" error

Hey mate,

I faced an error. I am using vuex and, as for the events props I put data using getter from computed not model like,


...
computed: {
events(){
return this.$store.getters.events;
}
},

when the calender render, it shows me an error "vue.esm.js?65d7:523 TypeError: Cannot read property 'split' of undefined"

I was tracing using vue-tools, I found the problem. In the "CalPanel", the day list cannot make days, it said, "dayList:"(error during evaluation)""

is there a any way to solve this problem?

cheers,

Localization

It would be usefull if you could add custom translations without having to edit the NPM Package itself, i tried everything and the only solution i could come up with was adding it to the localization in the Package itself.

I dont find that a feasible solution, so i was wondering if something like custom localization could be added.

Cheers

Listen to a month change event

Thanks for the cool calendar library.

I was wandering if there is a way to listen to something like a month change event, so I can perform an ajax request to get all the events for the month

Default events

By default shows all events. How could I show my reservations today?

ReferenceError: dateString is not defined

My template based on example from README.md

<template>

    <div class="fast-navigation-calendar">
        <vue-event-calendar :events="demoEvents"></vue-event-calendar>
    </div>

</template>

<script>

    export default {
        name: 'fast-navigation-calendar',
        data () {
            return {
                demoEvents: [{
                    date: '2016/12/15',
                    title: 'Foo',
                    desc: 'longlonglong description'
                },{
                    date: '2016/11/12',
                    title: 'Bar'
                }]
            }
        }
    }

</script>

But i see

[Vue warn]: Error in getter for watcher "calendarParams": "ReferenceError: dateString is not defined"

found in

---> <VueEventCalendar>
       <FastNavigationCalendar> at src/components/fast-navigation/fast-navigation-calendar.vue
         <FastNavigation> at src/components/fast-navigation/fast-navigation.vue
           <FrontendIndex> at src/pages/frontend-index.vue
             <App> at src/app.vue
               <Root>
error during render : /
ReferenceError: dateString is not defined
    at VueComponent.calendarParams (/var/git/frontend/node_modules/vue-event-calendar/dist/index.js:864:26)
    at Watcher.get (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:2860:25)
    at Watcher.evaluate (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:2967:21)
    at VueComponent.computedGetter (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:3238:17)
    at VueComponent.<anonymous> (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:432:16)
    at Watcher.get (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:2860:25)
    at new Watcher (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:2849:12)
    at VueComponent.Vue.$watch (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:3338:19)
    at createWatcher (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:3298:13)
    at initWatch (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:3280:7)
    at initState (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:3069:5)
    at VueComponent.Vue._init (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:4193:5)
    at new VueComponent (/var/git/frontend/node_modules/vue/dist/vue.runtime.common.js:4365:12)
    at createComponentInstanceForVnode (/var/git/frontend/node_modules/vue-server-renderer/build.js:6810:10)
    at renderComponentInner (/var/git/frontend/node_modules/vue-server-renderer/build.js:6986:40)
    at renderComponent (/var/git/frontend/node_modules/vue-server-renderer/build.js:6961:5)
    at RenderContext.renderNode (/var/git/frontend/node_modules/vue-server-renderer/build.js:6877:5)
    at RenderContext.next (/var/git/frontend/node_modules/vue-server-renderer/build.js:2186:14)
    at cachedWrite (/var/git/frontend/node_modules/vue-server-renderer/build.js:2046:9)
    at renderElement (/var/git/frontend/node_modules/vue-server-renderer/build.js:7101:5)
    at renderNode (/var/git/frontend/node_modules/vue-server-renderer/build.js:6879:5)
    at renderComponentInner (/var/git/frontend/node_modules/vue-server-renderer/build.js:6997:3)
"GET /" 500 - "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.78 Safari/537.36"

Im using

"vue": "^2.4.1",
"vue-event-calendar": "^1.4.5"

Exactly
ReferenceError: dateString is not defined
https://github.com/GeoffZhu/vue-event-calendar/blob/master/dist/index.js#L864

Events not highlighting

First, this is an excellent Vue component, thanks for all of the hard work!

I'm having a problem where the events aren't being highlighted in the calendar. Wondering if I'm somehow doing something silly with the date format (although I have tried many combinations without success). Here is a screenshot:

localhost-8080- iphone 6

Not sure if this is a part of the problem but it seems weird that the date at the top is "MM/YYYY" but the format in the event is "YYYY/MM/DD". I also tried using a date format of "YYYY/M/D" (to see if #1 resurfaced), but it didn't help.

Here is the relevant code:

# Calendar.vue
<template>
  <vue-event-calendar
    :events="demoEvents"
    @month-changed="handleMonthChanged"
    @day-changed="handleDayChanged"
  >
    <template scope="props">
      <div v-for="(event, index) in props.showEvents" class="event-item">
        <!-- In here do whatever you want, make you owner event template -->
        {{event}}
      </div>
    </template>
  </vue-event-calendar>
</template>

<script>
export default {
  data () {
    return {
      claims: [],
      demoEvents: [{
        // id: 5,
        date: '2016/12/15',
        title: 'Foo',
        desc: 'longlonglong description'
      },
      {
        // id: 6,
        date: '2016/11/12',
        title: 'Bar'
      }]
    }
  },
  methods: {
    handleMonthChanged (data) {
      console.log('month-changed', data)
    },
    handleDayChanged (data) {
      console.log('month-changed', data)
    }
  }
}
</script>

if dayOfWeek == 0

if the day of the week is Sunday, firstDay.getDay () gives 0.
as a result, we lost the first week on the calendar.
replace with this code to fix it (in the cal-panel.vue)

    dayList () {
        let firstDay = new Date(this.calendar.params.curYear, this.calendar.params.curMonth, 1)
        let dayOfWeek = firstDay.getDay()
        if (dayOfWeek == 0&&this.calendar.options.weekStartOn > 0) {
          dayOfWeek=7
        }

        let startDate = new Date(firstDay)
        startDate.setDate(firstDay.getDate() - dayOfWeek + this.calendar.options.weekStartOn)

Event list not scrollabile

Events are not scrollabile in the event block, i have 9 events and i can only see 7 of it.
I added a overflow-x: scroll; temporally to resolve that.

OGT

A.P el OGT

Wrong date format

Really nice plugin. But there is a problem with the date format for events.

For example:
When I put an event at the date: '2017/2/16' it does show up

But when I change to '2017/02/16' it does not.

Should I send a pr?

npm run dev 报错

已经 npm install 过,报错如下,请帮忙看一下,谢谢:
➜ vue-event-calendar git:(master) npm run dev

[email protected] dev /Users/youcheng/Desktop/vue-event-calendar
cross-env NODE_ENV=development webpack-dev-server --open --inline --hot

events.js:160
throw er; // Unhandled 'error' event
^

Error: spawn webpack-dev-server ENOENT
at exports._errnoException (util.js:1022:11)
at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
at onErrorNT (internal/child_process.js:359:16)
at _combinedTickCallback (internal/process/next_tick.js:74:11)
at process._tickCallback (internal/process/next_tick.js:98:9)
at Module.runMain (module.js:606:11)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3

Can you add incoming events options on shown events

As far as I see, it can only be selected to show all events or one day events by setting curEventsDate parameter. However it would be more useful if incoming events could be shown by default.

By incoming events, I mean it can show the nearest 10 future events (even the number 10 can be parametric), and the title is set to "Incoming Events".

If you can add this feature, the calendar would be nicer.

Thank you, Best regards.

自定义模板的事件绑定无效

<vue-event-calendar :events="demoEvents" @day-changed="handleDayChanged" @month-changed="handleMonthChanged">

<div v-for="(event, index) in props.showEvents" class="event-item" @click.native="pop(event)">
<div @click.native="pop(event)">
{{event.title}}
</div>
</div>
</template>
</vue-event-calendar>

不知道为什么,自定义内容里写点击事件无效,不管写在v-for的位置 还是写在里面的位置,这个到底应该写在哪?

Use DateTime instead of Date ?

It could be great to set DateTime instead of just a Date for events.
In my case, there are events happening on the same day.

Cannot read property 'split' of undefined

<template>

    <div class="fast-navigation-calendar">

        <vue-event-calendar :events="demoEvents"></vue-event-calendar>

    </div>

</template>

<script>

    import VueEventCalendar from "vue-event-calendar"

    export default {
        components: {VueEventCalendar},
        name: 'fast-navigation-calendar',
        data () {
            return {
                demoEvents: [{
                    date: '2016/12/15',
                    title: 'Foo',
                    desc: 'longlonglong description'
                },{
                    date: '2016/11/12',
                    title: 'Bar'
                }]
            }
        }
    }

</script>

Is not working

TypeError: Cannot read property 'split' of undefined
    at install (webpack:///./node_modules/vue-event-calendar/dist/index.js:940)
    at resolveAsyncComponent (vue.runtime.esm.js:2086)
    at createComponent (vue.runtime.esm.js:3558)
    at _createElement (vue.runtime.esm.js:3764)
    at createElement (vue.runtime.esm.js:3703)
    at vm._c (vue.runtime.esm.js:4043)
    at Proxy.render (fast-navigation-calendar.vue?46ba:4)
    at VueComponent.Vue._render (vue.runtime.esm.js:4095)
    at VueComponent.updateComponent (vue.runtime.esm.js:2515)
    at Watcher.get (vue.runtime.esm.js:2858)

Possible to Customize i18n?

Is it possible to customize the i18n for a given language?

In my case, being able to customize format, fullFormat, dayEventsTitle and notHaveEvents would be incredibly helpful. Here is an example of what I might want to change:

en: {
    dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
    monthNames: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
    format: 'January 2017',
    fullFormat: 'yyyy-MM-dd',
    dayEventsTitle: 'All Meetings',
    notHaveEvents: 'No Meetings Scheduled'
  },

在线示例的bug

在线的示例中没有报错,但是日历无法选择日期,请看一下

Change Date Format

Is there a way to change the date format from a Europe version (DD/MM/YYYY) to a US version (MM/DD/YYYY)???

Impossible to install in vuejs ^2.1.0

Here the errors i get :
build.min.js:685 [Vue warn]: Error when rendering component <vue-event-calendar>:
build.min.js:3074 TypeError: _vm._v is not a function

Possibility to add a custom classes to an .item.event based on its events

Bug, feature request, or proposal:

Possibility to add a custom classes to an .item.event based on its events

What is the use-case or motivation for changing an existing behavior?

Days with different style based on the types of events on that day.

Proposed solution

Each event can have a custom class name that will be used on the element .item.event.
If a single day have multiple events with multiple custom classes, all custom classes need to be applied on .item.event.
This will allow custom styles on event days.

<template>
  <vue-event-calendar :events="demoEvents"></vue-event-calendar>
</template>

<script>
export default {
  data () {
    return {
      demoEvents: [{
        date: '2016/12/15',
        title: 'Dinner',
        desc: 'Dinner with friends',
        classes: 'night other-custom-class no-limit-of-classes'
      },{
        date: '2016/11/12',
        title: 'Bar'
      }]
    }
  }
}
</script>

异步获取数据怎么默认显示当天事件

我想进入的时候默认显示当天事件,尝试操作vue-event-calendar.vue组件里的selectedDayEvents,不过还没获取数据之前处理方法就执行完了,把事件全部都显示出来了。然后尝试在vue-event-calendar.vue组件里异步success拼接数据后执行handleChangeCurDay,依然是数据没渲染就执行完了,还是把事件都显示出来了。有什么方法可以默认显示当天事件吗?

Multi-Days Event

Hi,
Is it possible to add an event that lasts several days?
If not, would it be possible to add this feature?
Thanks

感谢

特别的好用,我想给你100star,可惜只能给一个

this.$EventCalendar.toDate(today) 失败

let today = new Date() today = today.getFullYear()}/${today.getMonth() + 1}/${today.getDate()} this.$EventCalendar.toDate(today)

this.$EventCalendar.toDate(today) 此处无作用, 希望在demo中体现下

New feature

I really like the simplicity of your calendar. Do you think of adding a time feature for the events array?

Best Regards 👍

Edit:
Forget about it. Dumb question :)

How to go back to All Events list ?

Hello,

Great plugin!
But I'm not sure if it's me but I can't find a way to go back to the All Events state after having selected a day.
Is it possible ?

日历点击事件没有生效

上一月、下一月的事件生效了,但是点击日期事件是没有生效的,也没有报错,和在线实例中效果一样,没生效点击日期事件,和动态图中的效果有差异

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.