All Projects → luncheon → clocklet

luncheon / clocklet

Licence: WTFPL license
An opinionated clock-style vanilla-js timepicker.

Programming Languages

typescript
32286 projects
HTML
75241 projects
stylus
462 projects
Pug
443 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to clocklet

popoPicker
popoPicker是一个移动端3D滚轮日期时间和单项的选择器,支持无限循环滚动,不依赖第三方库
Stars: ✭ 26 (-16.13%)
Mutual labels:  time, timepicker, picker
Vue Ctk Date Time Picker
VueJS component to select dates & time, including a range mode
Stars: ✭ 707 (+2180.65%)
Mutual labels:  time, timepicker, picker
Md Date Time Picker
An implementation of Material Design Picker components in vanilla CSS, JS, and HTML
Stars: ✭ 272 (+777.42%)
Mutual labels:  time, clock, picker
Amazing Time Picker
Timepicker (Clock Picker) for Angular 2, Angular 4 and Angular 5, Angular 6, Angular 7 - Compatible with Angular Material
Stars: ✭ 142 (+358.06%)
Mutual labels:  clock, timepicker, picker
vue-timeselector
🕒 Simply customizable powerful time picker for Vue.js
Stars: ✭ 41 (+32.26%)
Mutual labels:  time, timepicker, picker
Angular Moment Picker
Angular Moment Picker is an AngularJS directive for date and time picker using Moment.js.
Stars: ✭ 536 (+1629.03%)
Mutual labels:  time, timepicker, picker
ngx-mat-timepicker
A true material timepicker
Stars: ✭ 45 (+45.16%)
Mutual labels:  time, timepicker, picker
Pickadate.js
The mobile-friendly, responsive, and lightweight jQuery date & time input picker.
Stars: ✭ 7,753 (+24909.68%)
Mutual labels:  time, picker
Truetime Android
Android NTP time library. Get the true current time impervious to device clock time changes
Stars: ✭ 1,134 (+3558.06%)
Mutual labels:  time, clock
Use Timer
A timer hook for React
Stars: ✭ 113 (+264.52%)
Mutual labels:  time, clock
Date Picker
📅 Custom responsive date picker widget for Android, written in Kotlin.
Stars: ✭ 146 (+370.97%)
Mutual labels:  time, picker
React Timer Hook
React timer hook
Stars: ✭ 118 (+280.65%)
Mutual labels:  time, clock
time
The simplest but configurable online clock
Stars: ✭ 77 (+148.39%)
Mutual labels:  time, clock
React Picky Date Time
A react component for date time picker. Online demo examples
Stars: ✭ 31 (+0%)
Mutual labels:  time, picker
Vue Datetime
Mobile friendly datetime picker for Vue. Supports date and datetime modes, i18n and more.
Stars: ✭ 928 (+2893.55%)
Mutual labels:  time, timepicker
Vue Clock2
vue clock component 😀
Stars: ✭ 67 (+116.13%)
Mutual labels:  time, clock
Singledateandtimepicker
You can now select a date and a time with only one widget !
Stars: ✭ 921 (+2870.97%)
Mutual labels:  time, picker
Tzupdate
Set the system timezone based on IP geolocation
Stars: ✭ 130 (+319.35%)
Mutual labels:  time, clock
React Native Modal Datetime Picker
A React-Native datetime-picker for Android and iOS
Stars: ✭ 2,412 (+7680.65%)
Mutual labels:  time, picker
Brpickerview
BRPickerView 封装的是iOS中常用的选择器组件,主要包括:日期选择器(支持年月日、年月等15种日期样式选择,支持设置星期、至今等)、地址选择器(支持省市区、省市、省三种地区选择)、自定义字符串选择器(支持单列、多列、二级联动、三级联动选择)。支持自定义主题样式,适配深色模式,支持将选择器组件添加到指定容器视图。
Stars: ✭ 2,149 (+6832.26%)
Mutual labels:  time, picker

Clocklet

npm jsDelivr WTFPL

An opinionated clock-style vanilla-js timepicker.
Demo
clocklet capture image

Features

  • Keyboard and numpad friendly
    • Autocomplete - e.g. "1"->"01:00", "12"->"12:00", "1234"->"12:34"
    • Support up/down arrow key to increment/decrement
  • Mouse and touch friendly
    • 3 clicks are sufficient to pick a time - am/pm, hour, minute
    • Click targets often used are large enough
    • No need to scroll
  • Declarative usage
  • Vanilla JS - no need jQuery or any other frameworks
  • Lightweight (CSS + JS ~ 7kB gzipped)

Installation

via npm (with a module bundler)

$ npm install clocklet
import "clocklet/css/clocklet.min.css";
import clocklet from "clocklet";

via CDN

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/css/clocklet.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]"></script>
<script>/* `window.clocklet` object is available */</script>

Download directly

clocklet.min.css
clocklet.min.js

Usage

Place <input> elements having data-clocklet attribute (either before or after loading the clocklet script).
When these elements get focused, the timepicker popups.

<input data-clocklet>

CodePen

Options

Default options

Default options can be set as properties of clocklet.defaultOptions object.
Option names must be described in camelCase.

clocklet.defaultOptions.zIndex = 9999;
clocklet.defaultOptions.format = "hh:mm a";

Element-specific options

Element-specific options can be specified as semicolon-separated data-clocklet attribute value.
Option names must be described in kebab-case.

<input data-clocklet="class-name: my-clocklet-style; placement: top;">

Available options

Name Type Default Description
class-name string "" Class name to set to the root element of the popup.
format string "HH:mm" Time format (template) of the input element.
Some tokens are replaced with the selected time value.
See the format tokens section below.
placement "top" | "bottom" "bottom" Popup placement.
alignment "left" | "center" | "right" "left" Popup alignment.
append-to "body" | "parent" "body" The parent element into which the popup element will be inserted.
z-index number | string "" Popup z-order.
If this value is an empty string, (1 + z-index of the input element) is used.

Format tokens

Token Range Description
H "0" .. "23" Hour in 0-based 24-hour notation with no padding.
HH "00" .. "23" Hour in 0-based 24-hour notation with zero padding.
_H " 0" .. "23" Hour in 0-based 24-hour notation with space padding.
h "1" .. "12" Hour in 1-based 12-hour notation with no padding.
hh "01" .. "12" Hour in 1-based 12-hour notation with zero padding.
_h " 1" .. "12" Hour in 1-based 12-hour notation with space padding.
k "1" .. "24" Hour in 1-based 24-hour notation with no padding.
kk "01" .. "24" Hour in 1-based 24-hour notation with zero padding.
_k " 1" .. "24" Hour in 1-based 24-hour notation with space padding.
m "0" .. "59" Minute with no padding.
mm "00" .. "59" Minute with zero padding.
_m " 0" .. "59" Minute with space padding.
a "am" | "pm" Post or ante meridiem abbreviation in lowercase without periods.
aa "a.m." | "p.m." Post or ante meridiem abbreviation in lowercase with periods.
A "AM" | "PM" Post or ante meridiem abbreviation in uppercase without periods.
AA "A.M." | "P.M." Post or ante meridiem abbreviation in uppercase with periods.

Events

Following events are raised on the input element by this library.

Type Cancelable event.details Description
clocklet.opening true { options: {...} } Raised before showing the clocklet popup.
clocklet.opened false { options: {...} } Raised after showing the clocklet popup.
clocklet.closing true {} Raised before hiding the clocklet popup.
clocklet.closed false {} Raised after hiding the clocklet popup.
input false undefined Raised after changing the input value.

For example:

<input id="my-clocklet" data-clocklet>
<script>
  document
    .getElementById("my-clocklet")
    .addEventListener("clocklet.opening", function (event) {
      console.log(event.details.options);
      if (DO_NOT_NEED_TIMEPICKER) {
        event.preventDefault();
      }
    });
</script>

API

clocklet.defaultOptions

See default options section.

clocklet.open(inputElement[, options])

Show the timepicker for the specified inputElement with the options (optional).

clocklet.close()

Hide the timepicker.

clocklet.inline(containerElement[, { input, format }])

Place the timepicker into the containerElement.
The optional parameter is the binding setting for the input element.

License

WTFPL

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].