input-duration 3.0.1 → 3.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -59,12 +59,12 @@ The control's styles are scoped inside its Shadow DOM, so global styles and rese
59
59
  <div>
60
60
  </div>
61
61
  <div align="center">
62
- <a href="https://codesandbox.io/s/peaceful-waterfall-6mxpg2?file=/index.html" target="_blank">
62
+ <a href="https://stephanluis.github.io/input-duration/" target="_blank">Demo</a>
63
+ ·
64
+ <a href="https://codesandbox.io/s/peaceful-waterfall-6mxpg2?file=/index.html" target="_blank">
63
65
  Fiddle
64
66
  </a> ·
65
- <a href="https://6mxpg2.csb.app/" target="_blank">Demo</a>
66
- ·
67
- <a href="https://stephanluis.github.io/input-duration/" target="_blank">Live demo</a>
67
+ <a href="https://6mxpg2.csb.app/" target="_blank">Fiddle's Output</a>
68
68
  ·
69
69
  <a href="https://stephanluis.github.io/input-duration/" target="_blank">Docs</a>
70
70
  ·
package/docs/index.html CHANGED
@@ -9,13 +9,13 @@
9
9
  :root {
10
10
  color-scheme: light;
11
11
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
12
- color: #17201c;
13
- background: #f5f7f3;
12
+ color: #172b45;
13
+ background: #eef6ff;
14
14
  font-synthesis: none;
15
15
  text-rendering: optimizeLegibility;
16
- --green: #176b4a;
17
- --muted: #64716a;
18
- --line: #dce4dd;
16
+ --blue: #2563a6;
17
+ --muted: #536b84;
18
+ --line: #d2e2f2;
19
19
  }
20
20
 
21
21
  * {
@@ -39,9 +39,35 @@
39
39
  text-align: center;
40
40
  }
41
41
 
42
+ .brand {
43
+ display: inline-flex;
44
+ align-items: center;
45
+ gap: 9px;
46
+ margin-bottom: 24px;
47
+ color: var(--blue);
48
+ }
49
+
50
+ .brand-icon {
51
+ width: 30px;
52
+ height: 34px;
53
+ flex: 0 0 auto;
54
+ }
55
+
56
+ .brand-tag {
57
+ padding: 6px 10px;
58
+ border: 1px solid #c8def4;
59
+ border-radius: 8px;
60
+ background: #fff;
61
+ color: #244e7a;
62
+ font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
63
+ font-size: .95rem;
64
+ font-weight: 650;
65
+ letter-spacing: -.04em;
66
+ }
67
+
42
68
  .eyebrow {
43
69
  margin: 0 0 14px;
44
- color: var(--green);
70
+ color: var(--blue);
45
71
  font-size: .78rem;
46
72
  font-weight: 750;
47
73
  letter-spacing: .12em;
@@ -67,10 +93,10 @@
67
93
  display: inline-block;
68
94
  margin-top: 20px;
69
95
  padding: 10px 15px;
70
- border: 1px solid #d6e8dc;
96
+ border: 1px solid #c8def4;
71
97
  border-radius: 999px;
72
- background: #eaf4ed;
73
- color: #25513b;
98
+ background: #e1efff;
99
+ color: #244e7a;
74
100
  font-size: .95rem;
75
101
  font-weight: 650;
76
102
  }
@@ -90,12 +116,12 @@
90
116
  border: 1px solid var(--line);
91
117
  border-radius: 18px;
92
118
  background: #fff;
93
- box-shadow: 0 12px 32px rgb(23 32 28 / 5%);
119
+ box-shadow: 0 12px 32px rgb(35 79 125 / 7%);
94
120
  }
95
121
 
96
122
  article.duration {
97
- border-color: #b7d9c4;
98
- box-shadow: 0 12px 32px rgb(23 107 74 / 9%);
123
+ border-color: #a9cbed;
124
+ box-shadow: 0 12px 32px rgb(37 99 166 / 12%);
99
125
  }
100
126
 
101
127
  .card-label {
@@ -126,7 +152,7 @@
126
152
  align-items: center;
127
153
  margin: 0 0 18px;
128
154
  padding: 8px 12px;
129
- border: 1px solid #bdc9c0;
155
+ border: 1px solid #b8cde2;
130
156
  border-radius: 10px;
131
157
  background: #fff;
132
158
  }
@@ -141,7 +167,7 @@
141
167
  }
142
168
 
143
169
  input[type="time"]:focus-visible {
144
- outline: 2px solid var(--green);
170
+ outline: 2px solid var(--blue);
145
171
  outline-offset: 3px;
146
172
  }
147
173
 
@@ -153,7 +179,7 @@
153
179
 
154
180
  .result {
155
181
  margin: auto 0 0;
156
- color: #33463a;
182
+ color: #334c69;
157
183
  font-size: .94rem;
158
184
  line-height: 1.5;
159
185
  }
@@ -163,7 +189,7 @@
163
189
  }
164
190
 
165
191
  .duration .result strong {
166
- color: var(--green);
192
+ color: var(--blue);
167
193
  }
168
194
 
169
195
  footer {
@@ -175,7 +201,7 @@
175
201
  }
176
202
 
177
203
  a {
178
- color: var(--green);
204
+ color: var(--blue);
179
205
  font-weight: 650;
180
206
  }
181
207
 
@@ -199,17 +225,23 @@
199
225
  <body>
200
226
  <main>
201
227
  <header>
202
- <p class="eyebrow">A small input, a very different question</p>
228
+ <div class="brand" role="img" aria-label="input-duration">
229
+ <svg class="brand-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" aria-hidden="true">
230
+ <path fill="currentColor" d="M393.9 184l22.6-22.6c4.7-4.7 4.7-12.3 0-17l-17-17c-4.7-4.7-12.3-4.7-17 0l-20.7 20.7c-31.1-27.5-70.4-45.9-113.8-50.8V48h28c6.6 0 12-5.4 12-12V12c0-6.6-5.4-12-12-12H172c-6.6 0-12 5.4-12 12v24c0 6.6 5.4 12 12 12h28v49.4C96.4 109.3 16 197.2 16 304c0 114.9 93.1 208 208 208s208-93.1 208-208c0-44.7-14.1-86.1-38.1-120zM224 464c-88.4 0-160-71.6-160-160s71.6-160 160-160 160 71.6 160 160-71.6 160-160 160zm12-112h-24c-6.6 0-12-5.4-12-12V204c0-6.6 5.4-12 12-12h24c6.6 0 12 5.4 12 12v136c0 6.6-5.4 12-12 12z"/>
231
+ </svg>
232
+ <span class="brand-tag">&lt;input-duration&gt;</span>
233
+ </div>
234
+ <p class="eyebrow">A small input, solves a very big problem</p>
203
235
  <h1>Time is not a duration.</h1>
204
- <p class="intro">You need to set a maintenance window. It’ll take 30 hours. Surely a time picker can handle that?</p>
205
- <p class="scenario">The task: run for 30 hours</p>
236
+ <p class="intro">You need to set a maintenance window. It’ll take 30 hours and 42 milliseconds. Surely a time picker can handle that?</p>
237
+ <p class="scenario">The task: run X for 30 hours and 42 milliseconds</p>
206
238
  </header>
207
239
 
208
240
  <section class="comparison" aria-label="Compare a time-of-day input with a duration input">
209
241
  <article>
210
- <p class="card-label">The time picker</p>
211
- <h2>“What time is it?”</h2>
212
- <p class="card-copy">HTML's built-in time input asks for a time of day—not an elapsed duration. The clock has other plans.</p>
242
+ <p class="card-label">The problem</p>
243
+ <h2>&lt;input type="time"&gt;</h2>
244
+ <p class="card-copy">Native HTML inputs are for times of day . Try setting this to 30 hours and 42 milliseconds. A time picker only accepts a time of day.</p>
213
245
  <label class="field" for="clock-time">
214
246
  <input id="clock-time" type="time" value="06:00" step="60">
215
247
  </label>
@@ -217,22 +249,22 @@
217
249
  </article>
218
250
 
219
251
  <article class="duration">
220
- <p class="card-label">The duration input</p>
221
- <h2>“How long does it take?”</h2>
222
- <p class="card-copy">HTML has no built-in duration input. This one handles 30 hours, with a fixed HH:mm:ss.SSS display.</p>
223
- <input-duration id="duration" role="group" aria-label="Duration in hours, minutes, seconds, and milliseconds" value="30:00:00.000"></input-duration>
224
- <p class="result" id="duration-result" aria-live="polite"><strong>30:00:00.000</strong> — a 30-hour duration, exactly as requested.</p>
252
+ <p class="card-label">The solution</p>
253
+ <h2>&lt;input-duration&gt;</h2>
254
+ <p class="card-copy">HTML has no built-in duration input. This web component handles 30 hours, plus those cheeky 42 milliseconds.</p>
255
+ <input-duration id="duration" role="group" aria-label="Duration in hours, minutes, seconds, and milliseconds" value="30:00:00.042"></input-duration>
256
+ <p class="result" id="duration-result" aria-live="polite"><strong>30:00:00.042</strong> — 30 hours, 42 milliseconds. No clock math required.</p>
225
257
  </article>
226
258
  </section>
227
259
 
228
260
  <footer>
229
- Native HTML time inputs are for times of day; HTML has no built-in control for entering a duration like 30:00:00.000.
261
+ Native HTML time inputs are for times of day; HTML has no built-in control for entering a duration like 30:00:00.042.
230
262
  That's the gap <a href="InputDuration.html">input-duration</a> fills. Read the
231
263
  <a href="https://github.com/StephanLuis/input-duration">source on GitHub</a>.
232
264
  </footer>
233
265
  </main>
234
266
  <script type="module">
235
- import '../index.js';
267
+ import 'https://cdn.jsdelivr.net/npm/input-duration@3.0.1/+esm';
236
268
 
237
269
  const clockInput = document.querySelector('#clock-time');
238
270
  const clockResult = document.querySelector('#clock-result');
@@ -252,7 +284,7 @@
252
284
  formattedValue.textContent = value;
253
285
  durationResult.replaceChildren(
254
286
  formattedValue,
255
- document.createTextNode(' — a duration, exactly as requested.')
287
+ document.createTextNode(' — duration, not time of day.')
256
288
  );
257
289
  } else {
258
290
  durationResult.textContent = 'Keep going—finish entering the duration.';
package/index.js CHANGED
@@ -279,8 +279,8 @@ class InputDuration extends HTMLElement {
279
279
  }
280
280
 
281
281
  .timeCase:focus-within {
282
- border-color: #176b4a;
283
- outline: 3px solid #176b4a;
282
+ border-color: #2196f3;
283
+ outline: 3px solid #2196f3;
284
284
  outline-offset: 2px;
285
285
  }
286
286
 
@@ -417,7 +417,7 @@ class InputDuration extends HTMLElement {
417
417
 
418
418
 
419
419
  /**
420
- * eventlistener that adds number input for keyed values triggered by the keyup event
420
+ * eventlistener that filters number input and advances between fields
421
421
  * @method
422
422
  * @see boot()
423
423
  */
@@ -439,12 +439,6 @@ class InputDuration extends HTMLElement {
439
439
  this.value = this.oldValue;
440
440
  }
441
441
  });
442
-
443
- inputElement.addEventListener('keyup', function (event) {
444
- if (/^[0-9]$/.test(event.key)) {
445
- inputFilter(this.value);
446
- }
447
- });
448
442
  }
449
443
 
450
444
  // three filters, hours or minutes and seconds (are the same) but milliseconds is different
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "input-duration",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "author": "Stephan Luis <stephan@learnsense.org>",
5
5
  "description": "A JavaScript web component for entering durations up to 99 hours in a fixed HH:mm:ss.SSS format, with millisecond precision for countdown timers and elapsed time.",
6
6
  "browser": "./index.js",