Giter Site home page Giter Site logo

xgscripter / vanilla-calendar-pro Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uvarov-frontend/vanilla-calendar-pro

0.0 0.0 0.0 1.17 MB

Vanilla Calendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependencies.

Home Page: https://vanilla-calendar.pro

License: MIT License

JavaScript 27.08% TypeScript 53.87% CSS 18.42% HTML 0.63%

vanilla-calendar-pro's Introduction

VanillaCalendar - A Lightweight, Feature-Rich JavaScript Date and Time Picker

vanilla-calendar preview

version tests downloads

VanillaCalendar is a versatile JavaScript date and time picker with TypeScript support, making it compatible with any JavaScript framework or library. It is designed to be lightweight, simple to use, and feature-rich without relying on external dependencies.

Key Features

  • Lightweight: The final minified .js file is only approximately 37.3 KB, and with gzip compression, it's just around 9.9 KB.
  • No Dependencies: VanillaCalendar is entirely self-contained, ensuring you don't need to include additional libraries.
  • Simple Localization: Supports simple localization for any language.
  • Customizable: Can be easily configured using CSS and HTML markup.
  • Multiple Instances: Allows for an unlimited number of calendar instances on a single page.
  • Theme Support: Includes two themes - the light theme and the dark theme.
  • Week Start Customization: Supports both Sunday and Monday as the beginning of the week.
  • Week Number Display: Can display week numbers throughout the year.
  • Not Tied to Input Tags: Unlike many date pickers, it's not limited to the <input> tag.

Browser Support

VanillaCalendar is compatible with a wide range of browsers:

Chrome Firefox Edge Opera Safari
57+ ✔ 52+ ✔ 80+ ✔ 44+ ✔ 10.1+ ✔

Support and Feedback

This plugin is completely free, and your support is important. Please feel free to report any issues or share your new ideas; it's really important!

If you like VanillaCalendar, please consider giving it a 🌟 star on GitHub.

Getting Started

Installation

You can install VanillaCalendar using npm or yarn:

npm install vanilla-calendar-pro
# or
yarn add vanilla-calendar-pro

If you prefer not to use a package manager, you can also include it via CDN or download it from the website.

Usage

Here's a simple example of how to use VanillaCalendar in your HTML:

<html>
  <head>
  </head>
  <body>
    <div id="calendar"></div>
    <!-- or -->
    <!-- <input type="text" id="calendar-input"> -->
  </body>
</html>

To add the necessary styles and scripts, you can use the following code:

import VanillaCalendar from 'vanilla-calendar-pro';
import 'vanilla-calendar-pro/build/vanilla-calendar.min.css';

// Initialize the calendar
const calendar = new VanillaCalendar('#calendar');
calendar.init();
// or
// const calendarWithInput = new VanillaCalendar('#calendar-input', { input: true });
// calendarWithInput.init();

If you're not using a package manager and prefer manual installation or CDN usage, you can include the necessary files in your HTML document's <head>:

<html>
  <head>
    <link href="./vanilla-calendar.min.css" rel="stylesheet">
    <script src="./vanilla-calendar.min.js" defer></script>
  </head>
  <body>
    <div id="calendar"></div>

    <script>
      document.addEventListener('DOMContentLoaded', () => {
        const calendar = new VanillaCalendar('#calendar');
        calendar.init();
      });
    </script>
  </body>
</html>

CSS Themes

// Only layout calendar
import 'vanilla-calendar-pro/build/vanilla-calendar.layout.min.css';

// Themes
import 'vanilla-calendar-pro/build/themes/light.min.css';
import 'vanilla-calendar-pro/build/themes/dark.min.css';

VanillaCalendar includes two CSS themes: the light theme and the dark theme.

  • The vanilla-calendar.min.css file contains all styles with all themes.
  • The vanilla-calendar.layout.min.css file contains the essential structural styles for the calendar.
  • The themes/light.min.css theme provides a light color scheme.
  • The themes/dark.min.css theme offers a dark color scheme.

The calendar will automatically display the theme according to the user's system preferences. If you want to apply a specific theme, it is recommended to import «vanilla-calendar.layout.min.css» along with the theme you prefer: «light.min.css» or «dark.min.css», instead of «vanilla-calendar.min.css».

DOM Templates

VanillaCalendar features customizable DOM templates that allow you to modify the structure of the calendar to fit your needs. The templates are identified by tags containing the # character, and they should include a trailing slash at the end.

Here's an example of the default template:

new VanillaCalendar('#calendar', {
  DOMTemplates: {
    default: `
      <div class="vanilla-calendar-header">
        <#ArrowPrev />
        <div class="vanilla-calendar-header__content">
          <#Month />
          <#Year />
        </div>
        <#ArrowNext />
      </div>
      <div class="vanilla-calendar-wrapper">
        <#WeekNumbers />
        <div class "vanilla-calendar-content">
          <#Week />
          <#Days />
        </div>
      </div>
      <#ControlTime />
    `
  }
});

React Component

For detailed instructions on using VanillaCalendar in a React component with TypeScript, please visit the website for comprehensive documentation and examples.

API Reference

For detailed information on the available parameters and settings, please refer to the API reference.

Sponsor

This project is tested with BrowserStack.

License

MIT License

Author

Yury Uvarov ([email protected])

vanilla-calendar-pro's People

Contributors

uvarov-frontend avatar efatsi avatar bkyaro avatar whataboutpereira 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.