godown 3.0.0-canary.1 → 3.0.0-canary.11
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 +38 -9
- package/components/alert.d.ts +6 -3
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +22 -14
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts +7 -2
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +13 -6
- package/components/avatar.js.map +1 -1
- package/components/breath.d.ts +4 -2
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +8 -6
- package/components/breath.js.map +1 -1
- package/components/button.d.ts +20 -11
- package/components/button.d.ts.map +1 -1
- package/components/button.js +23 -20
- package/components/button.js.map +1 -1
- package/components/card.d.ts +2 -2
- package/components/card.d.ts.map +1 -1
- package/components/card.js +8 -13
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts +8 -5
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +18 -11
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts +7 -3
- package/components/details.d.ts.map +1 -1
- package/components/details.js +7 -3
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +9 -5
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +20 -14
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts +3 -4
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +6 -7
- package/components/divider.js.map +1 -1
- package/components/dragbox.d.ts +9 -8
- package/components/dragbox.d.ts.map +1 -1
- package/components/dragbox.js +3 -2
- package/components/dragbox.js.map +1 -1
- package/components/flex.d.ts +3 -1
- package/components/flex.d.ts.map +1 -1
- package/components/flex.js +13 -4
- package/components/flex.js.map +1 -1
- package/components/form.d.ts +2 -3
- package/components/form.d.ts.map +1 -1
- package/components/form.js +0 -2
- package/components/form.js.map +1 -1
- package/components/grid.d.ts +9 -3
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js +6 -4
- package/components/grid.js.map +1 -1
- package/components/input.d.ts +4 -4
- package/components/input.d.ts.map +1 -1
- package/components/input.js +5 -7
- package/components/input.js.map +1 -1
- package/components/layout.d.ts +4 -6
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +23 -12
- package/components/layout.js.map +1 -1
- package/components/link.d.ts +3 -1
- package/components/link.d.ts.map +1 -1
- package/components/link.js +3 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts +4 -12
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +9 -17
- package/components/progress.js.map +1 -1
- package/components/range.d.ts +45 -18
- package/components/range.d.ts.map +1 -1
- package/components/range.js +133 -62
- package/components/range.js.map +1 -1
- package/components/rotate.d.ts +3 -2
- package/components/rotate.d.ts.map +1 -1
- package/components/rotate.js +1 -1
- package/components/rotate.js.map +1 -1
- package/components/router.d.ts +15 -17
- package/components/router.d.ts.map +1 -1
- package/components/router.js +10 -10
- package/components/router.js.map +1 -1
- package/components/select.d.ts +6 -9
- package/components/select.d.ts.map +1 -1
- package/components/select.js +48 -43
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts +2 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +5 -5
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts +20 -2
- package/components/split.d.ts.map +1 -1
- package/components/split.js +54 -20
- package/components/split.js.map +1 -1
- package/components/switch.d.ts +6 -5
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +7 -6
- package/components/switch.js.map +1 -1
- package/components/text.d.ts +2 -1
- package/components/text.d.ts.map +1 -1
- package/components/text.js +5 -6
- package/components/text.js.map +1 -1
- package/components/time.d.ts +6 -22
- package/components/time.d.ts.map +1 -1
- package/components/time.js +7 -67
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts +13 -2
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +24 -5
- package/components/tooltip.js.map +1 -1
- package/components/typewriter.d.ts +4 -4
- package/components/typewriter.d.ts.map +1 -1
- package/components/typewriter.js +4 -5
- package/components/typewriter.js.map +1 -1
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +9 -2
- package/core/global-style.js.map +1 -1
- package/core/super-anchor.d.ts +2 -1
- package/core/super-anchor.d.ts.map +1 -1
- package/core/super-anchor.js +4 -3
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +5 -5
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +3 -6
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts.map +1 -1
- package/core/super-openable.js +1 -1
- package/core/super-openable.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts +6 -3
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +38 -25
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts +7 -2
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +28 -13
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/breath.d.ts +4 -2
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +20 -6
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts +20 -11
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +34 -25
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts +2 -2
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +25 -30
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts +8 -5
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +35 -20
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts +7 -3
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +12 -4
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +9 -5
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +30 -24
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts +3 -4
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +20 -8
- package/dev/components/divider.js.map +1 -1
- package/dev/components/dragbox.d.ts +9 -8
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js +8 -1
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts +3 -1
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +24 -4
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts +2 -3
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +0 -2
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts +9 -3
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +17 -4
- package/dev/components/grid.js.map +1 -1
- package/dev/components/input.d.ts +4 -4
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +3 -21
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts +4 -6
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +33 -13
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.d.ts +3 -1
- package/dev/components/link.d.ts.map +1 -1
- package/dev/components/link.js +3 -1
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts +4 -12
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +14 -18
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts +45 -18
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +164 -109
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts +3 -2
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +1 -1
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +15 -17
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +10 -10
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts +6 -9
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +58 -45
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts +2 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +6 -6
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts +20 -2
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +69 -32
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts +6 -5
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +23 -20
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.d.ts +2 -1
- package/dev/components/text.d.ts.map +1 -1
- package/dev/components/text.js +7 -7
- package/dev/components/text.js.map +1 -1
- package/dev/components/time.d.ts +6 -22
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +9 -67
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts +13 -2
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +55 -20
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts +4 -4
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +11 -5
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +18 -10
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-anchor.d.ts +2 -1
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +8 -5
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +5 -5
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +21 -20
- package/dev/core/super-input.js.map +1 -1
- package/dev/core/super-openable.d.ts.map +1 -1
- package/dev/core/super-openable.js +1 -1
- package/dev/core/super-openable.js.map +1 -1
- package/dev/range.d.ts +1 -1
- package/dev/range.d.ts.map +1 -1
- package/index.js +13 -13
- package/package.json +11 -8
- package/range.d.ts +1 -1
- package/range.d.ts.map +1 -1
- 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 +284 -0
- package/src/components/avatar.ts +109 -0
- package/src/components/breath.ts +165 -0
- package/src/components/button.ts +292 -0
- package/src/components/card.ts +83 -0
- package/src/components/carousel.ts +183 -0
- package/src/components/details.ts +121 -0
- package/src/components/dialog.ts +166 -0
- package/src/components/divider.ts +56 -0
- package/src/components/dragbox.ts +134 -0
- package/src/components/flex.ts +82 -0
- package/src/components/form.ts +82 -0
- package/src/components/grid.ts +87 -0
- package/src/components/input.ts +73 -0
- package/src/components/layout.ts +89 -0
- package/src/components/link.ts +38 -0
- package/src/components/progress.ts +100 -0
- package/src/components/range.ts +399 -0
- package/src/components/rotate.ts +95 -0
- package/src/components/router.ts +281 -0
- package/src/components/select.ts +281 -0
- package/src/components/skeleton.ts +119 -0
- package/src/components/split.ts +225 -0
- package/src/components/switch.ts +184 -0
- package/src/components/text.ts +93 -0
- package/src/components/time.ts +84 -0
- package/src/components/tooltip.ts +150 -0
- package/src/components/typewriter.ts +159 -0
- package/src/core/global-style.ts +105 -0
- package/src/core/super-anchor.ts +55 -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,87 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
+
import { htmlStyle } from "@godown/element/directives/html-style.js";
|
6
|
+
import { joinRules } from "@godown/element/tools/css.js";
|
7
|
+
import { isNumerical } from "@godown/element/tools/lib.js";
|
8
|
+
import { css, html, type TemplateResult } from "lit";
|
9
|
+
import { property } from "lit/decorators.js";
|
10
|
+
|
11
|
+
import { GlobalStyle } from "../core/global-style.js";
|
12
|
+
|
13
|
+
const protoName = "grid";
|
14
|
+
|
15
|
+
/**
|
16
|
+
* {@linkcode Grid} provides gird layout.
|
17
|
+
*
|
18
|
+
* @slot - Grid items.
|
19
|
+
* @category layout
|
20
|
+
*/
|
21
|
+
@godown(protoName)
|
22
|
+
@styles(css`
|
23
|
+
:host,
|
24
|
+
:host([contents]) [part=root] {
|
25
|
+
display: grid;
|
26
|
+
}
|
27
|
+
|
28
|
+
[part=root] {
|
29
|
+
display: contents;
|
30
|
+
}
|
31
|
+
`)
|
32
|
+
class Grid extends GlobalStyle {
|
33
|
+
/**
|
34
|
+
* CSS property `gap`.
|
35
|
+
*/
|
36
|
+
@property()
|
37
|
+
gap: string;
|
38
|
+
|
39
|
+
/**
|
40
|
+
* CSS property `grid-template-columns`.
|
41
|
+
*
|
42
|
+
* If columns is numerical, divide columns equally.
|
43
|
+
*/
|
44
|
+
@property()
|
45
|
+
columns: string | number;
|
46
|
+
|
47
|
+
/**
|
48
|
+
* CSS property `grid-template-rows`.
|
49
|
+
*
|
50
|
+
* If rows is numerical, divide rows equally.
|
51
|
+
*/
|
52
|
+
@property()
|
53
|
+
rows: string | number;
|
54
|
+
|
55
|
+
/**
|
56
|
+
* CSS property `place-content` (`align-content justify-content`).
|
57
|
+
*/
|
58
|
+
@property()
|
59
|
+
content: string;
|
60
|
+
|
61
|
+
/**
|
62
|
+
* CSS property `place-items` (`align-items justify-items`).
|
63
|
+
*/
|
64
|
+
@property()
|
65
|
+
items: string;
|
66
|
+
|
67
|
+
protected render(): TemplateResult<1> {
|
68
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
69
|
+
${[
|
70
|
+
htmlSlot(),
|
71
|
+
htmlStyle(
|
72
|
+
joinRules({
|
73
|
+
":host": {
|
74
|
+
gap: this.gap,
|
75
|
+
"grid-template-columns": isNumerical(this.columns) ? `repeat(${this.columns},1fr)` : this.columns,
|
76
|
+
"grid-template-rows": isNumerical(this.rows) ? `repeat(${this.rows},1fr)` : this.rows,
|
77
|
+
"place-content": this.content,
|
78
|
+
"place-items": this.items,
|
79
|
+
},
|
80
|
+
}),
|
81
|
+
),
|
82
|
+
]}
|
83
|
+
</div>`;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
|
87
|
+
export default Grid;
|
@@ -0,0 +1,73 @@
|
|
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 { attr } from "@godown/element/directives/attr.js";
|
5
|
+
import { classList } from "@godown/element/directives/class-list.js";
|
6
|
+
import { css, html, nothing, type TemplateResult } from "lit";
|
7
|
+
import { property } from "lit/decorators.js";
|
8
|
+
|
9
|
+
import { cssGlobalVars } from "../core/global-style.js";
|
10
|
+
import SuperInput from "../core/super-input.js";
|
11
|
+
|
12
|
+
const protoName = "input";
|
13
|
+
|
14
|
+
/**
|
15
|
+
* {@linkcode Input} renders a text input.
|
16
|
+
*
|
17
|
+
* @category input
|
18
|
+
*/
|
19
|
+
@godown(protoName)
|
20
|
+
@styles(
|
21
|
+
css`
|
22
|
+
:host {
|
23
|
+
width: var(${cssGlobalVars.input}-width);
|
24
|
+
height: var(${cssGlobalVars.input}-height);
|
25
|
+
color: var(${cssGlobalVars.foreground});
|
26
|
+
background: var(${cssGlobalVars.input}-background);
|
27
|
+
border-radius: var(${cssGlobalVars.input}-radius);
|
28
|
+
display: block;
|
29
|
+
}
|
30
|
+
`,
|
31
|
+
)
|
32
|
+
class Input extends SuperInput {
|
33
|
+
type: "text" | "search" | "tel" | "url" | "email" | "password" = "text";
|
34
|
+
|
35
|
+
value: string;
|
36
|
+
|
37
|
+
/**
|
38
|
+
* If outline, the outline is always present.
|
39
|
+
*/
|
40
|
+
@property()
|
41
|
+
variant: "default" | "outline" = "default";
|
42
|
+
|
43
|
+
@part("input")
|
44
|
+
protected _input: HTMLInputElement;
|
45
|
+
|
46
|
+
protected render(): TemplateResult<1> {
|
47
|
+
return html`<div part="root" ${attr(this.observedRecord)} class="${classList("input-field", this.variant)}">
|
48
|
+
${[
|
49
|
+
this._renderPrefix(),
|
50
|
+
html`<input
|
51
|
+
part="input"
|
52
|
+
type="${this.type}"
|
53
|
+
id="${this.makeId}"
|
54
|
+
.value="${this.value}"
|
55
|
+
placeholder="${this.placeholder || nothing}"
|
56
|
+
?autofocus="${this.autofocus}"
|
57
|
+
autocapitalize="${this.autocapitalize || nothing}"
|
58
|
+
autocomplete="${this.autocomplete || nothing}"
|
59
|
+
?disabled="${this.disabled}"
|
60
|
+
@input="${this._handleInput}"
|
61
|
+
>`,
|
62
|
+
this._renderSuffix(),
|
63
|
+
]}
|
64
|
+
</div>`;
|
65
|
+
}
|
66
|
+
|
67
|
+
reset(): void {
|
68
|
+
this._input.value = this.default;
|
69
|
+
this.value = this.default;
|
70
|
+
}
|
71
|
+
}
|
72
|
+
|
73
|
+
export default Input;
|
@@ -0,0 +1,89 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
|
+
import { htmlSlot } from "@godown/element/directives/html-slot.js";
|
5
|
+
import { css, html, type TemplateResult } 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
|
+
* @slot header - The header of the layout.
|
17
|
+
* @slot footer - The footer of the layout.
|
18
|
+
* @category layout
|
19
|
+
*/
|
20
|
+
@godown(protoName)
|
21
|
+
@styles(
|
22
|
+
css`
|
23
|
+
:host,
|
24
|
+
:host([contents]) [part=root] {
|
25
|
+
min-height: 100%;
|
26
|
+
display: flex;
|
27
|
+
flex-direction: column;
|
28
|
+
}
|
29
|
+
|
30
|
+
[part=root] {
|
31
|
+
display: contents;
|
32
|
+
}
|
33
|
+
|
34
|
+
[sticky] header {
|
35
|
+
position: sticky;
|
36
|
+
top: 0;
|
37
|
+
z-index: 1;
|
38
|
+
}
|
39
|
+
|
40
|
+
[part=main] {
|
41
|
+
position: relative;
|
42
|
+
flex: 1;
|
43
|
+
width: 100%;
|
44
|
+
}
|
45
|
+
|
46
|
+
header,
|
47
|
+
main,
|
48
|
+
footer {
|
49
|
+
width: 100%;
|
50
|
+
}
|
51
|
+
`,
|
52
|
+
)
|
53
|
+
class NavLayout extends GlobalStyle {
|
54
|
+
/**
|
55
|
+
* If true, remove the header slot.
|
56
|
+
*/
|
57
|
+
@property({ type: Boolean })
|
58
|
+
noHeader = false;
|
59
|
+
|
60
|
+
/**
|
61
|
+
* If true, remove the footer slot.
|
62
|
+
*/
|
63
|
+
@property({ type: Boolean })
|
64
|
+
noFooter = false;
|
65
|
+
|
66
|
+
/**
|
67
|
+
* If true, header will sticky.
|
68
|
+
*/
|
69
|
+
@property({ type: Boolean })
|
70
|
+
sticky = false;
|
71
|
+
|
72
|
+
protected render(): TemplateResult<1> {
|
73
|
+
return html`<div part="root" ${attr(this.observedRecord)}>
|
74
|
+
${
|
75
|
+
!this.noHeader
|
76
|
+
? html`<header part="header">${htmlSlot("header")}</header>`
|
77
|
+
: ""
|
78
|
+
}
|
79
|
+
<main part="main">${htmlSlot()}</main>
|
80
|
+
${
|
81
|
+
!this.noFooter
|
82
|
+
? html`<footer part="footer">${htmlSlot("footer")}</footer>`
|
83
|
+
: ""
|
84
|
+
}
|
85
|
+
</div>`;
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
export default NavLayout;
|
@@ -0,0 +1,38 @@
|
|
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
|
+
* If "normal", behave like a normal anchor.
|
25
|
+
*/
|
26
|
+
@property()
|
27
|
+
type: "push" | "replace" | "normal" = "normal";
|
28
|
+
|
29
|
+
protected _handleClick(e: MouseEvent): void {
|
30
|
+
if (this.type === "push" || this.type === "replace") {
|
31
|
+
e.preventDefault();
|
32
|
+
(history[`${this.type}State`])(null, "", this.href);
|
33
|
+
Router.updateAll();
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
export default Link;
|
@@ -0,0 +1,100 @@
|
|
1
|
+
import { godown } from "@godown/element/decorators/godown.js";
|
2
|
+
import { styles } from "@godown/element/decorators/styles.js";
|
3
|
+
import { attr } from "@godown/element/directives/attr.js";
|
4
|
+
import { isNil } from "@godown/element/tools/lib.js";
|
5
|
+
import { css, html, type TemplateResult } from "lit";
|
6
|
+
import { property } from "lit/decorators.js";
|
7
|
+
|
8
|
+
import { cssGlobalVars, GlobalStyle } from "../core/global-style.js";
|
9
|
+
|
10
|
+
const protoName = "progress";
|
11
|
+
|
12
|
+
/**
|
13
|
+
* {@linkcode Progress} similar to `<progress>`.
|
14
|
+
*
|
15
|
+
* @category feedback
|
16
|
+
*/
|
17
|
+
@godown(protoName)
|
18
|
+
@styles(css`
|
19
|
+
:host {
|
20
|
+
width: 100%;
|
21
|
+
height: 0.5em;
|
22
|
+
border-radius: 0.25em;
|
23
|
+
background: var(${cssGlobalVars.passive});
|
24
|
+
color: var(${cssGlobalVars.active});
|
25
|
+
}
|
26
|
+
|
27
|
+
:host,
|
28
|
+
[part=root] {
|
29
|
+
display: block;
|
30
|
+
}
|
31
|
+
|
32
|
+
[part=root] {
|
33
|
+
height: inherit;
|
34
|
+
z-index: 1;
|
35
|
+
position: relative;
|
36
|
+
border-radius: inherit;
|
37
|
+
}
|
38
|
+
|
39
|
+
[part=value] {
|
40
|
+
position: absolute;
|
41
|
+
z-index: 2;
|
42
|
+
top: 0;
|
43
|
+
left: 0;
|
44
|
+
height: 100%;
|
45
|
+
border-radius: inherit;
|
46
|
+
transition: all 0.3s;
|
47
|
+
animation: progress 1.8s ease-in-out infinite alternate;
|
48
|
+
background: currentColor;
|
49
|
+
}
|
50
|
+
|
51
|
+
@keyframes progress {
|
52
|
+
from {
|
53
|
+
left: 0;
|
54
|
+
}
|
55
|
+
to {
|
56
|
+
left: 80%;
|
57
|
+
}
|
58
|
+
}
|
59
|
+
|
60
|
+
.static [part=value] {
|
61
|
+
animation: none;
|
62
|
+
}
|
63
|
+
`)
|
64
|
+
class Progress extends GlobalStyle {
|
65
|
+
@property({ type: Number })
|
66
|
+
max = 1;
|
67
|
+
|
68
|
+
@property({ type: Number })
|
69
|
+
min = 0;
|
70
|
+
|
71
|
+
@property({ type: Number })
|
72
|
+
value: number;
|
73
|
+
|
74
|
+
protected render(): TemplateResult<1> {
|
75
|
+
let width = 20;
|
76
|
+
let className: string;
|
77
|
+
if (!isNil(this.value)) {
|
78
|
+
width = this.parsePercent(this.value);
|
79
|
+
className = "static";
|
80
|
+
}
|
81
|
+
return html`<div part="root" ${attr(this.observedRecord)} class="${className}">
|
82
|
+
<i part="value" style="width:${width}%;"></i>
|
83
|
+
</div>`;
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Convert s to a percentage without a percent sign.
|
88
|
+
*
|
89
|
+
* @param s String or number to convert.
|
90
|
+
* @returns Percentage without a percent sign.
|
91
|
+
*/
|
92
|
+
parsePercent(s: string | number = "0"): number {
|
93
|
+
if (String(s).includes("%")) {
|
94
|
+
return parseFloat(String(s));
|
95
|
+
}
|
96
|
+
return (parseFloat(String(s)) / (this.max - this.min)) * 100;
|
97
|
+
}
|
98
|
+
}
|
99
|
+
|
100
|
+
export default Progress;
|