godown 3.0.0 → 3.0.2
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/build/godown+lit.iife.js +12 -12
- package/build/godown+lit.iife.js.map +1 -1
- package/build/godown+lit.js +12 -12
- package/build/godown+lit.js.map +1 -1
- package/build/godown+lit.umd.js +12 -12
- package/build/godown+lit.umd.js.map +1 -1
- package/build/godown.iife.js +11 -11
- package/build/godown.js +11 -11
- package/build/godown.js.map +1 -1
- package/build/godown.umd.js +11 -11
- package/build/godown.umd.js.map +1 -1
- package/components/alert.d.ts.map +1 -1
- package/components/alert.js +1 -1
- package/components/alert.js.map +1 -1
- package/components/avatar.d.ts.map +1 -1
- package/components/avatar.js +1 -1
- package/components/avatar.js.map +1 -1
- package/components/badge.d.ts.map +1 -1
- package/components/badge.js +1 -1
- package/components/badge.js.map +1 -1
- package/components/breath.d.ts.map +1 -1
- package/components/breath.js +1 -1
- package/components/breath.js.map +1 -1
- package/components/button.d.ts.map +1 -1
- package/components/button.js +1 -1
- package/components/button.js.map +1 -1
- package/components/card.d.ts.map +1 -1
- package/components/card.js +1 -1
- package/components/card.js.map +1 -1
- package/components/carousel.d.ts.map +1 -1
- package/components/carousel.js +1 -1
- package/components/carousel.js.map +1 -1
- package/components/details.d.ts.map +1 -1
- package/components/details.js +1 -1
- package/components/details.js.map +1 -1
- package/components/dialog.d.ts +3 -2
- package/components/dialog.d.ts.map +1 -1
- package/components/dialog.js +1 -1
- package/components/dialog.js.map +1 -1
- package/components/divider.d.ts.map +1 -1
- package/components/divider.js +1 -1
- package/components/divider.js.map +1 -1
- package/components/dragbox.d.ts.map +1 -1
- package/components/dragbox.js +1 -1
- package/components/dragbox.js.map +1 -1
- package/components/flex.d.ts.map +1 -1
- package/components/flex.js.map +1 -1
- package/components/form.d.ts.map +1 -1
- package/components/form.js.map +1 -1
- package/components/grid.d.ts.map +1 -1
- package/components/grid.js.map +1 -1
- package/components/heading.d.ts.map +1 -1
- package/components/heading.js +1 -1
- package/components/heading.js.map +1 -1
- package/components/input.d.ts.map +1 -1
- package/components/input.js +1 -1
- package/components/input.js.map +1 -1
- package/components/layout.d.ts.map +1 -1
- package/components/layout.js +1 -1
- package/components/layout.js.map +1 -1
- package/components/link.js.map +1 -1
- package/components/progress.d.ts.map +1 -1
- package/components/progress.js +1 -1
- package/components/progress.js.map +1 -1
- package/components/range.d.ts.map +1 -1
- package/components/range.js +1 -1
- package/components/range.js.map +1 -1
- 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 +21 -26
- package/components/router.d.ts.map +1 -1
- package/components/router.js +1 -1
- package/components/router.js.map +1 -1
- package/components/select.d.ts.map +1 -1
- package/components/select.js +1 -1
- package/components/select.js.map +1 -1
- package/components/skeleton.d.ts.map +1 -1
- package/components/skeleton.js +1 -1
- package/components/skeleton.js.map +1 -1
- package/components/split.d.ts.map +1 -1
- package/components/split.js +1 -1
- package/components/split.js.map +1 -1
- package/components/switch.d.ts.map +1 -1
- package/components/switch.js +1 -1
- package/components/switch.js.map +1 -1
- package/components/text.d.ts.map +1 -1
- package/components/text.js +1 -1
- package/components/text.js.map +1 -1
- package/components/time.d.ts.map +1 -1
- package/components/time.js.map +1 -1
- package/components/tooltip.d.ts.map +1 -1
- package/components/tooltip.js +1 -1
- package/components/tooltip.js.map +1 -1
- package/components/typewriter.d.ts.map +1 -1
- package/components/typewriter.js +1 -1
- package/components/typewriter.js.map +1 -1
- package/core/global-style.d.ts.map +1 -1
- package/core/global-style.js +1 -1
- package/core/global-style.js.map +1 -1
- package/core/super-anchor.d.ts.map +1 -1
- package/core/super-anchor.js +1 -1
- package/core/super-anchor.js.map +1 -1
- package/core/super-input.d.ts +1 -0
- package/core/super-input.d.ts.map +1 -1
- package/core/super-input.js +1 -1
- package/core/super-input.js.map +1 -1
- package/core/super-openable.d.ts.map +1 -1
- package/core/super-openable.js.map +1 -1
- package/custom-elements.json +1 -1
- package/dev/components/alert.d.ts.map +1 -1
- package/dev/components/alert.js +82 -69
- package/dev/components/alert.js.map +1 -1
- package/dev/components/avatar.d.ts.map +1 -1
- package/dev/components/avatar.js +52 -36
- package/dev/components/avatar.js.map +1 -1
- package/dev/components/badge.d.ts.map +1 -1
- package/dev/components/badge.js +57 -50
- package/dev/components/badge.js.map +1 -1
- package/dev/components/breath.d.ts.map +1 -1
- package/dev/components/breath.js +20 -14
- package/dev/components/breath.js.map +1 -1
- package/dev/components/button.d.ts.map +1 -1
- package/dev/components/button.js +13 -13
- package/dev/components/button.js.map +1 -1
- package/dev/components/card.d.ts.map +1 -1
- package/dev/components/card.js +40 -35
- package/dev/components/card.js.map +1 -1
- package/dev/components/carousel.d.ts.map +1 -1
- package/dev/components/carousel.js +63 -43
- package/dev/components/carousel.js.map +1 -1
- package/dev/components/details.d.ts.map +1 -1
- package/dev/components/details.js +72 -61
- package/dev/components/details.js.map +1 -1
- package/dev/components/dialog.d.ts +3 -2
- package/dev/components/dialog.d.ts.map +1 -1
- package/dev/components/dialog.js +63 -65
- package/dev/components/dialog.js.map +1 -1
- package/dev/components/divider.d.ts.map +1 -1
- package/dev/components/divider.js +28 -23
- package/dev/components/divider.js.map +1 -1
- package/dev/components/dragbox.d.ts.map +1 -1
- package/dev/components/dragbox.js +19 -17
- package/dev/components/dragbox.js.map +1 -1
- package/dev/components/flex.d.ts.map +1 -1
- package/dev/components/flex.js +16 -11
- package/dev/components/flex.js.map +1 -1
- package/dev/components/form.d.ts.map +1 -1
- package/dev/components/form.js +4 -4
- package/dev/components/form.js.map +1 -1
- package/dev/components/grid.d.ts.map +1 -1
- package/dev/components/grid.js +16 -11
- package/dev/components/grid.js.map +1 -1
- package/dev/components/heading.d.ts.map +1 -1
- package/dev/components/heading.js +62 -40
- package/dev/components/heading.js.map +1 -1
- package/dev/components/input.d.ts.map +1 -1
- package/dev/components/input.js +32 -24
- package/dev/components/input.js.map +1 -1
- package/dev/components/layout.d.ts.map +1 -1
- package/dev/components/layout.js +43 -30
- package/dev/components/layout.js.map +1 -1
- package/dev/components/link.js +1 -1
- package/dev/components/link.js.map +1 -1
- package/dev/components/progress.d.ts.map +1 -1
- package/dev/components/progress.js +51 -42
- package/dev/components/progress.js.map +1 -1
- package/dev/components/range.d.ts.map +1 -1
- package/dev/components/range.js +33 -30
- package/dev/components/range.js.map +1 -1
- package/dev/components/rotate.d.ts.map +1 -1
- package/dev/components/rotate.js +12 -5
- package/dev/components/rotate.js.map +1 -1
- package/dev/components/router.d.ts +21 -26
- package/dev/components/router.d.ts.map +1 -1
- package/dev/components/router.js +22 -18
- package/dev/components/router.js.map +1 -1
- package/dev/components/select.d.ts.map +1 -1
- package/dev/components/select.js +65 -57
- package/dev/components/select.js.map +1 -1
- package/dev/components/skeleton.d.ts.map +1 -1
- package/dev/components/skeleton.js +65 -61
- package/dev/components/skeleton.js.map +1 -1
- package/dev/components/split.d.ts.map +1 -1
- package/dev/components/split.js +66 -58
- package/dev/components/split.js.map +1 -1
- package/dev/components/switch.d.ts.map +1 -1
- package/dev/components/switch.js +88 -79
- package/dev/components/switch.js.map +1 -1
- package/dev/components/text.d.ts.map +1 -1
- package/dev/components/text.js +51 -45
- package/dev/components/text.js.map +1 -1
- package/dev/components/time.d.ts.map +1 -1
- package/dev/components/time.js +13 -2
- package/dev/components/time.js.map +1 -1
- package/dev/components/tooltip.d.ts.map +1 -1
- package/dev/components/tooltip.js +31 -23
- package/dev/components/tooltip.js.map +1 -1
- package/dev/components/typewriter.d.ts.map +1 -1
- package/dev/components/typewriter.js +35 -27
- package/dev/components/typewriter.js.map +1 -1
- package/dev/core/global-style.d.ts.map +1 -1
- package/dev/core/global-style.js +9 -9
- package/dev/core/global-style.js.map +1 -1
- package/dev/core/super-anchor.d.ts.map +1 -1
- package/dev/core/super-anchor.js +27 -26
- package/dev/core/super-anchor.js.map +1 -1
- package/dev/core/super-input.d.ts +1 -0
- package/dev/core/super-input.d.ts.map +1 -1
- package/dev/core/super-input.js +87 -69
- 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 -2
- package/dev/core/super-openable.js.map +1 -1
- package/package.json +3 -3
- package/src/components/alert.ts +84 -75
- package/src/components/avatar.ts +54 -40
- package/src/components/badge.ts +68 -65
- package/src/components/breath.ts +23 -19
- package/src/components/button.ts +14 -14
- package/src/components/card.ts +42 -40
- package/src/components/carousel.ts +65 -47
- package/src/components/details.ts +74 -65
- package/src/components/dialog.ts +69 -66
- package/src/components/divider.ts +33 -30
- package/src/components/dragbox.ts +22 -22
- package/src/components/flex.ts +31 -28
- package/src/components/form.ts +7 -9
- package/src/components/grid.ts +31 -28
- package/src/components/heading.ts +67 -49
- package/src/components/input.ts +37 -31
- package/src/components/layout.ts +45 -34
- package/src/components/link.ts +1 -1
- package/src/components/progress.ts +53 -46
- package/src/components/range.ts +58 -52
- package/src/components/rotate.ts +15 -10
- package/src/components/router.ts +46 -46
- package/src/components/select.ts +74 -70
- package/src/components/skeleton.ts +67 -65
- package/src/components/split.ts +73 -69
- package/src/components/switch.ts +90 -83
- package/src/components/text.ts +53 -49
- package/src/components/time.ts +14 -3
- package/src/components/tooltip.ts +32 -24
- package/src/components/typewriter.ts +37 -31
- package/src/core/global-style.ts +11 -12
- package/src/core/super-anchor.ts +29 -30
- package/src/core/super-input.ts +91 -74
- package/src/core/super-openable.ts +2 -8
- package/vscode.html-custom-data.json +1 -1
- package/web-types.json +1 -1
package/src/components/badge.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { attr, godown, htmlSlot, styles } from "@godown/element";
|
2
|
-
import { css, html
|
2
|
+
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
|
-
import {
|
5
|
+
import { GlobalStyle, cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
6
6
|
|
7
7
|
type Position = "top-right" | "top-left" | "bottom-right" | "bottom-left";
|
8
8
|
|
@@ -16,61 +16,59 @@ const cssScope = scopePrefix(protoName);
|
|
16
16
|
* @category display
|
17
17
|
*/
|
18
18
|
@godown(protoName)
|
19
|
-
@styles(
|
20
|
-
|
21
|
-
:
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
:
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
`,
|
73
|
-
)
|
19
|
+
@styles(css`
|
20
|
+
:host {
|
21
|
+
${cssScope}--background: var(${cssGlobalVars.active});
|
22
|
+
${cssScope}--offset: 0%;
|
23
|
+
${cssScope}--offset-x: var(${cssScope}--offset);
|
24
|
+
${cssScope}--offset-y: var(${cssScope}--offset);
|
25
|
+
}
|
26
|
+
|
27
|
+
:host,
|
28
|
+
:host([contents]) [part="root"] {
|
29
|
+
display: inline-block;
|
30
|
+
}
|
31
|
+
|
32
|
+
[part="root"] {
|
33
|
+
position: relative;
|
34
|
+
}
|
35
|
+
|
36
|
+
[part="badge"] {
|
37
|
+
position: absolute;
|
38
|
+
font-size: 75%;
|
39
|
+
padding: 0 0.5em;
|
40
|
+
user-select: none;
|
41
|
+
border-radius: calc(infinity * 1px);
|
42
|
+
transform: translate(-50%, -50%);
|
43
|
+
left: var(--left);
|
44
|
+
top: var(--top);
|
45
|
+
background: var(${cssScope}--background);
|
46
|
+
}
|
47
|
+
|
48
|
+
[part="badge"]:empty {
|
49
|
+
width: 0.5em;
|
50
|
+
height: 0.5em;
|
51
|
+
font-size: 100%;
|
52
|
+
padding: 0;
|
53
|
+
border-radius: 50%;
|
54
|
+
}
|
55
|
+
|
56
|
+
[position^="top"] {
|
57
|
+
--top: calc(0% + var(${cssScope}--offset-y));
|
58
|
+
}
|
59
|
+
|
60
|
+
[position$="right"] {
|
61
|
+
--left: calc(100% - var(${cssScope}--offset-x));
|
62
|
+
}
|
63
|
+
|
64
|
+
[position^="bottom"] {
|
65
|
+
--top: calc(100% - var(${cssScope}--offset-y));
|
66
|
+
}
|
67
|
+
|
68
|
+
[position$="left"] {
|
69
|
+
--left: calc(0% + var(${cssScope}--offset-x));
|
70
|
+
}
|
71
|
+
`)
|
74
72
|
class Badge extends GlobalStyle {
|
75
73
|
@property()
|
76
74
|
position: Position = "top-right";
|
@@ -92,14 +90,19 @@ class Badge extends GlobalStyle {
|
|
92
90
|
}
|
93
91
|
|
94
92
|
render(): TemplateResult<1> {
|
95
|
-
return html
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
93
|
+
return html`
|
94
|
+
<div
|
95
|
+
part="root"
|
96
|
+
${attr(this.observedRecord)}
|
97
|
+
>
|
98
|
+
${htmlSlot()}
|
99
|
+
${this.value || this.dot
|
100
|
+
? html`
|
101
|
+
<div part="badge">${this.dot ? "" : this.formatValue(this.value)}</div>
|
102
|
+
`
|
103
|
+
: ""}
|
104
|
+
</div>
|
105
|
+
`;
|
103
106
|
}
|
104
107
|
}
|
105
108
|
|
package/src/components/breath.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { attr, godown, htmlStyle, styles } from "@godown/element";
|
2
|
-
import { css, html
|
2
|
+
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
|
-
import {
|
5
|
+
import { GlobalStyle, cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
6
6
|
|
7
7
|
const defineName = "breath";
|
8
8
|
const cssScope = scopePrefix(defineName);
|
@@ -48,11 +48,11 @@ const cssScope = scopePrefix(defineName);
|
|
48
48
|
}
|
49
49
|
|
50
50
|
:host,
|
51
|
-
:host([contents]) [part=root] {
|
51
|
+
:host([contents]) [part="root"] {
|
52
52
|
display: flex;
|
53
53
|
}
|
54
54
|
|
55
|
-
[part=root] {
|
55
|
+
[part="root"] {
|
56
56
|
display: contents;
|
57
57
|
}
|
58
58
|
|
@@ -108,16 +108,23 @@ class Breath extends GlobalStyle {
|
|
108
108
|
|
109
109
|
protected render(): TemplateResult<1> {
|
110
110
|
const texts = this.getTexts();
|
111
|
-
return html
|
112
|
-
|
113
|
-
|
111
|
+
return html`
|
112
|
+
<div
|
113
|
+
part="root"
|
114
|
+
${attr(this.observedRecord)}
|
115
|
+
>
|
116
|
+
${[texts.map(this.renderText), htmlStyle(this._computeStyle(texts.length))]}
|
117
|
+
</div>
|
118
|
+
`;
|
114
119
|
}
|
115
120
|
|
116
121
|
protected renderText(text: string): TemplateResult<1> {
|
117
|
-
return html
|
118
|
-
<span class="
|
119
|
-
|
120
|
-
|
122
|
+
return html`
|
123
|
+
<span class="rel">
|
124
|
+
<span class="nocolor">${text}</span>
|
125
|
+
<span class="colorful">${text}</span>
|
126
|
+
</span>
|
127
|
+
`;
|
121
128
|
}
|
122
129
|
|
123
130
|
protected getTexts(): string[] {
|
@@ -129,16 +136,13 @@ class Breath extends GlobalStyle {
|
|
129
136
|
const duration = this.parseDuration() || len * 2 + 2;
|
130
137
|
let style1 = "";
|
131
138
|
for (let number = 1; number <= len; number++) {
|
132
|
-
const delay = -duration / len * (len - number + 1);
|
139
|
+
const delay = (-duration / len) * (len - number + 1);
|
133
140
|
const defaultNumber = ((number - 1) % 3) + 1;
|
134
|
-
style1 +=
|
135
|
-
`.rel:nth-child(${number}) .colorful{animation-delay:${delay}s;background:var(${cssScope}--${number},var(${cssScope}--${defaultNumber}));}`;
|
141
|
+
style1 += `.rel:nth-child(${number}) .colorful{animation-delay:${delay}s;background:var(${cssScope}--${number},var(${cssScope}--${defaultNumber}));}`;
|
136
142
|
}
|
137
|
-
return
|
138
|
-
|
139
|
-
|
140
|
-
}%{opacity:1;}}${style1}`
|
141
|
-
);
|
143
|
+
return `.colorful{animation-duration:${duration}s;}@keyframes colorfulN{0%,${gap * 3}%{opacity:0;}${gap}%,${
|
144
|
+
gap * 2
|
145
|
+
}%{opacity:1;}}${style1}`;
|
142
146
|
}
|
143
147
|
|
144
148
|
protected parseDuration(): number | undefined {
|
package/src/components/button.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { attr, constructCSSObject, godown, htmlSlot, htmlStyle, part, styles, toVar } from "@godown/element";
|
2
|
-
import { css, html
|
2
|
+
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
|
-
import {
|
5
|
+
import { GlobalStyle, cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
6
6
|
|
7
7
|
const protoName = "button";
|
8
8
|
const cssScope = scopePrefix(protoName);
|
@@ -106,7 +106,7 @@ const colors: Record<Colors, string> = constructCSSObject(
|
|
106
106
|
|
107
107
|
:host([ghost]) {
|
108
108
|
${cssScope}--modal-background: var(${cssScope}--ghost-color);
|
109
|
-
box-shadow:inset 0px 0px 0px var(${cssScope}--ghost-width) var(${cssScope}--ghost-color);
|
109
|
+
box-shadow: inset 0px 0px 0px var(${cssScope}--ghost-width) var(${cssScope}--ghost-color);
|
110
110
|
color: var(${cssScope}--ghost-color);
|
111
111
|
background: transparent;
|
112
112
|
}
|
@@ -114,7 +114,7 @@ const colors: Record<Colors, string> = constructCSSObject(
|
|
114
114
|
css`
|
115
115
|
:host {
|
116
116
|
${cssScope}--padding-x: .5em;
|
117
|
-
${cssScope}--padding-y: min(calc(var(${cssScope}--padding-x) / 2), .
|
117
|
+
${cssScope}--padding-y: min(calc(var(${cssScope}--padding-x) / 2), .125em);
|
118
118
|
${cssScope}--padding: var(${cssScope}--padding-y) var(${cssScope}--padding-x);
|
119
119
|
${cssScope}--modal-animation-duration: 1s;
|
120
120
|
${cssScope}--ghost-width: .08em;
|
@@ -137,11 +137,11 @@ const colors: Record<Colors, string> = constructCSSObject(
|
|
137
137
|
cursor: pointer;
|
138
138
|
}
|
139
139
|
|
140
|
-
:host([contents]) [part=root] {
|
140
|
+
:host([contents]) [part="root"] {
|
141
141
|
width: fit-content;
|
142
142
|
}
|
143
143
|
|
144
|
-
[part=root] {
|
144
|
+
[part="root"] {
|
145
145
|
width: 100%;
|
146
146
|
height: 100%;
|
147
147
|
overflow: hidden;
|
@@ -150,9 +150,6 @@ const colors: Record<Colors, string> = constructCSSObject(
|
|
150
150
|
user-select: none;
|
151
151
|
border-radius: inherit;
|
152
152
|
transition-duration: inherit;
|
153
|
-
}
|
154
|
-
|
155
|
-
[part=content] {
|
156
153
|
padding: var(${cssScope}--padding);
|
157
154
|
}
|
158
155
|
|
@@ -228,12 +225,15 @@ class Button extends GlobalStyle {
|
|
228
225
|
|
229
226
|
protected render(): TemplateResult<1> {
|
230
227
|
const color = this.nextColor();
|
231
|
-
return html
|
232
|
-
<
|
233
|
-
|
234
|
-
${
|
228
|
+
return html`
|
229
|
+
<div
|
230
|
+
part="root"
|
231
|
+
${attr(this.observedRecord)}
|
232
|
+
>
|
233
|
+
<span part="modal-root"></span>
|
234
|
+
<div part="content">${[this.content || htmlSlot(), htmlStyle(colors[color])]}</div>
|
235
235
|
</div>
|
236
|
-
|
236
|
+
`;
|
237
237
|
}
|
238
238
|
|
239
239
|
focus(): void {
|
package/src/components/card.ts
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
import { attr, godown, htmlSlot, styles } from "@godown/element";
|
2
|
-
import { css, html
|
2
|
+
import { type TemplateResult, css, html } from "lit";
|
3
3
|
import { property } from "lit/decorators.js";
|
4
4
|
|
5
|
-
import {
|
6
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
5
|
+
import { GlobalStyle, cssGlobalVars, scopePrefix } from "../core/global-style.js";
|
7
6
|
import type Layout from "../layout.js";
|
8
7
|
|
9
8
|
const protoName = "card";
|
@@ -21,44 +20,42 @@ const cssScope = scopePrefix(protoName);
|
|
21
20
|
* @category display
|
22
21
|
*/
|
23
22
|
@godown(protoName)
|
24
|
-
@styles(
|
25
|
-
|
26
|
-
:
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
}
|
23
|
+
@styles(css`
|
24
|
+
:host {
|
25
|
+
${cssScope}--background: var(${cssGlobalVars.background});
|
26
|
+
${cssScope}--border-width: .0375em;
|
27
|
+
${cssScope}--border-color: transparent;
|
28
|
+
${cssScope}--border-background: var(${cssGlobalVars.passive});
|
29
|
+
${cssScope}--padding: .75em;
|
30
|
+
color: var(${cssGlobalVars.foreground});
|
31
|
+
background: var(${cssScope}--background);
|
32
|
+
border-width: var(${cssScope}--border-width);
|
33
|
+
display: block;
|
34
|
+
flex-shrink: 0;
|
35
|
+
position: relative;
|
36
|
+
overflow: hidden;
|
37
|
+
box-sizing: border-box;
|
38
|
+
}
|
41
39
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
40
|
+
slot {
|
41
|
+
display: block;
|
42
|
+
padding: var(${cssScope}--padding);
|
43
|
+
}
|
46
44
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
:host,
|
46
|
+
slot {
|
47
|
+
border-color: var(${cssScope}--border-background);
|
48
|
+
border-style: solid;
|
49
|
+
}
|
52
50
|
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
[name="footer"] {
|
52
|
+
border-top-width: var(${cssScope}--border-width);
|
53
|
+
}
|
56
54
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
)
|
55
|
+
[name="header"] {
|
56
|
+
border-bottom-width: var(${cssScope}--border-width);
|
57
|
+
}
|
58
|
+
`)
|
62
59
|
class Card extends GlobalStyle {
|
63
60
|
@property({ type: Boolean })
|
64
61
|
footer = false;
|
@@ -67,9 +64,14 @@ class Card extends GlobalStyle {
|
|
67
64
|
header = false;
|
68
65
|
|
69
66
|
protected render(): TemplateResult<1> {
|
70
|
-
return html
|
71
|
-
|
72
|
-
|
67
|
+
return html`
|
68
|
+
<div
|
69
|
+
part="root"
|
70
|
+
${attr(this.observedRecord)}
|
71
|
+
>
|
72
|
+
${[this.header ? htmlSlot("header") : "", htmlSlot(), this.footer ? htmlSlot("footer") : ""]}
|
73
|
+
</div>
|
74
|
+
`;
|
73
75
|
}
|
74
76
|
}
|
75
77
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { attr, godown, htmlSlot, htmlStyle, part, styles } from "@godown/element";
|
2
2
|
import iconChevronLeft from "@godown/f7-icon/icons/chevron-left.js";
|
3
3
|
import iconChevronRight from "@godown/f7-icon/icons/chevron-right.js";
|
4
|
-
import { css, html
|
4
|
+
import { type TemplateResult, css, html } from "lit";
|
5
5
|
import { property } from "lit/decorators.js";
|
6
6
|
|
7
7
|
import { GlobalStyle } from "../core/global-style.js";
|
@@ -23,52 +23,50 @@ const protoName = "carousel";
|
|
23
23
|
* @category display
|
24
24
|
*/
|
25
25
|
@godown(protoName)
|
26
|
-
@styles(
|
27
|
-
|
28
|
-
:
|
29
|
-
|
30
|
-
|
31
|
-
}
|
26
|
+
@styles(css`
|
27
|
+
:host {
|
28
|
+
display: block;
|
29
|
+
transition: 0.3s;
|
30
|
+
}
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
[part="root"] {
|
33
|
+
direction: ltr;
|
34
|
+
overflow: hidden;
|
35
|
+
}
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
37
|
+
[part="root"],
|
38
|
+
[part="move-root"] {
|
39
|
+
height: 100%;
|
40
|
+
width: 100%;
|
41
|
+
display: flex;
|
42
|
+
position: relative;
|
43
|
+
transition: inherit;
|
44
|
+
}
|
46
45
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
46
|
+
[part="prev"],
|
47
|
+
[part="next"] {
|
48
|
+
height: 100%;
|
49
|
+
width: 1.5em;
|
50
|
+
z-index: 1;
|
51
|
+
position: absolute;
|
52
|
+
display: flex;
|
53
|
+
align-items: center;
|
54
|
+
justify-content: center;
|
55
|
+
user-select: none;
|
56
|
+
}
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
[part="prev"] {
|
59
|
+
left: 0;
|
60
|
+
}
|
62
61
|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
[part="next"] {
|
63
|
+
right: 0;
|
64
|
+
}
|
66
65
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
)
|
66
|
+
slot::slotted(*) {
|
67
|
+
flex-shrink: 0 !important;
|
68
|
+
}
|
69
|
+
`)
|
72
70
|
class Carousel extends GlobalStyle {
|
73
71
|
/**
|
74
72
|
* The index of the element is displayed for the first time.
|
@@ -98,12 +96,32 @@ class Carousel extends GlobalStyle {
|
|
98
96
|
private _cloneLast: HTMLElement | undefined;
|
99
97
|
|
100
98
|
protected render(): TemplateResult<1> {
|
101
|
-
return html
|
102
|
-
<
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
99
|
+
return html`
|
100
|
+
<div
|
101
|
+
part="root"
|
102
|
+
${attr(this.observedRecord)}
|
103
|
+
>
|
104
|
+
<i
|
105
|
+
part="prev"
|
106
|
+
@click="${this.prev}"
|
107
|
+
>
|
108
|
+
${iconChevronLeft()}
|
109
|
+
</i>
|
110
|
+
<div
|
111
|
+
part="move-root"
|
112
|
+
style="transform:${`translateX(-${this.index + 1}00%)`}"
|
113
|
+
>
|
114
|
+
${htmlSlot()}
|
115
|
+
</div>
|
116
|
+
<i
|
117
|
+
part="next"
|
118
|
+
@click="${this.next}"
|
119
|
+
>
|
120
|
+
${iconChevronRight()}
|
121
|
+
</i>
|
122
|
+
${htmlStyle(`:host,:host([contents]) [part=root]{width:${this.width};}`)}
|
123
|
+
</div>
|
124
|
+
`;
|
107
125
|
}
|
108
126
|
|
109
127
|
protected async firstUpdated(): Promise<void> {
|