Giter Site home page Giter Site logo

grudus / timepicker Goto Github PK

View Code? Open in Web Editor NEW
14.0 3.0 2.0 163 KB

Material design timepicker in pure vanilla js

Home Page: https://grudus.github.io/Timepicker/

License: Apache License 2.0

CSS 9.47% JavaScript 90.53%
material-design material-ui material time timepicker timepickerdialog vanilla-javascript vanillajs css javascript js ecmascript6

timepicker's Introduction

Grudus Timepicker

npm downloads dependencies dev dependencies license

Material design timepicker written in Javascript (without any external dependencies - no jQuery, no Bootstrap, only one file!) See https://grudus.github.io/Timepicker/ for more usage!

How it looks?

By default picker uses blue-white theme:

Normal


But you can change its colors by overriding some of default configuration:
defaultConfig = {
    headerBackground: "#1976D2",
    headerColor: "#c7d6e1",
    headerSelected: "#ffffff",
    wrapperBackground: "#f0fff0",
    footerBackground: "#f0fff0",
    submitColor: "#1976D2",
    cancelColor: "#1976D2",
    clockBackground: "#CFD8DC",
    clockItemColor: "#212121",
    clockItemInnerColor: "#212121",
    handColor: "#1976D2"
};

How custom theme can look:

brave


But you can also create more user-friendly view - create your own dark theme:

dark


How to get it?

You can include all in single html file! Just add

<head>
  <link href="https://rawgit.com/grudus/Timepicker/master/dist/index.css" type="text/css" rel="stylesheet">
</head>
<body>
  <button onclick="Timepicker.showPicker()">Show picker</button>
</body>
<script type="text/javascript" src="https://rawgit.com/grudus/Timepicker/master/dist/grudus-timepicker.es5.js"></script>

Or, you can download it from npm

npm install --save grudus-timepicker

Then, include index.css into your project (e.g. add <link href="node_modules/grudus-timepicker/dist/index.css" rel="stylesheet" type="text/css"> into your html file)

And lastly, somewhere in your code put

import Timepicker from "path/to/grudus-timepicker/dist/grudus-timepicker.js";

// ...

 Timepicker.showPicker({
            time: new Date(),
            onSubmit: (time) => {
                //some action ...
            },
            headerColor: "#ff0000"       
            // more color configuration ...
        })

You can set initial time by passing time field in argument. time may be a Date object, an object {hours: 12, minutes: 44} or a string in format HH:mm. If you want to learn more, visit customization section

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.