input-duration 3.0.3 → 3.2.0

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.
@@ -0,0 +1,104 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <meta name="description" content="See input-duration styled with Bootstrap 5 using CSS custom properties and Shadow Parts.">
7
+ <title>Bootstrap demo — input-duration</title>
8
+ <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
9
+ <style>
10
+ input-duration {
11
+ --input-duration-gap: 0.1em;
12
+ --input-duration-padding: 0.375rem 0.75rem;
13
+ --input-duration-border-color: var(--bs-border-color);
14
+ --input-duration-border-radius: var(--bs-border-radius);
15
+ --input-duration-background: var(--bs-body-bg);
16
+ --input-duration-color: var(--bs-body-color);
17
+ --input-duration-focus-color: var(--bs-primary);
18
+ --input-duration-focus-outline: 0.25rem solid rgba(var(--bs-primary-rgb), 0.25);
19
+ --input-duration-focus-outline-offset: 0;
20
+ }
21
+
22
+ input-duration::part(control) {
23
+ min-height: calc(1.5em + 0.75rem + 2px);
24
+ }
25
+
26
+ input-duration::part(field) {
27
+ font-size: 1rem;
28
+ }
29
+ </style>
30
+ </head>
31
+ <body>
32
+ <main class="container py-5">
33
+ <div class="row justify-content-center">
34
+ <div class="col-lg-8">
35
+ <a class="link-secondary text-decoration-none" href="./">&larr; Main demo</a>
36
+ <header class="my-4">
37
+ <p class="text-uppercase text-primary fw-semibold small mb-2">input-duration + Bootstrap 5</p>
38
+ <h1 class="display-5 fw-semibold">A duration input that fits your Bootstrap theme</h1>
39
+ <p class="lead text-secondary mt-3">
40
+ The component keeps its Shadow DOM. Bootstrap’s global selectors do not reach inside it;
41
+ this page maps Bootstrap theme variables to the component’s public styling hooks instead.
42
+ </p>
43
+ </header>
44
+
45
+ <section class="card shadow-sm" aria-labelledby="example-heading">
46
+ <div class="card-body p-4">
47
+ <h2 class="h4 card-title" id="example-heading">Maintenance window</h2>
48
+ <p class="card-text text-secondary">Set a duration of more than a day, down to milliseconds.</p>
49
+ <label class="form-label fw-medium" id="duration-label">Duration</label>
50
+ <div>
51
+ <input-duration id="duration" value="30:00:00.042" role="group"
52
+ aria-labelledby="duration-label"
53
+ aria-describedby="duration-help"
54
+ aria-label="Duration in hours, minutes, seconds, and milliseconds"></input-duration>
55
+ </div>
56
+ <div class="form-text mt-3" id="duration-help">
57
+ Current value: <output id="duration-value">30:00:00.042</output>
58
+ </div>
59
+ </div>
60
+ </section>
61
+
62
+ <section class="mt-4" aria-labelledby="integration-heading">
63
+ <h2 class="h5" id="integration-heading">How the styling works</h2>
64
+ <p>
65
+ CSS custom properties bring in Bootstrap colors, border radius, spacing, and focus-ring
66
+ styling. Shadow Parts provide targeted access to the control and its internal fields.
67
+ </p>
68
+ <pre class="bg-body-tertiary border rounded p-3"><code>input-duration {
69
+ --input-duration-border-color: var(--bs-border-color);
70
+ --input-duration-border-radius: var(--bs-border-radius);
71
+ --input-duration-focus-color: var(--bs-primary);
72
+ --input-duration-focus-outline: 0.25rem solid rgba(var(--bs-primary-rgb), 0.25);
73
+ }
74
+
75
+ input-duration::part(field) {
76
+ font-size: 1rem;
77
+ }</code></pre>
78
+ </section>
79
+
80
+ <footer class="border-top mt-5 pt-3 text-secondary small">
81
+ <a href="https://github.com/StephanLuis/input-duration">Source on GitHub</a>
82
+ <span class="mx-2" aria-hidden="true">&middot;</span>
83
+ <a href="https://github.com/StephanLuis/input-duration#usage">Styling API documentation</a>
84
+ </footer>
85
+ </div>
86
+ </div>
87
+ </main>
88
+ <script type="module">
89
+ import 'https://cdn.jsdelivr.net/npm/input-duration/+esm';
90
+
91
+ const duration = document.querySelector('#duration');
92
+ const output = document.querySelector('#duration-value');
93
+
94
+ duration.addEventListener('input', () => {
95
+ output.value = duration.value;
96
+ output.textContent = duration.value;
97
+ });
98
+ duration.addEventListener('change', () => {
99
+ output.value = duration.value;
100
+ output.textContent = duration.value;
101
+ });
102
+ </script>
103
+ </body>
104
+ </html>
package/docs/index.html CHANGED
@@ -89,16 +89,25 @@
89
89
  line-height: 1.6;
90
90
  }
91
91
 
92
- .scenario {
93
- display: inline-block;
94
- margin-top: 20px;
95
- padding: 10px 15px;
96
- border: 1px solid #c8def4;
97
- border-radius: 999px;
98
- background: #e1efff;
99
- color: #244e7a;
100
- font-size: .95rem;
101
- font-weight: 650;
92
+ .get-started {
93
+ display: table;
94
+ margin: 30px auto 0;
95
+ padding: 13px 22px;
96
+ border: 1px solid var(--blue);
97
+ border-radius: 10px;
98
+ background: var(--blue);
99
+ color: #fff;
100
+ font-size: 1.05rem;
101
+ text-decoration: none;
102
+ }
103
+
104
+ .get-started:hover {
105
+ background: #1d4f87;
106
+ }
107
+
108
+ .get-started:focus-visible {
109
+ outline: 3px solid #8bb9e8;
110
+ outline-offset: 3px;
102
111
  }
103
112
 
104
113
  .comparison {
@@ -234,7 +243,6 @@
234
243
  <p class="eyebrow">A small input, solves a very big problem</p>
235
244
  <h1>Time is not a duration.</h1>
236
245
  <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>
238
246
  </header>
239
247
 
240
248
  <section class="comparison" aria-label="Compare a time-of-day input with a duration input">
@@ -262,9 +270,11 @@
262
270
  That's the gap <a href="InputDuration.html">input-duration</a> fills. Read the
263
271
  <a href="https://github.com/StephanLuis/input-duration">source on GitHub</a>.
264
272
  </footer>
273
+ <p class="demo-link"><a href="bootstrap.html">See the Bootstrap 5 demo</a></p>
274
+ <a class="get-started" href="https://github.com/StephanLuis/input-duration#getting-started">Get Started</a>
265
275
  </main>
266
276
  <script type="module">
267
- import 'https://cdn.jsdelivr.net/npm/input-duration@3.0.1/+esm';
277
+ import 'https://cdn.jsdelivr.net/npm/input-duration/+esm';
268
278
 
269
279
  const clockInput = document.querySelector('#clock-time');
270
280
  const clockResult = document.querySelector('#clock-result');