All Projects → motss → App Datepicker

motss / App Datepicker

Licence: mit
Datepicker element built with Google's lit-element and Material Design 2

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to App Datepicker

Vaadin
An evolving set of open source web components for building mobile and desktop web applications in modern browsers.
Stars: ✭ 424 (+198.59%)
Mutual labels:  webcomponents, polymer
Redux Store Element
A custom element allowing a more declarative use of Redux.
Stars: ✭ 83 (-41.55%)
Mutual labels:  webcomponents, polymer
Vaadin Form Layout
The Web Component providing configurable responsive layout for form elements. Part of the Vaadin components.
Stars: ✭ 15 (-89.44%)
Mutual labels:  webcomponents, polymer
Google Chart
Google Charts API web components
Stars: ✭ 284 (+100%)
Mutual labels:  webcomponents, polymer
Frontend
🍭 Frontend for Home Assistant
Stars: ✭ 1,366 (+861.97%)
Mutual labels:  webcomponents, polymer
Vaadin Core
An evolving set of free, open source web components for building mobile and desktop web applications in modern browsers.
Stars: ✭ 382 (+169.01%)
Mutual labels:  webcomponents, polymer
Login Fire
An element that allows simple configuration of multiple provider login for firebase
Stars: ✭ 58 (-59.15%)
Mutual labels:  webcomponents, polymer
vaadin-icons
Vaadin Icons is a collection of 600+ unique icons designed for web applications
Stars: ✭ 59 (-58.45%)
Mutual labels:  polymer, webcomponents
The Grid
Grid layout custom element with drag and drop capabilities
Stars: ✭ 122 (-14.08%)
Mutual labels:  webcomponents, polymer
Highcharts Chart
Polymer Element wrapper for highcharts library. Seamlessly create various types of charts from one element.
Stars: ✭ 97 (-31.69%)
Mutual labels:  webcomponents, polymer
Apollo Elements
🚀🌛 Use the Launch Platform 👩‍🚀👨‍🚀
Stars: ✭ 278 (+95.77%)
Mutual labels:  webcomponents, polymer
Webdash
🔥 Orchestrate your web project with Webdash the customizable web dashboard
Stars: ✭ 1,528 (+976.06%)
Mutual labels:  webcomponents, polymer
vaadin-text-field
The themable Web Component providing input controls. Part of the Vaadin components.
Stars: ✭ 29 (-79.58%)
Mutual labels:  polymer, webcomponents
Awesome Polymer
A collection of awesome Polymer resources.
Stars: ✭ 384 (+170.42%)
Mutual labels:  webcomponents, polymer
polymerx-cli
⚡ Unlock the power of Polymer 3, Web Components and modern web tools.
Stars: ✭ 30 (-78.87%)
Mutual labels:  polymer, webcomponents
Gwt Api Generator
Generator for creating GWT JSInterop clients from Polymer Web Components
Stars: ✭ 49 (-65.49%)
Mutual labels:  webcomponents, polymer
material-datepicker
Material Datepicker
Stars: ✭ 29 (-79.58%)
Mutual labels:  polymer, datepicker
dom-repeat-n
[Polymer 1.x] A template element that repeat n times its content.
Stars: ✭ 20 (-85.92%)
Mutual labels:  polymer, webcomponents
Vaadin Upload
The Web Component for uploading multiple files with progress indication. Part of the Vaadin components.
Stars: ✭ 87 (-38.73%)
Mutual labels:  webcomponents, polymer
Wc Loader
🚽 Webcomponents webpack loader.
Stars: ✭ 101 (-28.87%)
Mutual labels:  webcomponents, polymer

app-datepicker

Datepicker element built with lit-element and Material Design 2


Buy Me A Coffee tippin.me Follow me

Version lit-element Node version MIT License

Downloads Total downloads Packagephobia Bundlephobia

ci Sauce Labs Dependency Status

codebeat badge Language grade: JavaScript Code of Conduct

A different way of datepicker-ing on the web.

💯 Also, featured in awesome-lit-html.

This marks another completion of an important milestone of app-datepicker with all the love from the Web Components community in making this element great and wonderful. As Web Components getting more and more traction and better at providing a web standard way of creating shareable components, it plays an important role in the JavaScript community as many developers depend on a plethora of development tools written in JavaScript for the web to create a better developer experience when developing a library, a component, or even a large scalable application.

app-datepicker

Today, app-datepicker has been completely rewritten to adapt to the best of both worlds by leveraging the modern technologies the community most familiar with since year 2018.

The following are the list of tools used that makes it shine:

  1. TypeScript
  2. lit-element

Table of contents

Pre-requisite

  • ES2019 (The element is compiled with features targeting ES2019, so it might not work properly without transpilation on older browsers.)
  • lit-element >= 2.2.1
  • [OPTIONAL] TypeScript >= 3.8.3 (TypeScript users only)

Installation

  • NPM

    $ npm i app-datepicker
    
  • Alternatively, it can be downloaded from any of the following awesome CDNs:

    1. jsdelivr (ESM)
    2. unpkg (ESM)

How to use

Polyfills

Please make sure you have all these features available on the browsers you are supporting. If no, please consider polyfill-ing in order to run the datepicker element.

The following snippet shows a simple script used in the demo to load polyfills via feature detection on different browsers:

<script>
  if (null == Array.prototype.find) {
    Object.defineProperty(Array.prototype, 'find', {
      value: function arrayFind(cb) {
        var filtered = this.filter(cb);
        return !filtered.length ? void 0 : filtered[0];
      },
    });
  }

  if (!window.Intl) {
    var wa = document.createElement('script');
    /** FIXME: Pin package version due to https://github.com/andyearnshaw/Intl.js/issues/256 */
    wa.src = 'https://unpkg.com/[email protected]/dist/Intl.complete.js';
    wa.onload = function onLoad() { console.info('🌐 Intl polyfill loaded'); };
    wa.onerror = console.error;
    document.head.appendChild(wa);
  }
</script>

my-app.ts

/**
 * Say you've already installed the element via NPM, simply import the package to your application.
 * Here I'm using `lit-element` for developing my application.
 */
import { css, customElement, html, LitElement } from 'lit-element';
import 'app-datepicker';

@customElement(MyApp.is)
export class MyApp extends LitElement {
  static is() { return 'my-app'; }

  static styles = [
    css`
    :host {
      display: block;
    }

    * {
      box-sizing: border-box;
    }
    `
  ];

  protected render() {
    return html`<app-datepicker></app-datepicker>`;
  }
}

index.html

<!doctype html>
<html>
  <!-- Using ES modules to load the app -->
  <script type="module" src="/my-app.js"></script>
  ...
  <body>
    <my-app>
      <!-- <AppDatepicker> will be rendered when <MyApp> loads. -->
    </my-app>
  </body>
  ...
</html> 

Browser compatibility

Both app-datepicker and app-datepicker-dialog works in last 2 versions of all evergreen browsers (Chrome, Firefox, Edge, and Safari). Internet Explorer 11 is no longer supported in favor of the new Microsoft Edge.

Tested on the following browsers:

Name OS
Chrome 79 Windows 10
Edge 18 Windows 10
Firefox 72 Windows 10
Safari 13 mac 10.13

Q&A

  1. Does it work well with material-components-web-components?

    For material-components-web-components users, you can create your own custom date picker element by wrapping app-datepicker inside mwc-dialog.

    // Simplified code snippet
    
    class MWCDatePicker extends LitElement {
      render() {
        return html`
        <mwc-dialog>
          <app-datepicker></app-datepicker>
    
          <mwc-button slot="secondaryAction" dialogAction="cancel">cancel</mwc-button>
          <mwc-button slot="primaryAction" dialogAction="set">set</mwc-button>
        </mwc-dialog>
        `;
      }
    }
    
  2. How can I hide the focus outline?

    For a11y reason, focus outline is shown when a calendar day is being focused. However, this can be modified via CSS Shadow Parts.

    /**
     * Hide focus ring.
     * 
     * NOTE: It is recommended to come up with alternative styling for focus state
     * instead of just hiding the focus ring.
     */
    app-datepicker::part(calendar-day):focus {
      outline: none;
    }
    

API references

Demo

Configurable demo powered by Firebase

Older versions

Meantime, feel free to check the older version out at:

  1. 2.x branch - Built with Material Design and Polymer 2, published at Bower.
  2. 3.x branch - Built with Material Design and Polymer 3, published at NPM.

License

MIT License © Rong Sen Ng

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].