Giter VIP home page Giter VIP logo

days-calendar's Introduction

Days Calendar

Simple and customizable calender for Vue, which only used moment.js and no more other dependencies.

This project still under active development, please feel free to open issues or pull request.

Demo

http://days.sardo.work/

Features

  • Customizable days and weekdays output
  • Customizable style

Installation

npm install days-calendar --save

or

yarn add days-calendar

Usage

Import module from days-calendar, then register it to Vue:

Base

import DaysCalendar from 'days-calendar';

new Vue({
  el: '#your-dom-element',
   components: {
      Calendar: DaysCalendar
   }
})

Custom Modal

By default, Days Calendar will show a modal which contain event content. If you want to custom the template of modal, you can call calendar like this:

   <Calendar>
     <div slot="modal-content">
       <h1>Hello World!</h1>
     </div>
   </Calendar>

If you want to using day object in custom modal, you should pass renderDay function to calendar like this:

<Calendar :renderDay="getDate">
 <div slot="modal-content">
   {{day.content}}
 </div>
</Calendar>
getDate: function(day){
  this.day = day;
  return day;
}

or you will not be allow to access the information of day.

Disable Day

If you don't want user click on some day, you can pass renderDays function to calendar like this:

<Calendar :renderDays="renderDays"></Calendar>
renderDays: function(days){
  return new Promise((resolve, reject) => {
    for(let i = 0; i < days.length; i++){
      const weekday = days[i].date.weekday();
      //If it is Tuesday, disable it
      if(weekday == 2){
        days[i].disabled = true;
      }
    }
     resolve(days);
  });
},

Props

langcode (optional)

A string of language code which used to setting calendar language. Support language:

  1. English - en
  2. Traditional Chinese (Hong Kong) - zh-hk
  3. Traditional Chinese (Taiwan) - zh-tw
  4. Simplified Chinese - zh-cn

Default value is en.

defaultStart (optional)

A string which tell calendar should start on that date. Format is YYYY-MM-DD.

Default value is current date.

Example: 2017-11-03

renderDay (optional)

If you pass this props to Days Calendar, it will pass day object to the function before render the content.

This function should return a day object array.

renderDay(day){
  console.log(day);
  return day;
}

/* Day object:
{ number: (Number of that day), date: (Moment Date Object), class: [] } */

renderDays (optional)

If you pass this props to Days Calendar, it will pass the array of day object to the function before render the content.

This function should return promise which resolve days array or error.

renderDays(year, month, days){
  return new Promise((resolve, reject) => {
     //Do something
     resolve(days);
  });
}

onClick (optional)

If you pass this props to Days Calendar, it will pass the day object to the function before render the content. It will allow you control the behavior after click on any day.

onClick(day){
  console.log('This day is:', day);
}

Contributing

You can clone this repository then start develop at sandbox, or feel free to open issue on github.

Build package:

npm run build

Watch package change and build it:

npm run watch

days-calendar's People

Contributors

falconshark avatar

Watchers

James Cloos avatar  avatar

Forkers

limdblur

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.