Coder Social home page Coder Social logo

zhibirc / excale Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 1.19 MB

:calendar: Simple and solid implementation of Calendar UI component

License: MIT License

JavaScript 70.04% HTML 8.81% CSS 21.15%
calendar calendar-component calendar-widget date-picker datepicker datepicker-component time-picker timepicker

excale's Introduction

GitHub Maintenance GitHub package.json version GitHub file size in bytes

Express Calendar

Simple and solid implementation of Calendar UI component.

Core ideas:

  • zero-dependency;
  • often times customization flexibility is more important than a variety of out-of-the-box features, amount of which is often not enough for project purposes, so the first goal was to provide the most basic implementation, but extendable enough in the same time to build more features on top;
  • some basic concepts such as show/hide methods are omitted, because in modular UI they expect to be present in prototype chain, like basic component module;
  • realization is in OOP-style, so users can instantiate as many independents calendars as they want;
  • resulting bundle size is one of project priorities so some syntax constructions and architectural decisions sometimes may look strange (google "abnormal programming").

Install

npm i excale

API

Public

Property Type Scope Arguments Purpose
date [object Date] self - Current date.
events [object Object] self - User-level subscriptions.
$node [object HTMLDivElement] self - Root DOM element of instance for extended customization.
scroll [object Function] prototype direction Scroll/switch to the previous/next month.
DIRECTION_PREVIOUS [object Symbol] static getter - Predefined constant for specify backward direction.
DIRECTION_NEXT [object Symbol] static getter - Predefined constant for specify forward direction.

Initial config

Property Type Required Defaults Purpose
year [object Number] no Current year. Year for initial setup.
month [object Number] no Current month. Month for initial setup.
day [object Number] no Current day. Day to highlight on initial setup.
bindTo HTMLElement yes - HTML element that will determine the location of instance node.
className [object String] no Empty string ''. User-defined class name of instance node.
events [object Object] no Empty object {}. User's subscriptions to interested events.

Example:

const Excale = require('excale');
const excale = new Excale({
    year:  2020,
    month: 4,
    day:   1,

    bindTo: document.getElementById('calendar'),

    className: 'be-my-calendar',

    events: {
        scroll: (direction, dateFrom, dateTo) => {
            console.info(`Scroll ${['back', 'for'][direction]}ward from ${dateFrom} to ${dateTo}.`);

            /* do some cool stuff */
        }
    }
});

License

excale is MIT licensed.

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.