godown 3.0.0-canary.6 → 3.0.0-canary.8
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/components/alert.d.ts +1 -1
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +8 -2
- package/components/alert.js.map +1 -1
- package/components/breath.js +2 -2
- package/components/breath.js.map +1 -1
- package/components/card.d.ts +1 -1
- package/components/card.d.ts.map +1 -1
- package/components/card.js +3 -4
- package/components/card.js.map +1 -1
- package/components/carousel.js +1 -1
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts +1 -1
- package/components/details.js +1 -1
- package/components/dialog.d.ts +1 -1
- package/components/dialog.js +1 -1
- package/components/divider.d.ts +1 -1
- package/components/divider.js +1 -1
- package/components/input.d.ts +0 -1
- package/components/input.d.ts.map +1 -1
- package/components/input.js +0 -3
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +1 -1
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +5 -6
- package/components/layout.js.map +1 -1
- package/components/progress.d.ts +1 -1
- package/components/progress.js +1 -1
- package/components/router.js +1 -1
- package/components/router.js.map +1 -1
- package/components/select.d.ts +1 -5
- package/components/select.d.ts.map +1 -1
- package/components/select.js +1 -8
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +1 -2
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +1 -1
- package/components/split.d.ts.map +1 -1
- package/components/split.js +8 -2
- package/components/split.js.map +1 -1
- package/components/text.js +1 -1
- package/components/text.js.map +1 -1
- package/components/time.d.ts +0 -16
- package/components/time.d.ts.map +1 -1
- package/components/time.js +4 -57
- package/components/time.js.map +1 -1
- package/core/super-input.d.ts +0 -1
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +0 -3
- package/core/super-input.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts +1 -1
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +8 -2
- package/dev/components/alert.js.map +1 -1
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +2 -1
- package/dev/components/breath.js.map +1 -1
- package/dev/components/card.d.ts +1 -1
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +3 -4
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +1 -0
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +1 -1
- package/dev/components/details.js +1 -1
- package/dev/components/dialog.d.ts +1 -1
- package/dev/components/dialog.js +1 -1
- package/dev/components/divider.d.ts +1 -1
- package/dev/components/divider.js +1 -1
- package/dev/components/input.d.ts +0 -1
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +0 -3
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +1 -1
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +7 -6
- package/dev/components/layout.js.map +1 -1
- package/dev/components/progress.d.ts +1 -1
- package/dev/components/progress.js +1 -1
- package/dev/components/router.js +1 -1
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +1 -5
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +1 -8
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +1 -2
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +1 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +9 -3
- package/dev/components/split.js.map +1 -1
- package/dev/components/text.js +3 -3
- package/dev/components/time.d.ts +0 -16
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +4 -57
- package/dev/components/time.js.map +1 -1
- package/dev/core/super-input.d.ts +0 -1
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +0 -3
- package/dev/core/super-input.js.map +1 -1
- package/package.json +9 -7
- package/src/alert.ts +11 -0
- package/src/avatar.ts +11 -0
- package/src/breath.ts +13 -0
- package/src/button.ts +11 -0
- package/src/card.ts +11 -0
- package/src/carousel.ts +11 -0
- package/src/components/alert.ts +282 -0
- package/src/components/avatar.ts +93 -0
- package/src/components/breath.ts +151 -0
- package/src/components/button.ts +276 -0
- package/src/components/card.ts +85 -0
- package/src/components/carousel.ts +166 -0
- package/src/components/details.ts +112 -0
- package/src/components/dialog.ts +160 -0
- package/src/components/divider.ts +44 -0
- package/src/components/dragbox.ts +126 -0
- package/src/components/flex.ts +65 -0
- package/src/components/form.ts +83 -0
- package/src/components/grid.ts +66 -0
- package/src/components/input.ts +71 -0
- package/src/components/layout.ts +84 -0
- package/src/components/link.ts +36 -0
- package/src/components/progress.ts +101 -0
- package/src/components/range.ts +409 -0
- package/src/components/rotate.ts +92 -0
- package/src/components/router.ts +264 -0
- package/src/components/select.ts +268 -0
- package/src/components/skeleton.ts +116 -0
- package/src/components/split.ts +190 -0
- package/src/components/switch.ts +176 -0
- package/src/components/text.ts +95 -0
- package/src/components/time.ts +77 -0
- package/src/components/tooltip.ts +118 -0
- package/src/components/typewriter.ts +147 -0
- package/src/core/global-style.ts +86 -0
- package/src/core/super-anchor.ts +52 -0
- package/src/core/super-input.ts +230 -0
- package/src/core/super-openable.ts +51 -0
- package/src/details.ts +11 -0
- package/src/dialog.ts +11 -0
- package/src/divider.ts +11 -0
- package/src/dragbox.ts +11 -0
- package/src/flex.ts +11 -0
- package/src/form.ts +11 -0
- package/src/grid.ts +11 -0
- package/src/index.ts +28 -0
- package/src/input.ts +13 -0
- package/src/layout.ts +12 -0
- package/src/link.ts +13 -0
- package/src/progress.ts +12 -0
- package/src/range.ts +13 -0
- package/src/rotate.ts +13 -0
- package/src/router.ts +12 -0
- package/src/select.ts +13 -0
- package/src/skeleton.ts +13 -0
- package/src/split.ts +13 -0
- package/src/switch.ts +13 -0
- package/src/text.ts +13 -0
- package/src/time.ts +13 -0
- package/src/tooltip.ts +13 -0
- package/src/typewriter.ts +11 -0
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
@@ -0,0 +1,83 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
4
|
+
import { css } from "lit";
|
5
|
+
import { property } from "lit/decorators.js";
|
6
|
+
|
7
|
+
import { GlobalStyle } from "../core/global-style.js";
|
8
|
+
|
9
|
+
const protoName = "form";
|
10
|
+
|
11
|
+
/**
|
12
|
+
* {@linkcode Form} Gets child element key-value object,
|
13
|
+
* which will be nested if the child element is the same as this element.
|
14
|
+
*
|
15
|
+
* @slot - Child elements.
|
16
|
+
*
|
17
|
+
* @category form
|
18
|
+
*/
|
19
|
+
@godown(protoName)
|
20
|
+
@styles(
|
21
|
+
css`
|
22
|
+
:host {
|
23
|
+
display: block;
|
24
|
+
}
|
25
|
+
`,
|
26
|
+
)
|
27
|
+
class Form<T = object> extends GlobalStyle {
|
28
|
+
@property()
|
29
|
+
name = "";
|
30
|
+
get value(): T {
|
31
|
+
return Form.buildValue(this._slot.assignedElements()) as T;
|
32
|
+
}
|
33
|
+
|
34
|
+
nameValue = this.namevalue;
|
35
|
+
|
36
|
+
protected render() {
|
37
|
+
return htmlSlot();
|
38
|
+
}
|
39
|
+
|
40
|
+
reset() {
|
41
|
+
this.deepQuerySelectorAll<HTMLElement & { reset?: () => void; }>("*").forEach((el) => {
|
42
|
+
if (el.tagName === this.tagName) {
|
43
|
+
return;
|
44
|
+
}
|
45
|
+
if (el.reset) {
|
46
|
+
el.reset();
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
50
|
+
|
51
|
+
namevalue(): [string, T] {
|
52
|
+
return [this.name, this.value];
|
53
|
+
}
|
54
|
+
|
55
|
+
static buildValue(
|
56
|
+
elements: (Element & {
|
57
|
+
name?: string;
|
58
|
+
value?: unknown;
|
59
|
+
namevalue?: () => [string, unknown];
|
60
|
+
})[],
|
61
|
+
): Record<string, any> {
|
62
|
+
const result = {};
|
63
|
+
for (const el of elements) {
|
64
|
+
if (el.tagName === "FORM") {
|
65
|
+
Object.assign(result, Object.fromEntries(new FormData(el as HTMLFormElement).entries()));
|
66
|
+
} else if (el.namevalue) {
|
67
|
+
const [name, value] = el.namevalue();
|
68
|
+
if (name) {
|
69
|
+
result[name] = value;
|
70
|
+
}
|
71
|
+
} else if (el.name && el.value !== undefined) {
|
72
|
+
result[el.name] = el.value;
|
73
|
+
} else if (el.shadowRoot) {
|
74
|
+
for (const slot of el.shadowRoot.querySelectorAll("slot")) {
|
75
|
+
Object.assign(result, this.buildValue(slot.assignedElements()));
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
return result;
|
80
|
+
}
|
81
|
+
}
|
82
|
+
|
83
|
+
export default Form;
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
4
|
+
import { htmlStyle } from "@godown/element/directives/html-style.js";
|
5
|
+
import { joinRules } from "@godown/element/tools/css.js";
|
6
|
+
import { isNumerical } from "@godown/element/tools/lib.js";
|
7
|
+
import { css } from "lit";
|
8
|
+
import { property } from "lit/decorators.js";
|
9
|
+
|
10
|
+
import { GlobalStyle } from "../core/global-style.js";
|
11
|
+
|
12
|
+
const protoName = "grid";
|
13
|
+
|
14
|
+
/**
|
15
|
+
* {@linkcode Grid} provides gird layout.
|
16
|
+
*
|
17
|
+
* @category layout
|
18
|
+
*/
|
19
|
+
@godown(protoName)
|
20
|
+
@styles(css`:host{display:grid;}`)
|
21
|
+
class Grid extends GlobalStyle {
|
22
|
+
/**
|
23
|
+
* CSS property `gap`.
|
24
|
+
*/
|
25
|
+
@property()
|
26
|
+
gap: string;
|
27
|
+
/**
|
28
|
+
* CSS property `grid-template-columns`, if {@linkcode isNumerical} divide equally.
|
29
|
+
*/
|
30
|
+
@property()
|
31
|
+
columns: string | number;
|
32
|
+
/**
|
33
|
+
* CSS property `grid-template-rows`, if {@linkcode isNumerical} divide equally.
|
34
|
+
*/
|
35
|
+
@property()
|
36
|
+
rows: string | number;
|
37
|
+
/**
|
38
|
+
* CSS property `place-content` (`align-content justify-content`).
|
39
|
+
*/
|
40
|
+
@property()
|
41
|
+
content: string;
|
42
|
+
/**
|
43
|
+
* CSS property `place-items` (`align-items justify-items`).
|
44
|
+
*/
|
45
|
+
@property()
|
46
|
+
items: string;
|
47
|
+
|
48
|
+
protected render() {
|
49
|
+
return [
|
50
|
+
htmlSlot(),
|
51
|
+
htmlStyle(
|
52
|
+
joinRules({
|
53
|
+
":host": {
|
54
|
+
gap: this.gap,
|
55
|
+
"grid-template-columns": isNumerical(this.columns) ? `repeat(${this.columns},1fr)` : this.columns,
|
56
|
+
"grid-template-rows": isNumerical(this.rows) ? `repeat(${this.rows},1fr)` : this.rows,
|
57
|
+
"place-content": this.content,
|
58
|
+
"place-items": this.items,
|
59
|
+
},
|
60
|
+
}),
|
61
|
+
),
|
62
|
+
];
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
export default Grid;
|
@@ -0,0 +1,71 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { part } from "@godown/element/decorators/part.js";
|
3
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
4
|
+
import { classList } from "@godown/element/directives/class-list.js";
|
5
|
+
import { css, html, nothing } from "lit";
|
6
|
+
import { property } from "lit/decorators.js";
|
7
|
+
|
8
|
+
import { cssGlobalVars } from "../core/global-style.js";
|
9
|
+
import SuperInput from "../core/super-input.js";
|
10
|
+
|
11
|
+
const protoName = "input";
|
12
|
+
|
13
|
+
/**
|
14
|
+
* {@linkcode Input} used for text input.
|
15
|
+
*
|
16
|
+
* @category input
|
17
|
+
*/
|
18
|
+
@godown(protoName)
|
19
|
+
@styles(
|
20
|
+
css`
|
21
|
+
:host {
|
22
|
+
width: var(${cssGlobalVars.input}-width);
|
23
|
+
height: var(${cssGlobalVars.input}-height);
|
24
|
+
color: var(${cssGlobalVars.foreground});
|
25
|
+
background: var(${cssGlobalVars.input}-background);
|
26
|
+
border-radius: var(${cssGlobalVars.input}-radius);
|
27
|
+
display: block;
|
28
|
+
}
|
29
|
+
`,
|
30
|
+
)
|
31
|
+
class Input extends SuperInput {
|
32
|
+
type: "text" | "search" | "tel" | "url" | "email" | "password" = "text";
|
33
|
+
value: string;
|
34
|
+
|
35
|
+
/**
|
36
|
+
* If outline, the outline is always present.
|
37
|
+
*/
|
38
|
+
@property()
|
39
|
+
variant: "default" | "outline" = "default";
|
40
|
+
|
41
|
+
@part("input")
|
42
|
+
_input: HTMLInputElement;
|
43
|
+
|
44
|
+
protected render() {
|
45
|
+
return html`<div part="root" class="${classList("input-field", this.variant)}">
|
46
|
+
${[
|
47
|
+
this._renderPrefix(),
|
48
|
+
html`<input
|
49
|
+
part="input"
|
50
|
+
type="${this.type}"
|
51
|
+
id="${this.makeId}"
|
52
|
+
.value="${this.value}"
|
53
|
+
placeholder="${this.placeholder || nothing}"
|
54
|
+
?autofocus="${this.autofocus}"
|
55
|
+
autocapitalize="${this.autocapitalize || nothing}"
|
56
|
+
autocomplete="${this.autocomplete || nothing}"
|
57
|
+
?disabled="${this.disabled}"
|
58
|
+
@input="${this._handleInput}"
|
59
|
+
>`,
|
60
|
+
this._renderSuffix(),
|
61
|
+
]}
|
62
|
+
</div>`;
|
63
|
+
}
|
64
|
+
|
65
|
+
reset() {
|
66
|
+
this._input.value = this.default;
|
67
|
+
this.value = this.default;
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
export default Input;
|
@@ -0,0 +1,84 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { classList } from "@godown/element/directives/class-list.js";
|
4
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
+
import { css, html } from "lit";
|
6
|
+
import { property } from "lit/decorators.js";
|
7
|
+
|
8
|
+
import { GlobalStyle } from "../core/global-style.js";
|
9
|
+
|
10
|
+
const protoName = "layout";
|
11
|
+
|
12
|
+
/**
|
13
|
+
* {@linkcode NavLayout} renders slot and optional top header, bottom footer.
|
14
|
+
*
|
15
|
+
* @slot - The main content of the layout.
|
16
|
+
*
|
17
|
+
* @slot header - The header of the layout.
|
18
|
+
*
|
19
|
+
* @slot footer - The footer of the layout.
|
20
|
+
*
|
21
|
+
* @category layout
|
22
|
+
*/
|
23
|
+
@godown(protoName)
|
24
|
+
@styles(
|
25
|
+
css`
|
26
|
+
:host {
|
27
|
+
min-height: 100%;
|
28
|
+
display: flex;
|
29
|
+
flex-direction: column;
|
30
|
+
}
|
31
|
+
|
32
|
+
.sticky {
|
33
|
+
position: sticky;
|
34
|
+
top: 0;
|
35
|
+
z-index: 1;
|
36
|
+
}
|
37
|
+
|
38
|
+
[part="main"] {
|
39
|
+
position: relative;
|
40
|
+
flex: 1;
|
41
|
+
width: 100%;
|
42
|
+
}
|
43
|
+
|
44
|
+
header,
|
45
|
+
main,
|
46
|
+
footer {
|
47
|
+
width: 100%;
|
48
|
+
}
|
49
|
+
`,
|
50
|
+
)
|
51
|
+
class NavLayout extends GlobalStyle {
|
52
|
+
/**
|
53
|
+
* If true, hide the header slot.
|
54
|
+
*/
|
55
|
+
@property({ type: Boolean })
|
56
|
+
noHeader: boolean;
|
57
|
+
/**
|
58
|
+
* If true, hide the footer slot.
|
59
|
+
*/
|
60
|
+
@property({ type: Boolean })
|
61
|
+
noFooter: boolean;
|
62
|
+
|
63
|
+
/**
|
64
|
+
* If true, header will sticky.
|
65
|
+
*/
|
66
|
+
@property({ type: Boolean })
|
67
|
+
sticky: boolean;
|
68
|
+
|
69
|
+
protected render() {
|
70
|
+
return html`${
|
71
|
+
!this.noHeader
|
72
|
+
? html`<header part="header" class="${classList({ sticky: this.sticky })}">${htmlSlot("header")}</header>`
|
73
|
+
: ""
|
74
|
+
}
|
75
|
+
<main part="main">${htmlSlot()}</main>
|
76
|
+
${
|
77
|
+
!this.noFooter
|
78
|
+
? html`<footer part="footer">${htmlSlot("footer")}</footer>`
|
79
|
+
: ""
|
80
|
+
}`;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
export default NavLayout;
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { property } from "lit/decorators.js";
|
3
|
+
|
4
|
+
import SuperAnchor from "../core/super-anchor.js";
|
5
|
+
import Router from "./router.js";
|
6
|
+
|
7
|
+
const protoName = "link";
|
8
|
+
|
9
|
+
/**
|
10
|
+
* {@linkcode Link} is used for link jumping.
|
11
|
+
*
|
12
|
+
* Set `type` to `"push" `or `"replace"`,
|
13
|
+
* will invoke the history api and trigger the {@linkcode Router.updateAll}.
|
14
|
+
*
|
15
|
+
* @category navigation
|
16
|
+
*/
|
17
|
+
@godown(protoName)
|
18
|
+
class Link extends SuperAnchor {
|
19
|
+
/**
|
20
|
+
* If "push", call `history.pushState`.
|
21
|
+
*
|
22
|
+
* If "replace", call `history.replaceState`
|
23
|
+
*/
|
24
|
+
@property()
|
25
|
+
type: "push" | "replace" | "normal" = "normal";
|
26
|
+
|
27
|
+
protected _handleClick(e: MouseEvent) {
|
28
|
+
if (this.type === "push" || this.type === "replace") {
|
29
|
+
e.preventDefault();
|
30
|
+
(history[`${this.type}State`])(null, "", this.href);
|
31
|
+
Router.updateAll();
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
export default Link;
|
@@ -0,0 +1,101 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { css, html } from "lit";
|
4
|
+
import { property } from "lit/decorators.js";
|
5
|
+
|
6
|
+
import { cssGlobalVars, GlobalStyle } from "../core/global-style.js";
|
7
|
+
|
8
|
+
const protoName = "progress";
|
9
|
+
|
10
|
+
/**
|
11
|
+
* {@linkcode Progress} similar to `<progress>`.
|
12
|
+
*
|
13
|
+
* @category feedback
|
14
|
+
*/
|
15
|
+
@godown(protoName)
|
16
|
+
@styles(css`
|
17
|
+
:host {
|
18
|
+
width: 100%;
|
19
|
+
height: 0.5em;
|
20
|
+
display: inline-block;
|
21
|
+
border-radius: 0.25em;
|
22
|
+
background: var(${cssGlobalVars.passive});
|
23
|
+
color: var(${cssGlobalVars.active});
|
24
|
+
}
|
25
|
+
|
26
|
+
[part="root"] {
|
27
|
+
height: inherit;
|
28
|
+
z-index: 1;
|
29
|
+
position: relative;
|
30
|
+
border-radius: inherit;
|
31
|
+
}
|
32
|
+
|
33
|
+
[part="value"] {
|
34
|
+
position: absolute;
|
35
|
+
z-index: 2;
|
36
|
+
top: 0;
|
37
|
+
left: 0;
|
38
|
+
height: 100%;
|
39
|
+
border-radius: inherit;
|
40
|
+
transition: all 0.3s;
|
41
|
+
animation: progress 1.8s ease-in-out infinite alternate;
|
42
|
+
background: currentColor;
|
43
|
+
}
|
44
|
+
|
45
|
+
@keyframes progress {
|
46
|
+
from {
|
47
|
+
left: 0;
|
48
|
+
}
|
49
|
+
to {
|
50
|
+
left: 80%;
|
51
|
+
}
|
52
|
+
}
|
53
|
+
|
54
|
+
.static [part="value"] {
|
55
|
+
animation: none;
|
56
|
+
}
|
57
|
+
`)
|
58
|
+
class Progress extends GlobalStyle {
|
59
|
+
/**
|
60
|
+
* Maximum.
|
61
|
+
*/
|
62
|
+
@property({ type: Number })
|
63
|
+
max = 1;
|
64
|
+
/**
|
65
|
+
* Minimum.
|
66
|
+
*/
|
67
|
+
@property({ type: Number })
|
68
|
+
min = 0;
|
69
|
+
/**
|
70
|
+
* Input value.
|
71
|
+
*/
|
72
|
+
@property({ type: Number, reflect: true })
|
73
|
+
value = null;
|
74
|
+
|
75
|
+
protected render() {
|
76
|
+
let width = 20;
|
77
|
+
let className: string;
|
78
|
+
if (this.value !== null) {
|
79
|
+
width = this.parsePercent(this.value);
|
80
|
+
className = "static";
|
81
|
+
}
|
82
|
+
return html`<div part="root" class="${className}">
|
83
|
+
<i part="value" style="width:${width}%;"></i>
|
84
|
+
</div>`;
|
85
|
+
}
|
86
|
+
|
87
|
+
/**
|
88
|
+
* Convert s to a percentage without a percent sign.
|
89
|
+
*
|
90
|
+
* @param s String or number to convert.
|
91
|
+
* @returns Percentage without a percent sign.
|
92
|
+
*/
|
93
|
+
parsePercent(s: string | number = "0"): number {
|
94
|
+
if (String(s).includes("%")) {
|
95
|
+
return parseFloat(String(s));
|
96
|
+
}
|
97
|
+
return (parseFloat(String(s)) / (this.max - this.min)) * 100;
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
export default Progress;
|