Giter Site home page Giter Site logo

grudus / timepicker Goto Github PK

View Code? Open in Web Editor NEW
13.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

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

timepicker's People

Contributors

grudus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

timepicker's Issues

I would like to contribute for this repo

Hi there.
I am Currently checking this repo, and I think that this library is really useful to a project that I'm working. I would like to contribute for some features that could be aren't enables. For example AM, PM formater. Let me know if I can to do some pull request with those features.

Question about Error

Hi there!

Love the Timepicker :)

How would you handle the "Error: There is already one running grudus-timepicker instance!"-error?

Is there an onError or something?

Or maybe a TimePicker.hidePicker()? That would also do the trick

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.