vira 26.3.1 → 26.4.1

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.
@@ -14,3 +14,4 @@ export * from './vira-icon.element.js';
14
14
  export * from './vira-image.element.js';
15
15
  export * from './vira-input.element.js';
16
16
  export * from './vira-link.element.js';
17
+ export * from './vira-progress.element.js';
@@ -14,3 +14,4 @@ export * from './vira-icon.element.js';
14
14
  export * from './vira-image.element.js';
15
15
  export * from './vira-input.element.js';
16
16
  export * from './vira-link.element.js';
17
+ export * from './vira-progress.element.js';
@@ -0,0 +1,18 @@
1
+ import { type PartialWithUndefined } from '@augment-vir/common';
2
+ /**
3
+ * A [`<progress>`](https://developer.mozilla.org/docs/Web/HTML/Reference/Elements/progress)
4
+ * alternative that supports custom styling in _all_ browsers via CSS vars _and_ prevents background
5
+ * bleed.
6
+ *
7
+ * @category Progress
8
+ * @category Elements
9
+ * @see https://electrovir.github.io/element-vir/vira/book/elements/vira-progress
10
+ */
11
+ export declare const ViraProgress: import("element-vir").DeclarativeElementDefinition<"vira-progress", Readonly<{
12
+ value: number;
13
+ } & PartialWithUndefined<{
14
+ /** @default 0 */
15
+ min: number;
16
+ /** @default 100 */
17
+ max: number;
18
+ }>>, {}, {}, "vira-progress-", "vira-progress-border-radius" | "vira-progress-background-color" | "vira-progress-foreground-color", readonly []>;
@@ -0,0 +1,68 @@
1
+ import { clamp } from '@augment-vir/common';
2
+ import { css, html } from 'element-vir';
3
+ import { defineViraElement } from './define-vira-element.js';
4
+ /**
5
+ * A [`<progress>`](https://developer.mozilla.org/docs/Web/HTML/Reference/Elements/progress)
6
+ * alternative that supports custom styling in _all_ browsers via CSS vars _and_ prevents background
7
+ * bleed.
8
+ *
9
+ * @category Progress
10
+ * @category Elements
11
+ * @see https://electrovir.github.io/element-vir/vira/book/elements/vira-progress
12
+ */
13
+ export const ViraProgress = defineViraElement()({
14
+ tagName: 'vira-progress',
15
+ cssVars: {
16
+ /**
17
+ * The browser will automatically cap the border-radius at half of the element's smaller
18
+ * dimension which creates a perfect pill border radius.
19
+ */
20
+ 'vira-progress-border-radius': '99999999px',
21
+ 'vira-progress-background-color': '#eee',
22
+ 'vira-progress-foreground-color': 'dodgerblue',
23
+ },
24
+ styles: ({ cssVars }) => css `
25
+ :host {
26
+ /* Default width that can easily be overridden because it's applied on the host. */
27
+ width: 100px;
28
+ /* Default height that can easily be overridden because it's applied on the host. */
29
+ height: 10px;
30
+ display: inline-flex;
31
+ align-items: center;
32
+ border-radius: ${cssVars['vira-progress-border-radius'].value};
33
+ color: ${cssVars['vira-progress-foreground-color'].value};
34
+ overflow: hidden;
35
+ }
36
+
37
+ .progress-bar {
38
+ background-color: currentColor;
39
+ height: 100%;
40
+ }
41
+
42
+ .background-bar {
43
+ background-color: ${cssVars['vira-progress-background-color'].value};
44
+ height: 100%;
45
+ flex-grow: 1;
46
+ }
47
+ `,
48
+ render({ inputs }) {
49
+ const min = inputs.min || 0;
50
+ const max = inputs.max || 100;
51
+ const totalRange = max - min;
52
+ const value = inputs.value - min;
53
+ const percentFull = clamp(Math.round((value / totalRange) * 100), { min: 0, max: 100 });
54
+ return html `
55
+ <div
56
+ class="progress-bar"
57
+ style=${percentFull
58
+ ? css `
59
+ width: ${percentFull}%;
60
+ `
61
+ : css `
62
+ display: none;
63
+ `}
64
+ ></div>
65
+ <div class="background-bar"></div>
66
+ `;
67
+ },
68
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vira",
3
- "version": "26.3.1",
3
+ "version": "26.4.1",
4
4
  "description": "A simple and highly versatile design system using element-vir.",
5
5
  "keywords": [
6
6
  "design",
@@ -67,7 +67,7 @@
67
67
  "vite-tsconfig-paths": "^5.1.4"
68
68
  },
69
69
  "peerDependencies": {
70
- "element-vir": "^26.3.1"
70
+ "element-vir": "^26.4.1"
71
71
  },
72
72
  "engines": {
73
73
  "node": ">=22"