Giter VIP home page Giter VIP logo

pro-calendar-vue's Introduction

Pro Calendar

Another one Best Professional Calendar ever

Install

npm i @lbgm/pro-calendar-vue

Screenshot with Native Datepicker

Pro-calendar-vue screenshot with native datepicker

Screenshot with VCalendar Datepicker

Pro-calendar-vue screenshot with vcalendar datepicker

Use

main.ts

import { ProCalendar } from "@lbgm/pro-calendar-vue";

//...

app.use(ProCalendar);

App.vue

<script setup lang="ts">
import "@lbgm/pro-calendar-vue/style";
import type { Configs } from "./stores/events";
import { ref, type Ref } from "vue";

const cfg = ref<Configs>({
  viewEvent: undefined,
  reportEvent: {
    icon: true,
    text: "",
  },
  searchPlaceHolder: "",
  eventName: "",
  closeText: "",
  nativeDatepicker: true, // false or undefined ---> use VCalendar DatePicker instead
});

const evts: Ref<Appointment[]> = ref([
  {
    date: "2022-11-19T14:00:00.000Z",
    comment: "",
    id: "cl32rbkjk1700101o53e3e3uhn",
    keywords: "Projet BAMBA",
    name: "MONTCHO Kévin",
  },
  //...
]);

</script>

<template>
<!-- all props are optional -->
<pro-calendar
  :events="evts"
  :loading="false"
  :config="cfg"
  view="week"
  date="'isoStringDate'"
  @calendarClosed="void 0"
  @fetchEvents="void 0"
/>
</template>

Props

export type T_Action = {
  icon?: boolean;
  text?: string;
}

export type Configs = {
  viewEvent?: T_Action;
  reportEvent?: T_Action;
  searchPlaceHolder?: string;
  eventName?: string;
  closeText?: string;
  nativeDatepicker?: boolean;
}

// interface
interface Props {
  date?: string | null;
  view?: string;
  events?: Appointment[];
  loading?: boolean;
  config?: Configs;
}

// defaults
{
  date: null,
  view: "",
  events: () => [],
  loading: false,
  config: () => ({
    viewEvent: {
      icon: true,
      text: "",
    },
    reportEvent: {
      icon: true,
      text: "",
    },
    searchPlaceHolder: "",
    eventName: "",
    closeText: "",
    nativeDatepicker: true, // false ---> use VCalendar DatePicker instead
  }),
}

Prop events type

type Appointment = {
  date: string; //DateIsoString
  comment?: string;
  createdAt?: string; //DateIsoString
  id: string;
  updatedAt?: string; //DateIsoString
  keywords: string;
  name: string;
}

events: Appointment[];

Prop view type

'day' | 'week' | 'month'

Events

@calendarClosed:

This event is fired when user clicks close button.

@fetchEvents:

This event is fired when date selected changes. $event: { start: string; end: string }. start and end are iso string date.

Slots

Draw your own calendars using scoped slots

<pro-calendar
  :events="evts"
  :loading="false"
  :config="cfg"
  view="week"
  date="'isoStringDate'"
>
  <template #leftSwitchArrow>
    <!-- replace left switch arrow with this slot -->
  </template>

  <template #rightSwitchArrow>
    <!-- replace left switch arrow with this slot -->
  </template>

  <template #closeButton>
    <!-- replace close button with this slot -->
  </template>

  <template #loader="{ calendarGotLoading }">
    <!-- replace calendar loader with this slot -->
  </template>

  <template #searchIcon>
    <!-- replace search widget icon with this slot -->
  </template>

  <template #dateLeftArrow>
    <!-- replace date picker left arrow with this -->
  </template>

  <template #dateRightArrow>
    <!-- replace date picker right arrow with this -->
  </template>

  <template #sideEvent="{ dateSelected, calendarEvents }">
    <!-- use this slot to show yourself side events in appearance you want -->
    <!--
      dateSelected: Date;
      calendarEvents: Appointment[]; // all events
    -->
  </template>

  <template #eventCard="{ date, time, cardEvent }">
    <!-- use this slot to show yourself calendar event in appearance you want -->
    <!--
      date: Date;
      time: string;
      cardEvent: Appointment[]; // events according to date/time
    -->
  </template>
</pro-calendar>

Custom Events fired

calendar.request.view & calendar.request.report

When the user clicks on view or report action, an custom html event is fired with the id of event in detail. You can listen these events like this:

<script setup lang="ts">
import { ref, onMounted } from "vue";

onMounted(() => {
  ["calendar.request.view", "calendar.request.report"].forEach((e: string) => {
    document.body.addEventListener(e, (event: Event | CustomEvent) => {
      console.log({ event });
    });
  });
});

</script>

On default #sideEvent template, when user clicks on event, calendar.request.view is fired.

pro-calendar-vue's People

Contributors

lbgm avatar marlonrochaa avatar

Watchers

 avatar

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.