Giter Site home page Giter Site logo

codekraft-studio / vue-calendar Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 157 KB

A moment based calendar for Vue

License: MIT License

JavaScript 15.21% Vue 47.64% CSS 35.72% HTML 1.44%
vuejs vue-calendar vue-plugin vue-components moment-js calendar calendar-component

vue-calendar's Introduction

vue-calendar

A fully customizable versatile calendar with events support

NPM version Dependency Status

This project is still in development so api and features might change.

Installation

Download the project using your favourite package manager:

npm i @codekraft-studio/vue-calendar
yarn add @codekraft-studio/vue-calendar

Import it in your project and install it in your application:

import Vue from 'vue'

// component and styles
import '@codekraft-studio/vue-calendar/dist/VueCalendar.css'
import VueCalendar from '@codekraft-studio/vue-calendar'

Vue.use(VueCalendar, options)

It's all ready, you can use the <VueCalendar /> component.

<body id="app">
  <VueCalendar />
</body>

Customization

The calendar is very flexible and allow for sections customization using named slots or full section replacements.

For example if you want to place a image above the calendar header you can do it like this:

<VueCalendar>
  <div slot="header-top">
    <img src="path/to/img" />
  </div>
</VueCalendar>

If you use the section name as the slot name, it will fully replace the section letting you fully customize the output:

<VueCalendar>
  <div slot="header" slot-scope="slotProps">
    <div class="my-header-top"></div>
    <div class="my-header-content">
      <!-- your custom toolbar -->
    </div>
    <div class="my-header-bottom"></div>
  </div>
</VueCalendar>

Right now you can only customize the calendar header and footer, below the list of the slot names:

header

The header is where the calendar toolbar is usually located, it exposes two child slots for upper and lower content placement.

  • header-top
  • header-bottom

footer

The footer is usually used to put arbitrary text, it exposes two child slots for upper and lower content placement.

  • footer-top
  • footer-bottom

Methods

The calendar is built on top of momentjs so it's very easy to control the dates and the calendar itself exposes few methods to change the date view and move around the calendar:

prev(unit, len=1)

Change the date to the next unit updating the calendar. By default it will add or remove only one unit, the second parameter is to choose how far to move previous.

this.$refs.Calendar.prev('m')
this.$refs.Calendar.prev('month', 2)

next(unit, len=1)

Change the date to the next unit updating the calendar. By default it will add or remove only one unit, the second parameter is to choose how far to move next.

this.$refs.Calendar.next('y')
this.$refs.Calendar.next('year', 2)

setDate(date)

This method update the calendar current date, it will trigger a calendar view change if the date is not inside the current sliced view, it accepts what momentjs accepts as a valid date, so a string, object and more.. checkout momentjs documentation to know more about it.

this.$refs.Calendar.setDate() // default to now
this.$refs.Calendar.setDate(new Date())
this.$refs.Calendar.setDate('tomorrow')
this.$refs.Calendar.setDate('09-08-2018')
this.$refs.Calendar.setDate('09-08-2018', 'MM-DD-YYYY')
this.$refs.Calendar.setDate('09/08/2018', 'MM/DD/YYYY')

The arguments are forwarded to momentjs parse function, checkout all the valid formats.


Development

Clone the project repository and install all the dependencies than start the vuecli development server:

npm install
npm run serve

License

This package is under the MIT License.

vue-calendar's People

Watchers

 avatar  avatar

vue-calendar's Issues

Support for multiple date selection

When the calendar is in multiple mode and is editable when dates are clicked they should be added to the selected dates array and returned to the user.

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.