Giter VIP home page Giter VIP logo

kalendar's Introduction

πŸ—“ Kalendar

npm version Open Source Love Open Source Love PRs Welcome

Your best friend when it comes to events management in Vue.

πŸ•Ή Live Demo

Kalendar Showcase

Running the Demo Locally

You can run the demo locally :

The code for the demo app is in src/serve-dev.vue - a small but complete calendar app. This is a good place to learn how thing work and a good starting point for your own implementation.

🏁Getting Started

  • Install plugin and its dependencies from npm
npm install kalendar-vue portal-vue -S
  • The easiest option is to copy the demo app from src/serve-dev.vue into your project and start from that.

Step by Step:

  • Import plugin and its dependencies in your component
import Vue from "vue";
import PortalVue from "portal-vue";
Vue.use(PortalVue);

import { Kalendar } from 'kalendar-vue';
...
components: {
	Kalendar,
	...
},
  • Provide Appointments array. This array will be the source of the appointments which are rendered in the calendar. Specify the start and end times of each appointment as ISO format strings. You must use the sync modifier when passing the configuration prop to the component or else switching weeks will break.
<template>
	<kalendar :configuration="calendar_settings" :events.sync="events" />
</template>
<script>
...
data: () => ({
    calendar_settings: {
      style: 'material_design',
      view_type: 'week',
      cell_height: 20,
      scrollToNow: true,
      start_day: new Date().toISOString(),
      read_only: false,
      day_starts_at: 0,
      day_ends_at: 24,
      overlap: true,
      hide_dates: ['2019-10-31'], // Spooky
      hide_days: [6],
      past_event_creation: true
    },
    events: [
      {
        from: '2020-03-18T18:00:00Z',
        to: '2020-03-18T19:00:00Z',
        data: 'Event 1',
      },
      {
        from: '2020-03-18T19:00:00Z',
        to: '2020-03-18T21:00:00Z',
        data: 'Olive & Friends',
      },
      ...
    ],
    ...
})
</script>

πŸŽ› Kalendar Options

Option Default Value Type Description
view_type 'week' string Determines the mode of kalendar. You can pick either 'week' or 'day'. Day is recommended for mobile devices.
cell_height 10 string Determines the height in pixels of a cell
start_day new Date().toISOString() string Determines the week or day which is shown in the kalendar on first load
style 'material_design' string You can pick either 'material_design' or 'flat_design' (iOS)
read_only false boolean Enabled, viewers won't be able to interact with kalendar
day_starts_at 0 integer Determines what hour the kalendar starts from (0 to 24)
day_ends_at 24 integer Determines what hour the kalendar ends at (0 to 24)
overlap true boolean Enables ability to create multiple events (overlapping) at the same timeframe
hide_dates [] Array Hides the provided dates from kalendar. Array of strings each being a valid date in YYYY-MM-DD format.
hide_days [6] Array Hides the provided days from kalendar. Monday = 0 ... Sunday = 6
past_event_creation true boolean Determines the ability of creating events that have happened in the past
scrollToNow true boolean Scroll kalendar to current time on render
formatLeftHours (date) => { return format(date, 'HH') } function A function which accepts an ISO date and determines how the hours on the left side are shown
formatDayTitle (date) => { return format(date, 'DDD dd') } function A function which accepts an ISO date and determines what the day column title shows
formatWeekNavigator (date) => { return ${startDate(date)} - ${endDate(date)}} function A function which accepts an ISO date and determines what the week view navigator (at the top) shows
formatDayNavigator (date) => { return new Date(date).toUTCString().slice(5, 11) } function A function which accepts an ISO date and determines what the day view navigator (at the top) shows

Using Slots

The plugin can turn incredibly useful using scoped slots. You can customize all the essential parts of it.

Slots summary

Slot name Slot scope Slot description
created-card event_information Display information about an existing event
creating-card event_information Display information about an event which is being created (mouse is being dragged)
popup-form popup_information Display information about a temporary event (after user finishes dragging the mouse)

event_information definition

Field Type Description
start_time String Start time as ISO Date String of the event
end_time String End time as ISO Date String of the event
kalendar_id String Unique ID used for operations internally by kalendar
key String Key of the event used internally by kalendar
data Object Data object which can hold any type of information which may prove useful for you

πŸ›£ Roadmap

  • ⚠️ Refactor so code is readable/understandable and others can help--
  • Add Read-Only mode
  • Remove date-fns dependency
  • Improve performance _ Hard-code split value to 5mins, and use split-value-prop to only mark current_min%split-value-prop === 0 _ Using upmentioned technique, day hours can be hardcoded into JSON, while the date part would come in from for in loop * Use event delegation and remove listeners from every cell. Use event target instead, to manipulate the cell DOM object.
  • Add month view
  • Write docs
  • Write unit-tests

kalendar's People

Contributors

altin-selimi avatar altinselimi avatar andrewhl avatar dependabot[bot] avatar dreglad avatar itsrawiththeh avatar magarrent avatar mserralta avatar tomscytale avatar wangqiang0121 avatar xlcrr 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

kalendar's Issues

Changing the cell height breaks the hour indicator

When changing the cell height, the hour indicator does not scale accordingly, resulting in an incorrect position of the indicator. This also affects the scrollToNow, as this function focusses on the hour indicator.

Attached is a screenshot with this issue. At the time of the screenschot it is 14:25, while the hour indicator shows it's about 20:45.

image

Overlapping events

Hi Altin,

Excellent component! Really impressed.

I would like to make an enhancement and need your guidance where to start. The current implementation does not position events correctly if they overlap. They are positioned directly over each other. It would be if they would be positioned next to each other. In other words, that there width would be halved. If you would like to test this you can add the following events to the codepen you provide.

  {
    from: "Tue Nov 05 2018 01:00:00",
    to: "Tue Nov 05 2018 03:00:00",
    date: "2018-11-05",
    data: {
      title: "My Birthday",
      description: "Lorem ipsum dolor sit amet."
    }
  },
  {
    from: "Tue Nov 05 2018 02:00:00",
    to: "Tue Nov 05 2018 04:00:00",
    date: "2018-11-05",
    data: {
      title: "My Birthday",
      description: "Lorem ipsum dolor sit amet."
    }
  }

To better see the result switch to day view.

An additional problem I have noticed that it is not possible to create an overlapping event. The schedule is not clickable.

Regards, nidkil

"TypeError: from.getHours is not a function"

image

I don't know why it's crashing all time!

app.js:8368 [Vue warn]: Error in callback for watcher "appointments": "TypeError: from.getHours is not a function"

found in

---> <Kalendar> at kalendar-container.vue

Navigation to Next or Previous Week Slow

Sweet library! @altinselimi

One issue I noticed is that the navigation between weeks is really slow when I added to my project. It takes about 4-7 seconds to load the next week, no existing appointments. Initial load of the component is quick. Everything else seems to work fine. No console errors.

Any idea what might be causing this? Navigation throughout my project is fast. Just this component.

scss is not scoped

The scss is not scoped, causing problems with styling when embedding Kalendar in a website.

click event

hi how to handle the click on the event ?( for editing or delete it ) i tried to add @click to details-card but it will not be fired

crypto.getRandomValues doesnt work on IE11

For IE11
the use of crypto as a global variable doesnt work on IE11 as crypto exists not as window.crypto but as window.msCrypto.

this can be fixed by adding const crypto = window.crypto || window.msCrypto; to kalendar-container and kalendar-cell.

Note, that if later adding type definitions or for users using typescript, the msCrypto would have to be added

declare global {
  interface Window{
    msCrypto: Crypto;
  }
}

Other options could be using non mscrypto polyfills such as https://github.com/gaswelder/window-crypto

Split current day from configuration

Split current_day from configuration and provide it as a separate prop. In the same time remove the need for .sync modifier on kalendar props.

Not able to add kalendar-vue dependency (dependencies were not found)

Created a new project cal with vue cli 3.0.0

vue create cal
npm install --save kalendar-vue

then in HelloWorld.vue added the following:

import { Kalendar } from 'kalendar-vue';
import 'kalendar-vue/dist/kalendar-vue.css';

It gave me the following error:

ERROR Failed to compile with 2 errors 08:35:51

These dependencies were not found:

  • kalendar-vue in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/HelloWorld.vue?vue&type=script&lang=js&
  • kalendar-vue/dist/kalendar-vue.css in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/vue-loader/lib??vue-loader-options!./src/components/HelloWorld.vue?vue&type=script&lang=js&

To install them, you can run: npm install --save kalendar-vue kalendar-vue/dist/kalendar-vue.css

Change period shown in day view

Hi Altin,

I would like to make a change to the day view that it is possible to limit the period of the day that is displayed. Now it displays the full day. I would like to limit it to a specific period, i.e. business hours (8:00-17:00).

Can you please provide me with guidance how to best approach this change?

Regards, Stephen

missing modules

I'm using vue as frontend with meteor and get this error after install npm i kalendar-vue -S:

"If you notice problems related to these missing modules, consider running:
meteor npm install --save kalendar-vue" over and over again

any suggestions ???

enhancement "requests"

Hi, this looks like an amazing lib that I'll probably end up using, just have 2 things that would be cool if they could be implemented in the future, maybe in that rewrite you're doing right now, there's no hurry as I'm in early dev-stage of my project right now

1: on the week/day views (side note: why is the config for week view 'month'?) would it be possible to have a date/week-picker to select the current range in addition to the navigation arrows?

2: would it at all be possible to implement events that can cross over midnight? currently you have a start and end time and a date property, the project I'm working out is going to be used in multiple timezones, so even when someone creates an event from 4pm till 10pm american time, that would be a '2 date event' when converted to a european timezone

Event time not positioned correctly

Hi Altin,

I have noticed that the event time is not positioned correctly. It falls outside the event area. You can test this with the codepen you provide using the following event.

  {
    from: "Tue Nov 05 2018 02:00:00",
    to: "Tue Nov 05 2018 04:00:00",
    date: "2018-11-05",
    data: {
      title: "My Birthday",
      description: "Lorem ipsum dolor sit amet."
    }
  }

The fix is pretty straight forward, changing the .existing-event .time from 12px to 50px. See below.

.existing-event .time {
    right: 50px;
}

Regards, nidkil

Mobile view?

Awesome component.

But i found a mobile view, checking on some mobile app agent. If we check the mobile views of the day there is no reason to check things like that. Maybe a media query to check the width of the browser. But i would prefer not to check those, Phones and tablets are wider than most modern desktops when checking.
https://www.w3schools.com/howto/howto_js_media_queries.asp

I just remove the media is mobile check in the element and everything worked better, maybe a touch drag in sync with the mouse down check to add.

When you add a overflow hidden on the .day-indicator class it still fits as it should :)

.day-indicator {
    padding-left: 5px;
    overflow: hidden;
    @media only screen and (min-width: 600px) {
        padding-left: 16px;
     }
}

Also would like to help. Don't know what the status is of the new developments. But if you know, please let us know here. Would like a nice standalone calendar for vue πŸ‘

range dates view

amazing design and functionalties.

I would like to know if i can change the range of hour of my calendar like from 8A.M. to 6P.M.

range date

normalizeDate

Hi!

I`m trying to use this compoment.
I already followed this repo tutorial and the codepen example. But i getting these errors:

Failed to resolve filter: normalizeDate

vue.esm.js?efeb:571 [Vue warn]: Unknown custom element: <portal> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

found in

---> <Kalendar> at kalendar-container.vue
       <Agenda> at src\components\agenda\Agenda.vue
         <VuesticLayout> at src\vuestic-theme\vuestic-components\vuestic-layout\VuesticLayout.vue
           <AppLayout> at src\components\admin\AppLayout.vue
             <App> at src\App.vue
               <Root>

Is there something i'm forgeting to add to my app?

Thanks in advance.

adjusting split_value responsively

Hi, I was wondering if I can upgrade the way split_value is handled recently.

Right now, in order to avoid problems in displaying appointments in my Calendar,
split_value is always equal to the greatest common divisor between my appointments durations.

Meaning if I have appointments with duration 15 min and another one with duration 20 min, split_value will equal 5 so all the appointments can be displayed without any error.

But this calculation is done globally among all my appointments, if I have 200 appointments with a duration of 20 minutes and 1 old appointment with a duration of 15 minutes, the split_value will still be 5, and it will be displayed like this for every day and every week shown in the calendar.

One way to enhance this that would be to calculate the geatest common divisor, not on all the appointments, but only on those that are displayed to the user. Thus the split_value would be calculated reactively to always match the greatest common divisor of the appointments displayed.

I saw that the component kalendar-week-view contains a computed property witch contains only the appointments displayed. Would it be possible to pass it via scoped-slots or events to parent component that contains the kalendar ?

I also saw that every time we change the week-view, there is a change event that is emitted. If the value of the dates that are displayed could be passed in this event, this could also be a way to retrieve info about dates that are actually displayed. So we can then calculate and optimise the split_value to be the greatest common divisor among the appointments that are showned.

BR

Add start_hour/end_hour support

The day view is always from 0 a.m. to 11 p.m. which is not always convenience, because we merely add event in the very early morning or too late in the night.
So I add start_hour/end_hour support to customize this behavior like the following snapshot.

image

Set start-date

Hi, I am unsure whether or not this is possible yet, but something like the ability to always have today's date as the left-most date and only see forwards in the calendar.

Cheers

Only events with start end time equal to the full hour supported

Hi Altin,

I ran into a problem that events that do not start or end on the full hour throw an error (Uncaught TypeError: r.getHours is not a function). The problem seems to be the following line in kalendar-container.vue.

let start_is_midnight = from.getHours() + from.getMinutes() === 0;

In the codepen you provide you can test this with the following event.

  {
    from: "Tue Nov 05 2018 01:00:00",
    to: "Tue Nov 05 2018 02:30:00",
    date: "2018-11-05",
    data: {
      title: "My Birthday",
      description: "Lorem ipsum dolor sit amet."
    }
  }

Regards, nidkil

Import CSS throws not found error

When doing this step,
import 'kalendar-vue/dist/KalendarVue.css';

I get the error
Module not found: Error: Can't resolve 'kalendar-vue/dist/kalendar-vue.css' in '/home/projectname/projectname/components'

Is there another way to import them, or should I just download the CSS?

Also, when using <kalendar :configuration="calendar_settings" :appointments="appointments"/>, is this all you need in the HTML part to make it render the calendar, or do you have to provide the full scoped slots stuff too?

Thanks.

Event cards are blank

I have set up a simple project and am pulling data from Google Calendar and passing it to Kalendar.

Kalendar creates event cards in the right places on the calendar but they are all blank. See attached image.
kalendar-empty-events

<template>
  <Kalendar :configuration="calendar_settings" :events="events" />
</template>

<script>
import Vue from 'vue';
import PortalVue from 'portal-vue';
import {Kalendar} from 'kalendar-vue';
Vue.use(PortalVue);

export default {
  name: 'Calendar',
  components: {
    Kalendar,
  },
  data: () => ({
    calendar_settings: {
      day_starts_at: 7,
      cell_height: 10,
      scrollToNow: true,
      read_only: false,
      past_event_creation: false
    },
   events: [
          {
      summary: 'B in M 🎀',
      start: { dateTime: '2020-03-18T18:00:00Z', timeZone: 'Europe/Dublin' },
      end: { dateTime: '2020-03-18T19:00:00Z', timeZone: 'Europe/Dublin' },
    },
    {
      summary: 'O & F 🎀',
      start: { dateTime: '2020-03-18T19:00:00Z', timeZone: 'Europe/Dublin' },
      end: { dateTime: '2020-03-18T21:00:00Z', timeZone: 'Europe/Dublin' },
    },
    ...  // many more
     ]
  }),

Start week on monday

Hi, is it possible to start the week on monday, it's the customary way to display a calendar in Europe.

Cheers

Disabling hours

Hello, how can I disable hours in the table? I just want to customize kalendar so I can assign some appointments for a whole day omitting hours. Thank you!

Kalendar + Firebase database

Hi everyone,

Ive 2 issues using this module with my firebase database.

First, the div "details-card" isn't being taken into account when im pulling appointments from my firebase database.

As you can see on the screenshot, appointments are being display, but when i'm using the following code in order to control what's inside the appointments blue rectangles, nothing is being display.

capture d ecran 2018-08-20 a 12 19 41

<div id='slot' slot="details-card" slot-scope="{appointment_props}">
            {{appointment_props.start_value.value | moment("add", "8 hours","hh:mm a")}} to 
             {{appointment_props.end_value.value | moment("add", "8 hours","hh:mm a")}}
 </div>

My second issue is that i want to be able to update or remove appointments when user clicks on them. It is related to the first issue obviously but its also related to the css of kalendar which indicated a "pointer-event:none" on the details-card.

Thanks very much in advance.

How to do new events Hourly?

Hey, when you select the hours for doing an event, you can choose with 10 min range, what if I only want hourly or 30 minutes rang?

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.