@internetarchive/elements 0.0.1 → 0.1.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.
- package/dist/src/elements/ia-button/ia-button.d.ts.map +1 -1
- package/dist/src/elements/ia-button/ia-button.js +16 -6
- package/dist/src/elements/ia-button/ia-button.js.map +1 -1
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.d.ts +21 -0
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.d.ts.map +1 -0
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.js +220 -0
- package/dist/src/elements/ia-status-indicator/ia-status-indicator.js.map +1 -0
- package/dist/src/labs/ia-snow/ia-snow.d.ts +3 -2
- package/dist/src/labs/ia-snow/ia-snow.d.ts.map +1 -1
- package/dist/src/labs/ia-snow/ia-snow.js +43 -26
- package/dist/src/labs/ia-snow/ia-snow.js.map +1 -1
- package/dist/src/themes/theme-styles.d.ts +3 -0
- package/dist/src/themes/theme-styles.d.ts.map +1 -0
- package/dist/src/themes/theme-styles.js +67 -0
- package/dist/src/themes/theme-styles.js.map +1 -0
- package/dist/src/util/lazy-load-template.d.ts +51 -0
- package/dist/src/util/lazy-load-template.d.ts.map +1 -0
- package/dist/src/util/lazy-load-template.js +50 -0
- package/dist/src/util/lazy-load-template.js.map +1 -0
- package/package.json +2 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-button.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-button/ia-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-button.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-button/ia-button.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAC;AAKjE;;GAEG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,MAAM;IAQN,MAAM,KAAK,MAAM,IAAI,cAAc,CAgBlC;CACF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { customElement } from 'lit/decorators/custom-element.js';
|
|
4
|
+
import themeStyles from '../../themes/theme-styles';
|
|
4
5
|
/**
|
|
5
6
|
* A button element to demo the elements library
|
|
6
7
|
*/
|
|
@@ -13,12 +14,21 @@ let IAButton = class IAButton extends LitElement {
|
|
|
13
14
|
`;
|
|
14
15
|
}
|
|
15
16
|
static get styles() {
|
|
16
|
-
return
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
return [
|
|
18
|
+
themeStyles,
|
|
19
|
+
css `
|
|
20
|
+
:host {
|
|
21
|
+
--primary-background-color--: var(--primary-cta-fill);
|
|
22
|
+
--primary-text-color--: var(--primary-cta-text-color);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
button {
|
|
26
|
+
padding: 8px 16px;
|
|
27
|
+
background-color: var(--primary-background-color--);
|
|
28
|
+
color: var(--primary-text-color--);
|
|
29
|
+
}
|
|
30
|
+
`,
|
|
31
|
+
];
|
|
22
32
|
}
|
|
23
33
|
};
|
|
24
34
|
IAButton = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-button.js","sourceRoot":"","sources":["../../../../src/elements/ia-button/ia-button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE;;GAEG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IACtC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;KAIV,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA
|
|
1
|
+
{"version":3,"file":"ia-button.js","sourceRoot":"","sources":["../../../../src/elements/ia-button/ia-button.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAuB,MAAM,KAAK,CAAC;AACjE,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD;;GAEG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IACtC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;KAIV,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;OAWF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1BY,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA0BpB","sourcesContent":["import { css, html, LitElement, type CSSResultGroup } from 'lit';\nimport { customElement } from 'lit/decorators/custom-element.js';\n\nimport themeStyles from '@src/themes/theme-styles';\n\n/**\n * A button element to demo the elements library\n */\n@customElement('ia-button')\nexport class IAButton extends LitElement {\n render() {\n return html`\n <button>\n <slot></slot>\n </button>\n `;\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --primary-background-color--: var(--primary-cta-fill);\n --primary-text-color--: var(--primary-cta-text-color);\n }\n\n button {\n padding: 8px 16px;\n background-color: var(--primary-background-color--);\n color: var(--primary-text-color--);\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CSSResultGroup, LitElement, TemplateResult } from 'lit';
|
|
2
|
+
/**
|
|
3
|
+
* Renders an SVG indicator, which defualts to an animated circular indicator
|
|
4
|
+
*/
|
|
5
|
+
export declare class IAStatusIndicator extends LitElement {
|
|
6
|
+
loadingTitle: string;
|
|
7
|
+
successTitle: string;
|
|
8
|
+
errorTitle: string;
|
|
9
|
+
loadingStyle: 'ring' | 'ring-dots';
|
|
10
|
+
mode: 'loading' | 'success' | 'error';
|
|
11
|
+
render(): TemplateResult;
|
|
12
|
+
/** A circular loading indicator to render when processing */
|
|
13
|
+
private get loadingIndicatorTemplate();
|
|
14
|
+
/** A check mark to render on success */
|
|
15
|
+
private get successIndicatorTemplate();
|
|
16
|
+
/** An "!" to render on error */
|
|
17
|
+
private get errorIndicatorTemplate();
|
|
18
|
+
private get shouldShowLoadingDots();
|
|
19
|
+
static get styles(): CSSResultGroup;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ia-status-indicator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ia-status-indicator.d.ts","sourceRoot":"","sources":["../../../../src/elements/ia-status-indicator/ia-status-indicator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAO,cAAc,EAAQ,UAAU,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAO5E;;GAEG;AACH,qBACa,iBAAkB,SAAQ,UAAU;IAEnB,YAAY,SAAqB;IAGjC,YAAY,SAAkB;IAG9B,UAAU,SAAgB;IAG1B,YAAY,EAAE,MAAM,GAAG,WAAW,CAAe;IAGjD,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,OAAO,CAAa;IAE9E,MAAM,IAAI,cAAc;IAQxB,6DAA6D;IAC7D,OAAO,KAAK,wBAAwB,GA4BnC;IAED,wCAAwC;IACxC,OAAO,KAAK,wBAAwB,GAyBnC;IAED,gCAAgC;IAChC,OAAO,KAAK,sBAAsB,GAkBjC;IAGD,OAAO,KAAK,qBAAqB,GAIhC;IAED,MAAM,KAAK,MAAM,IAAI,cAAc,CAqFlC;CACF"}
|
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { css, html, LitElement } from 'lit';
|
|
3
|
+
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
+
import { msg } from '@lit/localize';
|
|
5
|
+
import { choose } from 'lit/directives/choose.js';
|
|
6
|
+
import themeStyles from '../../themes/theme-styles';
|
|
7
|
+
/**
|
|
8
|
+
* Renders an SVG indicator, which defualts to an animated circular indicator
|
|
9
|
+
*/
|
|
10
|
+
let IAStatusIndicator = class IAStatusIndicator extends LitElement {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
/* An optional title to use for the loading state of the indicator. Will be used for screen readers. */
|
|
14
|
+
this.loadingTitle = msg('Loading...');
|
|
15
|
+
/* An optional title to use for the success state of the indicator. Will be used for screen readers. */
|
|
16
|
+
this.successTitle = msg('Success');
|
|
17
|
+
/* An optional title to use for the error state of the indicator. Will be used for screen readers. */
|
|
18
|
+
this.errorTitle = msg('Error');
|
|
19
|
+
/* Which type of loading indicator to display */
|
|
20
|
+
this.loadingStyle = 'ring-dots';
|
|
21
|
+
/* The state of the indicator that should be shown */
|
|
22
|
+
this.mode = 'loading';
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return html `${choose(this.mode, [
|
|
26
|
+
['loading', () => this.loadingIndicatorTemplate],
|
|
27
|
+
['success', () => this.successIndicatorTemplate],
|
|
28
|
+
['error', () => this.errorIndicatorTemplate],
|
|
29
|
+
])}`;
|
|
30
|
+
}
|
|
31
|
+
/** A circular loading indicator to render when processing */
|
|
32
|
+
get loadingIndicatorTemplate() {
|
|
33
|
+
return html `
|
|
34
|
+
<svg
|
|
35
|
+
class="loading-indicator"
|
|
36
|
+
viewBox="0 0 120 120"
|
|
37
|
+
preserveAspectRatio="none"
|
|
38
|
+
version="1.1"
|
|
39
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
40
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
41
|
+
role="status"
|
|
42
|
+
>
|
|
43
|
+
<title>${this.loadingTitle}</title>
|
|
44
|
+
<g stroke="none" stroke-width="1" fill-rule="evenodd">
|
|
45
|
+
<path
|
|
46
|
+
class="loading-ring"
|
|
47
|
+
d="M60,10 C69.8019971,10 78.9452178,12.8205573 86.6623125,17.6943223 L76.4086287,27.9484118 C71.4880919,25.4243078 65.9103784,24 60,24 C40.117749,24 24,40.117749 24,60 C24,79.882251 40.117749,96 60,96 C79.882251,96 96,79.882251 96,60 C96,53.3014663 94.1704984,47.0302355 90.9839104,41.6587228 L101.110332,31.5326452 C106.715332,39.6116982 110,49.4222615 110,60 C110,87.6142375 87.6142375,110 60,110 C32.3857625,110 10,87.6142375 10,60 C10,32.3857625 32.3857625,10 60,10 Z"
|
|
48
|
+
></path>
|
|
49
|
+
<g
|
|
50
|
+
class="loading-dots ${!this.shouldShowLoadingDots ? 'hidden' : ''}"
|
|
51
|
+
transform="translate(40.000000, 55.000000)"
|
|
52
|
+
>
|
|
53
|
+
<circle id="left-dot" cx="5" cy="5" r="5"></circle>
|
|
54
|
+
<circle id="middle-dot" cx="20" cy="5" r="5"></circle>
|
|
55
|
+
<circle id="right-dot" cx="35" cy="5" r="5"></circle>
|
|
56
|
+
</g>
|
|
57
|
+
</g>
|
|
58
|
+
</svg>
|
|
59
|
+
`;
|
|
60
|
+
}
|
|
61
|
+
/** A check mark to render on success */
|
|
62
|
+
get successIndicatorTemplate() {
|
|
63
|
+
return html `
|
|
64
|
+
<svg
|
|
65
|
+
class="success-indicator"
|
|
66
|
+
viewBox="0 0 120 120"
|
|
67
|
+
preserveAspectRatio="none"
|
|
68
|
+
version="1.1"
|
|
69
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
70
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
71
|
+
role="status"
|
|
72
|
+
>
|
|
73
|
+
<title>${this.successTitle}</title>
|
|
74
|
+
<g stroke="none" stroke-width="1" fill-rule="evenodd">
|
|
75
|
+
<path
|
|
76
|
+
class="success-icon"
|
|
77
|
+
d="M60,10 C70.5816709,10 80.3955961,13.2871104 88.4763646,18.8959201 L78.3502633,29.0214223 C72.9767592,25.8315427 66.7022695,24 60,24 C40.117749,24 24,40.117749 24,60 C24,79.882251 40.117749,96 60,96 C79.882251,96 96,79.882251 96,60 L95.995,59.46 L108.327675,47.128668 C109.350926,50.9806166 109.925886,55.015198 109.993301,59.1731586 L110,60 C110,87.6142375 87.6142375,110 60,110 C32.3857625,110 10,87.6142375 10,60 C10,32.3857625 32.3857625,10 60,10 Z"
|
|
78
|
+
></path>
|
|
79
|
+
<polygon
|
|
80
|
+
class="success-icon"
|
|
81
|
+
transform="translate(75.000000, 41.500000) rotate(44.000000) translate(-75.000000, -41.500000) "
|
|
82
|
+
points="96 85 54 85 54 65 76 64.999 76 -2 96 -2"
|
|
83
|
+
></polygon>
|
|
84
|
+
</g>
|
|
85
|
+
</svg>
|
|
86
|
+
`;
|
|
87
|
+
}
|
|
88
|
+
/** An "!" to render on error */
|
|
89
|
+
get errorIndicatorTemplate() {
|
|
90
|
+
return html `
|
|
91
|
+
<svg
|
|
92
|
+
class="error-indicator"
|
|
93
|
+
viewBox="0 0 120 120"
|
|
94
|
+
preserveAspectRatio="none"
|
|
95
|
+
version="1.1"
|
|
96
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
97
|
+
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
98
|
+
role="status"
|
|
99
|
+
>
|
|
100
|
+
<title>${this.errorTitle}</title>
|
|
101
|
+
<path
|
|
102
|
+
class="error-icon"
|
|
103
|
+
d="m56.4612493 8.80450354 41.8901185 75.94632926c1.7706782 2.8433173 2.1150372 5.2623412 1.0330766 7.2570716-1.0819604 1.9947304-3.26978 2.9920956-6.5634587 2.9920956h-85.69973905c-3.29367873 0-5.46954894-.9973652-6.52761065-2.9920956-1.0580617-1.9947304-.70175345-4.4137543 1.06892476-7.2570716l41.89011844-75.12308969c1.8184757-2.84331737 3.9693609-4.37738627 6.4526556-4.60220671s4.6341799 1.03483527 6.4526556 3.77896714zm28.5387507 75.19549646-35.037482-62-34.962518 62zm-31-34.7484359v-10.2515641h-8v10.2515641l2.089172 14.7484359h3.8184713zm-8 19.7484359v8h8v-8z"
|
|
104
|
+
/>
|
|
105
|
+
</svg>
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
/* Whether to include the dots in the loading indicator */
|
|
109
|
+
get shouldShowLoadingDots() {
|
|
110
|
+
if (this.loadingStyle === 'ring')
|
|
111
|
+
return false;
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
static get styles() {
|
|
115
|
+
return [
|
|
116
|
+
themeStyles,
|
|
117
|
+
css `
|
|
118
|
+
:host {
|
|
119
|
+
--indicator-width--: var(--icon-width);
|
|
120
|
+
|
|
121
|
+
/* Loading */
|
|
122
|
+
--loading-ring-color--: var(--primary-text-color);
|
|
123
|
+
--loading-dot-color--: var(--primary-text-color);
|
|
124
|
+
|
|
125
|
+
/* Success */
|
|
126
|
+
--success-icon-color--: var(--color-success);
|
|
127
|
+
|
|
128
|
+
/* Error */
|
|
129
|
+
--error-icon-color--: var(--color-danger);
|
|
130
|
+
|
|
131
|
+
display: inline-block;
|
|
132
|
+
width: var(--indicator-width--);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.success-icon {
|
|
136
|
+
fill: var(--success-icon-color--);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
.error-icon {
|
|
140
|
+
fill: var(--error-icon-color--);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
.loading-ring {
|
|
144
|
+
fill: var(--loading-ring-color--);
|
|
145
|
+
animation: rotate 1.3s infinite linear;
|
|
146
|
+
transform-origin: 50px 50px;
|
|
147
|
+
transform-box: fill-box;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
.loading-dots {
|
|
151
|
+
fill: var(--loading-dot-color--);
|
|
152
|
+
transition: opacity 0.25s ease-out;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
.loading-dots.hidden {
|
|
156
|
+
display: none;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.loading-dots > * {
|
|
160
|
+
opacity: 0;
|
|
161
|
+
animation: dot 1.3s infinite;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.loading-dots #left-dot {
|
|
165
|
+
animation-delay: 0.2s;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.loading-dots #middle-dot {
|
|
169
|
+
animation-delay: 0.4s;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.loading-dots #right-dot {
|
|
173
|
+
animation-delay: 0.6s;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
@keyframes rotate {
|
|
177
|
+
0% {
|
|
178
|
+
transform: rotate(-360deg);
|
|
179
|
+
}
|
|
180
|
+
100% {
|
|
181
|
+
/* This frame is supposed to be inferred, but Safari doesn't rotate it unless we're explicit */
|
|
182
|
+
transform: rotate(0deg);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
@keyframes dot {
|
|
187
|
+
0% {
|
|
188
|
+
opacity: 0;
|
|
189
|
+
}
|
|
190
|
+
25% {
|
|
191
|
+
opacity: 1;
|
|
192
|
+
}
|
|
193
|
+
100% {
|
|
194
|
+
opacity: 0;
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
`,
|
|
198
|
+
];
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
__decorate([
|
|
202
|
+
property({ type: String })
|
|
203
|
+
], IAStatusIndicator.prototype, "loadingTitle", void 0);
|
|
204
|
+
__decorate([
|
|
205
|
+
property({ type: String })
|
|
206
|
+
], IAStatusIndicator.prototype, "successTitle", void 0);
|
|
207
|
+
__decorate([
|
|
208
|
+
property({ type: String })
|
|
209
|
+
], IAStatusIndicator.prototype, "errorTitle", void 0);
|
|
210
|
+
__decorate([
|
|
211
|
+
property({ type: String })
|
|
212
|
+
], IAStatusIndicator.prototype, "loadingStyle", void 0);
|
|
213
|
+
__decorate([
|
|
214
|
+
property({ type: String })
|
|
215
|
+
], IAStatusIndicator.prototype, "mode", void 0);
|
|
216
|
+
IAStatusIndicator = __decorate([
|
|
217
|
+
customElement('ia-status-indicator')
|
|
218
|
+
], IAStatusIndicator);
|
|
219
|
+
export { IAStatusIndicator };
|
|
220
|
+
//# sourceMappingURL=ia-status-indicator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ia-status-indicator.js","sourceRoot":"","sources":["../../../../src/elements/ia-status-indicator/ia-status-indicator.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAkB,MAAM,KAAK,CAAC;AAC5E,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,WAAW,MAAM,0BAA0B,CAAC;AAEnD;;GAEG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,UAAU;IAA1C;;QACL,uGAAuG;QAC3E,iBAAY,GAAG,GAAG,CAAC,YAAY,CAAC,CAAC;QAE7D,uGAAuG;QAC3E,iBAAY,GAAG,GAAG,CAAC,SAAS,CAAC,CAAC;QAE1D,qGAAqG;QACzE,eAAU,GAAG,GAAG,CAAC,OAAO,CAAC,CAAC;QAEtD,gDAAgD;QACpB,iBAAY,GAAyB,WAAW,CAAC;QAE7E,qDAAqD;QACzB,SAAI,GAAoC,SAAS,CAAC;IAuLhF,CAAC;IArLC,MAAM;QACJ,OAAO,IAAI,CAAA,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE;YAC9B,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC;YAChD,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,wBAAwB,CAAC;YAChD,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,sBAAsB,CAAC;SAC7C,CAAC,EAAE,CAAC;IACP,CAAC;IAED,6DAA6D;IAC7D,IAAY,wBAAwB;QAClC,OAAO,IAAI,CAAA;;;;;;;;;;iBAUE,IAAI,CAAC,YAAY;;;;;;;kCAOA,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;;;;;;;;;KASxE,CAAC;IACJ,CAAC;IAED,wCAAwC;IACxC,IAAY,wBAAwB;QAClC,OAAO,IAAI,CAAA;;;;;;;;;;iBAUE,IAAI,CAAC,YAAY;;;;;;;;;;;;;KAa7B,CAAC;IACJ,CAAC;IAED,gCAAgC;IAChC,IAAY,sBAAsB;QAChC,OAAO,IAAI,CAAA;;;;;;;;;;iBAUE,IAAI,CAAC,UAAU;;;;;;KAM3B,CAAC;IACJ,CAAC;IAED,0DAA0D;IAC1D,IAAY,qBAAqB;QAC/B,IAAI,IAAI,CAAC,YAAY,KAAK,MAAM;YAAE,OAAO,KAAK,CAAC;QAE/C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO;YACL,WAAW;YACX,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgFF;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAnM6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAkC;AAGjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAA+B;AAG9B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAA2B;AAG1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAAkD;AAGjD;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+CAAmD;AAdnE,iBAAiB;IAD7B,aAAa,CAAC,qBAAqB,CAAC;GACxB,iBAAiB,CAqM7B","sourcesContent":["import { css, CSSResultGroup, html, LitElement, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport { choose } from 'lit/directives/choose.js';\n\nimport themeStyles from '@src/themes/theme-styles';\n\n/**\n * Renders an SVG indicator, which defualts to an animated circular indicator\n */\n@customElement('ia-status-indicator')\nexport class IAStatusIndicator extends LitElement {\n /* An optional title to use for the loading state of the indicator. Will be used for screen readers. */\n @property({ type: String }) loadingTitle = msg('Loading...');\n\n /* An optional title to use for the success state of the indicator. Will be used for screen readers. */\n @property({ type: String }) successTitle = msg('Success');\n\n /* An optional title to use for the error state of the indicator. Will be used for screen readers. */\n @property({ type: String }) errorTitle = msg('Error');\n\n /* Which type of loading indicator to display */\n @property({ type: String }) loadingStyle: 'ring' | 'ring-dots' = 'ring-dots';\n\n /* The state of the indicator that should be shown */\n @property({ type: String }) mode: 'loading' | 'success' | 'error' = 'loading';\n\n render(): TemplateResult {\n return html`${choose(this.mode, [\n ['loading', () => this.loadingIndicatorTemplate],\n ['success', () => this.successIndicatorTemplate],\n ['error', () => this.errorIndicatorTemplate],\n ])}`;\n }\n\n /** A circular loading indicator to render when processing */\n private get loadingIndicatorTemplate(): TemplateResult {\n return html`\n <svg\n class=\"loading-indicator\"\n viewBox=\"0 0 120 120\"\n preserveAspectRatio=\"none\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n role=\"status\"\n >\n <title>${this.loadingTitle}</title>\n <g stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n class=\"loading-ring\"\n d=\"M60,10 C69.8019971,10 78.9452178,12.8205573 86.6623125,17.6943223 L76.4086287,27.9484118 C71.4880919,25.4243078 65.9103784,24 60,24 C40.117749,24 24,40.117749 24,60 C24,79.882251 40.117749,96 60,96 C79.882251,96 96,79.882251 96,60 C96,53.3014663 94.1704984,47.0302355 90.9839104,41.6587228 L101.110332,31.5326452 C106.715332,39.6116982 110,49.4222615 110,60 C110,87.6142375 87.6142375,110 60,110 C32.3857625,110 10,87.6142375 10,60 C10,32.3857625 32.3857625,10 60,10 Z\"\n ></path>\n <g\n class=\"loading-dots ${!this.shouldShowLoadingDots ? 'hidden' : ''}\"\n transform=\"translate(40.000000, 55.000000)\"\n >\n <circle id=\"left-dot\" cx=\"5\" cy=\"5\" r=\"5\"></circle>\n <circle id=\"middle-dot\" cx=\"20\" cy=\"5\" r=\"5\"></circle>\n <circle id=\"right-dot\" cx=\"35\" cy=\"5\" r=\"5\"></circle>\n </g>\n </g>\n </svg>\n `;\n }\n\n /** A check mark to render on success */\n private get successIndicatorTemplate(): TemplateResult {\n return html`\n <svg\n class=\"success-indicator\"\n viewBox=\"0 0 120 120\"\n preserveAspectRatio=\"none\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n role=\"status\"\n >\n <title>${this.successTitle}</title>\n <g stroke=\"none\" stroke-width=\"1\" fill-rule=\"evenodd\">\n <path\n class=\"success-icon\"\n d=\"M60,10 C70.5816709,10 80.3955961,13.2871104 88.4763646,18.8959201 L78.3502633,29.0214223 C72.9767592,25.8315427 66.7022695,24 60,24 C40.117749,24 24,40.117749 24,60 C24,79.882251 40.117749,96 60,96 C79.882251,96 96,79.882251 96,60 L95.995,59.46 L108.327675,47.128668 C109.350926,50.9806166 109.925886,55.015198 109.993301,59.1731586 L110,60 C110,87.6142375 87.6142375,110 60,110 C32.3857625,110 10,87.6142375 10,60 C10,32.3857625 32.3857625,10 60,10 Z\"\n ></path>\n <polygon\n class=\"success-icon\"\n transform=\"translate(75.000000, 41.500000) rotate(44.000000) translate(-75.000000, -41.500000) \"\n points=\"96 85 54 85 54 65 76 64.999 76 -2 96 -2\"\n ></polygon>\n </g>\n </svg>\n `;\n }\n\n /** An \"!\" to render on error */\n private get errorIndicatorTemplate(): TemplateResult {\n return html`\n <svg\n class=\"error-indicator\"\n viewBox=\"0 0 120 120\"\n preserveAspectRatio=\"none\"\n version=\"1.1\"\n xmlns=\"http://www.w3.org/2000/svg\"\n xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n role=\"status\"\n >\n <title>${this.errorTitle}</title>\n <path\n class=\"error-icon\"\n d=\"m56.4612493 8.80450354 41.8901185 75.94632926c1.7706782 2.8433173 2.1150372 5.2623412 1.0330766 7.2570716-1.0819604 1.9947304-3.26978 2.9920956-6.5634587 2.9920956h-85.69973905c-3.29367873 0-5.46954894-.9973652-6.52761065-2.9920956-1.0580617-1.9947304-.70175345-4.4137543 1.06892476-7.2570716l41.89011844-75.12308969c1.8184757-2.84331737 3.9693609-4.37738627 6.4526556-4.60220671s4.6341799 1.03483527 6.4526556 3.77896714zm28.5387507 75.19549646-35.037482-62-34.962518 62zm-31-34.7484359v-10.2515641h-8v10.2515641l2.089172 14.7484359h3.8184713zm-8 19.7484359v8h8v-8z\"\n />\n </svg>\n `;\n }\n\n /* Whether to include the dots in the loading indicator */\n private get shouldShowLoadingDots(): boolean {\n if (this.loadingStyle === 'ring') return false;\n\n return true;\n }\n\n static get styles(): CSSResultGroup {\n return [\n themeStyles,\n css`\n :host {\n --indicator-width--: var(--icon-width);\n\n /* Loading */\n --loading-ring-color--: var(--primary-text-color);\n --loading-dot-color--: var(--primary-text-color);\n\n /* Success */\n --success-icon-color--: var(--color-success);\n\n /* Error */\n --error-icon-color--: var(--color-danger);\n\n display: inline-block;\n width: var(--indicator-width--);\n }\n\n .success-icon {\n fill: var(--success-icon-color--);\n }\n\n .error-icon {\n fill: var(--error-icon-color--);\n }\n\n .loading-ring {\n fill: var(--loading-ring-color--);\n animation: rotate 1.3s infinite linear;\n transform-origin: 50px 50px;\n transform-box: fill-box;\n }\n\n .loading-dots {\n fill: var(--loading-dot-color--);\n transition: opacity 0.25s ease-out;\n }\n\n .loading-dots.hidden {\n display: none;\n }\n\n .loading-dots > * {\n opacity: 0;\n animation: dot 1.3s infinite;\n }\n\n .loading-dots #left-dot {\n animation-delay: 0.2s;\n }\n\n .loading-dots #middle-dot {\n animation-delay: 0.4s;\n }\n\n .loading-dots #right-dot {\n animation-delay: 0.6s;\n }\n\n @keyframes rotate {\n 0% {\n transform: rotate(-360deg);\n }\n 100% {\n /* This frame is supposed to be inferred, but Safari doesn't rotate it unless we're explicit */\n transform: rotate(0deg);\n }\n }\n\n @keyframes dot {\n 0% {\n opacity: 0;\n }\n 25% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { LitElement, type CSSResultGroup, type PropertyValues } from 'lit';
|
|
2
|
-
import {
|
|
3
|
-
import '../../elements/ia-button/ia-button';
|
|
2
|
+
import type { SnowflakesParams } from 'magic-snowflakes';
|
|
4
3
|
/**
|
|
5
4
|
* An element that shows snowflakes to demo the elements library
|
|
6
5
|
*/
|
|
@@ -10,6 +9,8 @@ export declare class IASnow extends LitElement {
|
|
|
10
9
|
private snowflakes?;
|
|
11
10
|
render(): import("lit-html").TemplateResult<1>;
|
|
12
11
|
protected willUpdate(_changedProperties: PropertyValues): void;
|
|
12
|
+
private get startButtonTemplate();
|
|
13
|
+
private get clearButtonTemplate();
|
|
13
14
|
private startSnowing;
|
|
14
15
|
private stopSnowing;
|
|
15
16
|
static get styles(): CSSResultGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-snow.d.ts","sourceRoot":"","sources":["../../../../src/labs/ia-snow/ia-snow.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-snow.d.ts","sourceRoot":"","sources":["../../../../src/labs/ia-snow/ia-snow.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,EACV,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,KAAK,CAAC;AAMb,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAQzD;;GAEG;AACH,qBACa,MAAO,SAAQ,UAAU;IACR,UAAU,CAAC,EAAE,gBAAgB,CAAC;IAG1D,OAAO,CAAC,OAAO,CAAS;IAExB,OAAO,CAAC,UAAU,CAAC,CAAa;IAEhC,MAAM;IAON,SAAS,CAAC,UAAU,CAAC,kBAAkB,EAAE,cAAc,GAAG,IAAI;IAc9D,OAAO,KAAK,mBAAmB,GAmB9B;IAED,OAAO,KAAK,mBAAmB,GAe9B;YAEa,YAAY;IAW1B,OAAO,CAAC,WAAW;IAKnB,MAAM,KAAK,MAAM,IAAI,cAAc,CAQlC;CACF"}
|
|
@@ -3,9 +3,8 @@ import { css, html, LitElement, } from 'lit';
|
|
|
3
3
|
import { property } from 'lit/decorators.js';
|
|
4
4
|
import { customElement } from 'lit/decorators/custom-element.js';
|
|
5
5
|
import { state } from 'lit/decorators/state.js';
|
|
6
|
-
import Snowflakes from 'magic-snowflakes';
|
|
7
|
-
import '../../elements/ia-button/ia-button';
|
|
8
6
|
import flakeIcon from './flake.svg';
|
|
7
|
+
import { lazyLoadTemplate, } from '../../util/lazy-load-template';
|
|
9
8
|
/**
|
|
10
9
|
* An element that shows snowflakes to demo the elements library
|
|
11
10
|
*/
|
|
@@ -16,29 +15,7 @@ let IASnow = class IASnow extends LitElement {
|
|
|
16
15
|
}
|
|
17
16
|
render() {
|
|
18
17
|
return html `
|
|
19
|
-
|
|
20
|
-
@click=${() => {
|
|
21
|
-
if (this.snowing) {
|
|
22
|
-
this.stopSnowing();
|
|
23
|
-
}
|
|
24
|
-
else {
|
|
25
|
-
this.startSnowing();
|
|
26
|
-
}
|
|
27
|
-
}}
|
|
28
|
-
>
|
|
29
|
-
${this.snowing ? 'Stop Snowflakes' : 'Start Snowflakes'}
|
|
30
|
-
</ia-button>
|
|
31
|
-
|
|
32
|
-
<ia-button
|
|
33
|
-
@click=${() => {
|
|
34
|
-
this.stopSnowing();
|
|
35
|
-
this.snowflakes?.destroy();
|
|
36
|
-
this.snowflakes = undefined;
|
|
37
|
-
}}
|
|
38
|
-
>
|
|
39
|
-
Clear Snowflakes
|
|
40
|
-
</ia-button>
|
|
41
|
-
|
|
18
|
+
${this.startButtonTemplate} ${this.clearButtonTemplate}
|
|
42
19
|
<img src=${flakeIcon} alt="Snowflakes icon" />
|
|
43
20
|
`;
|
|
44
21
|
}
|
|
@@ -49,8 +26,48 @@ let IASnow = class IASnow extends LitElement {
|
|
|
49
26
|
this.startSnowing();
|
|
50
27
|
}
|
|
51
28
|
}
|
|
52
|
-
|
|
29
|
+
// Consider lazy loading external templates if they are large,
|
|
30
|
+
// below the fold or not needed immediately. This will reduce the initial
|
|
31
|
+
// bundle size.
|
|
32
|
+
//
|
|
33
|
+
// Note: In this case, ia-button is visible immediately so it's not a great
|
|
34
|
+
// example, but it demonstrates the lazy loading pattern.
|
|
35
|
+
get startButtonTemplate() {
|
|
36
|
+
return lazyLoadTemplate(async () => {
|
|
37
|
+
await import('../../elements/ia-button/ia-button');
|
|
38
|
+
}, () => html `
|
|
39
|
+
<ia-button
|
|
40
|
+
@click=${() => {
|
|
41
|
+
if (this.snowing) {
|
|
42
|
+
this.stopSnowing();
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
this.startSnowing();
|
|
46
|
+
}
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
${this.snowing ? 'Stop Snowflakes' : 'Start Snowflakes'}
|
|
50
|
+
</ia-button>
|
|
51
|
+
`);
|
|
52
|
+
}
|
|
53
|
+
get clearButtonTemplate() {
|
|
54
|
+
return lazyLoadTemplate(async () => {
|
|
55
|
+
await import('../../elements/ia-button/ia-button');
|
|
56
|
+
}, () => html `
|
|
57
|
+
<ia-button
|
|
58
|
+
@click=${() => {
|
|
59
|
+
this.snowflakes?.destroy();
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
Clear Snowflakes
|
|
63
|
+
</ia-button>
|
|
64
|
+
`);
|
|
65
|
+
}
|
|
66
|
+
async startSnowing() {
|
|
53
67
|
if (!this.snowflakes) {
|
|
68
|
+
// lazy load dependencies when possible to reduce initial bundle size
|
|
69
|
+
const SnowflakesModule = await import('magic-snowflakes');
|
|
70
|
+
const Snowflakes = SnowflakesModule.default;
|
|
54
71
|
this.snowflakes = new Snowflakes(this.snowConfig);
|
|
55
72
|
}
|
|
56
73
|
this.snowflakes?.start();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ia-snow.js","sourceRoot":"","sources":["../../../../src/labs/ia-snow/ia-snow.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,GAGX,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"ia-snow.js","sourceRoot":"","sources":["../../../../src/labs/ia-snow/ia-snow.ts"],"names":[],"mappings":"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","sourcesContent":["import {\n css,\n html,\n LitElement,\n type CSSResultGroup,\n type PropertyValues,\n} from 'lit';\nimport { property } from 'lit/decorators.js';\nimport { customElement } from 'lit/decorators/custom-element.js';\nimport { state } from 'lit/decorators/state.js';\n\nimport type Snowflakes from 'magic-snowflakes';\nimport type { SnowflakesParams } from 'magic-snowflakes';\n\nimport flakeIcon from './flake.svg';\nimport {\n lazyLoadTemplate,\n type LazyLoadedTemplate,\n} from '@src/util/lazy-load-template';\n\n/**\n * An element that shows snowflakes to demo the elements library\n */\n@customElement('ia-snow')\nexport class IASnow extends LitElement {\n @property({ type: Object }) snowConfig?: SnowflakesParams;\n\n @state()\n private snowing = false;\n\n private snowflakes?: Snowflakes;\n\n render() {\n return html`\n ${this.startButtonTemplate} ${this.clearButtonTemplate}\n <img src=${flakeIcon} alt=\"Snowflakes icon\" />\n `;\n }\n\n protected willUpdate(_changedProperties: PropertyValues): void {\n if (_changedProperties.has('snowConfig')) {\n this.snowflakes?.destroy();\n this.snowflakes = undefined;\n this.startSnowing();\n }\n }\n\n // Consider lazy loading external templates if they are large,\n // below the fold or not needed immediately. This will reduce the initial\n // bundle size.\n //\n // Note: In this case, ia-button is visible immediately so it's not a great\n // example, but it demonstrates the lazy loading pattern.\n private get startButtonTemplate(): LazyLoadedTemplate {\n return lazyLoadTemplate(\n async () => {\n await import('@src/elements/ia-button/ia-button');\n },\n () => html`\n <ia-button\n @click=${() => {\n if (this.snowing) {\n this.stopSnowing();\n } else {\n this.startSnowing();\n }\n }}\n >\n ${this.snowing ? 'Stop Snowflakes' : 'Start Snowflakes'}\n </ia-button>\n `,\n );\n }\n\n private get clearButtonTemplate(): LazyLoadedTemplate {\n return lazyLoadTemplate(\n async () => {\n await import('@src/elements/ia-button/ia-button');\n },\n () => html`\n <ia-button\n @click=${() => {\n this.snowflakes?.destroy();\n }}\n >\n Clear Snowflakes\n </ia-button>\n `,\n );\n }\n\n private async startSnowing() {\n if (!this.snowflakes) {\n // lazy load dependencies when possible to reduce initial bundle size\n const SnowflakesModule = await import('magic-snowflakes');\n const Snowflakes = SnowflakesModule.default;\n this.snowflakes = new Snowflakes(this.snowConfig);\n }\n this.snowflakes?.start();\n this.snowing = true;\n }\n\n private stopSnowing() {\n this.snowflakes?.stop();\n this.snowing = false;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n img {\n width: 16px;\n filter: invert(1);\n vertical-align: middle;\n }\n `;\n }\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-styles.d.ts","sourceRoot":"","sources":["../../../src/themes/theme-styles.ts"],"names":[],"mappings":"AAEA,QAAA,MAAM,WAAW,yBA+DhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
const themeStyles = css `
|
|
3
|
+
:host {
|
|
4
|
+
/*
|
|
5
|
+
BASE STYLES
|
|
6
|
+
Default fallback values for theme styles. Assumes 16px root font size.
|
|
7
|
+
To adjust values, use theme styles below.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/* Typography */
|
|
11
|
+
--default-font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
|
|
12
|
+
|
|
13
|
+
/* Sizing */
|
|
14
|
+
--default-icon-width: 1.25rem;
|
|
15
|
+
|
|
16
|
+
/* Colors */
|
|
17
|
+
--true-white: #fff;
|
|
18
|
+
--off-white: #fbfbfd;
|
|
19
|
+
--dark-gray: #2c2c2c;
|
|
20
|
+
--light-gray: #666;
|
|
21
|
+
--classic-red: #e51c23;
|
|
22
|
+
--mint-green: #31a481;
|
|
23
|
+
--navy-blue: #194880;
|
|
24
|
+
--bright-blue: #4b64ff;
|
|
25
|
+
|
|
26
|
+
/*
|
|
27
|
+
ADJUSTABLE STYLES
|
|
28
|
+
To be adjusted by setting i.e. --ia-theme-link-color at the :root or component level.
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/* Text */
|
|
32
|
+
--base-font-family: var(
|
|
33
|
+
--ia-theme-base-font-family,
|
|
34
|
+
var(--default-font-family)
|
|
35
|
+
);
|
|
36
|
+
--primary-text-color: var(--ia-theme-primary-text-color, var(--dark-gray));
|
|
37
|
+
--secondary-text-color: var(
|
|
38
|
+
--ia-theme-secondary-text-color,
|
|
39
|
+
var(--light-gray)
|
|
40
|
+
);
|
|
41
|
+
--link-color: var(--ia-theme-link-color, var(--bright-blue));
|
|
42
|
+
|
|
43
|
+
/* Sizing */
|
|
44
|
+
--icon-width: var(--ia-theme-icon-width, var(--default-icon-width));
|
|
45
|
+
|
|
46
|
+
/* Backgrounds and fills */
|
|
47
|
+
--primary-background-color: var(
|
|
48
|
+
--ia-theme-primary-background-color,
|
|
49
|
+
var(--off-white)
|
|
50
|
+
);
|
|
51
|
+
--secondary-background-color: var(
|
|
52
|
+
--ia-theme-secondary-background-color,
|
|
53
|
+
var(--true-white)
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
/* State colors */
|
|
57
|
+
--primary-cta-fill: var(--ia-theme-primary-cta-fill, var(--navy-blue));
|
|
58
|
+
--primary-cta-text-color: var(
|
|
59
|
+
--ia-theme-primary-cta-text-color,
|
|
60
|
+
var(--true-white)
|
|
61
|
+
);
|
|
62
|
+
--color-success: var(--ia-theme-color-success, var(--mint-green));
|
|
63
|
+
--color-danger: var(--ia-theme-color-danger, var(--classic-red));
|
|
64
|
+
}
|
|
65
|
+
`;
|
|
66
|
+
export default themeStyles;
|
|
67
|
+
//# sourceMappingURL=theme-styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-styles.js","sourceRoot":"","sources":["../../../src/themes/theme-styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,WAAW,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+DtB,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import { css } from 'lit';\n\nconst themeStyles = css`\n :host {\n /*\n BASE STYLES\n Default fallback values for theme styles. Assumes 16px root font size.\n To adjust values, use theme styles below.\n */\n\n /* Typography */\n --default-font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;\n\n /* Sizing */\n --default-icon-width: 1.25rem;\n\n /* Colors */\n --true-white: #fff;\n --off-white: #fbfbfd;\n --dark-gray: #2c2c2c;\n --light-gray: #666;\n --classic-red: #e51c23;\n --mint-green: #31a481;\n --navy-blue: #194880;\n --bright-blue: #4b64ff;\n\n /*\n ADJUSTABLE STYLES\n To be adjusted by setting i.e. --ia-theme-link-color at the :root or component level.\n */\n\n /* Text */\n --base-font-family: var(\n --ia-theme-base-font-family,\n var(--default-font-family)\n );\n --primary-text-color: var(--ia-theme-primary-text-color, var(--dark-gray));\n --secondary-text-color: var(\n --ia-theme-secondary-text-color,\n var(--light-gray)\n );\n --link-color: var(--ia-theme-link-color, var(--bright-blue));\n\n /* Sizing */\n --icon-width: var(--ia-theme-icon-width, var(--default-icon-width));\n\n /* Backgrounds and fills */\n --primary-background-color: var(\n --ia-theme-primary-background-color,\n var(--off-white)\n );\n --secondary-background-color: var(\n --ia-theme-secondary-background-color,\n var(--true-white)\n );\n\n /* State colors */\n --primary-cta-fill: var(--ia-theme-primary-cta-fill, var(--navy-blue));\n --primary-cta-text-color: var(\n --ia-theme-primary-cta-text-color,\n var(--true-white)\n );\n --color-success: var(--ia-theme-color-success, var(--mint-green));\n --color-danger: var(--ia-theme-color-danger, var(--classic-red));\n }\n`;\n\nexport default themeStyles;\n"]}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { TemplateResult } from 'lit';
|
|
2
|
+
import { Directive, DirectiveParameters, DirectiveResult, Part, PartInfo } from 'lit/directive.js';
|
|
3
|
+
/**
|
|
4
|
+
* A LazyLoadedTemplate is a wrapper for a TemplateResult
|
|
5
|
+
* lazy-loaded with the `lazyLoadTemplate` function.
|
|
6
|
+
*
|
|
7
|
+
* It can be used in an html`` block, eg.
|
|
8
|
+
*
|
|
9
|
+
* html`
|
|
10
|
+
* ${this.radioPlayerTemplate} <-- see `radioPlayerTemplate` example below
|
|
11
|
+
* `
|
|
12
|
+
*/
|
|
13
|
+
export type LazyLoadedTemplate = DirectiveResult<typeof LazyLoadTemplate>;
|
|
14
|
+
/**
|
|
15
|
+
* This utility let's you asynchronously load a webcomponent.
|
|
16
|
+
*
|
|
17
|
+
* Derived from an example shown in:
|
|
18
|
+
* https://www.youtube.com/watch?v=x9YDQUJx2uw
|
|
19
|
+
*
|
|
20
|
+
* Example use:
|
|
21
|
+
*
|
|
22
|
+
* get radioPlayerTemplate(): LazyLoadedTemplate {
|
|
23
|
+
* return lazyLoadTemplate(
|
|
24
|
+
* async (): Promise<void> => {
|
|
25
|
+
* await import('./players/radio-player');
|
|
26
|
+
* },
|
|
27
|
+
* (): TemplateResult => {
|
|
28
|
+
* return html`
|
|
29
|
+
* <radio-player
|
|
30
|
+
* .metadataResponse=${this.metadataResponse}
|
|
31
|
+
* .browserHistoryHandler=${this.browserHistoryHandler}
|
|
32
|
+
* >
|
|
33
|
+
* </radio-player>
|
|
34
|
+
* `;
|
|
35
|
+
* },
|
|
36
|
+
* );
|
|
37
|
+
* }
|
|
38
|
+
*
|
|
39
|
+
* ...
|
|
40
|
+
*
|
|
41
|
+
* return html`
|
|
42
|
+
* ${this.radioPlayerTemplate}
|
|
43
|
+
* `
|
|
44
|
+
*/
|
|
45
|
+
export declare class LazyLoadTemplate extends Directive {
|
|
46
|
+
constructor(partInfo: PartInfo);
|
|
47
|
+
update(part: Part, [importPromise, value]: DirectiveParameters<this>): TemplateResult;
|
|
48
|
+
render(_importPromise: () => Promise<void>, value: () => TemplateResult): TemplateResult;
|
|
49
|
+
}
|
|
50
|
+
export declare const lazyLoadTemplate: (_importPromise: () => Promise<void>, value: () => TemplateResult) => DirectiveResult<typeof LazyLoadTemplate>;
|
|
51
|
+
//# sourceMappingURL=lazy-load-template.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-load-template.d.ts","sourceRoot":"","sources":["../../../src/util/lazy-load-template.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAC1C,OAAO,EACL,SAAS,EAET,mBAAmB,EACnB,eAAe,EACf,IAAI,EACJ,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAI1B;;;;;;;;;GASG;AACH,MAAM,MAAM,kBAAkB,GAAG,eAAe,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE1E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,qBAAa,gBAAiB,SAAQ,SAAS;gBACjC,QAAQ,EAAE,QAAQ;IAI9B,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,aAAa,EAAE,KAAK,CAAC,EAAE,mBAAmB,CAAC,IAAI,CAAC;IAQpE,MAAM,CAAC,cAAc,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,MAAM,cAAc;CAGxE;AAED,eAAO,MAAM,gBAAgB,yBALE,OAAO,CAAC,IAAI,CAAC,eAAe,cAAc,6CAKd,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Directive, directive, } from 'lit/directive.js';
|
|
2
|
+
const resolved = new WeakSet();
|
|
3
|
+
/**
|
|
4
|
+
* This utility let's you asynchronously load a webcomponent.
|
|
5
|
+
*
|
|
6
|
+
* Derived from an example shown in:
|
|
7
|
+
* https://www.youtube.com/watch?v=x9YDQUJx2uw
|
|
8
|
+
*
|
|
9
|
+
* Example use:
|
|
10
|
+
*
|
|
11
|
+
* get radioPlayerTemplate(): LazyLoadedTemplate {
|
|
12
|
+
* return lazyLoadTemplate(
|
|
13
|
+
* async (): Promise<void> => {
|
|
14
|
+
* await import('./players/radio-player');
|
|
15
|
+
* },
|
|
16
|
+
* (): TemplateResult => {
|
|
17
|
+
* return html`
|
|
18
|
+
* <radio-player
|
|
19
|
+
* .metadataResponse=${this.metadataResponse}
|
|
20
|
+
* .browserHistoryHandler=${this.browserHistoryHandler}
|
|
21
|
+
* >
|
|
22
|
+
* </radio-player>
|
|
23
|
+
* `;
|
|
24
|
+
* },
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* ...
|
|
29
|
+
*
|
|
30
|
+
* return html`
|
|
31
|
+
* ${this.radioPlayerTemplate}
|
|
32
|
+
* `
|
|
33
|
+
*/
|
|
34
|
+
export class LazyLoadTemplate extends Directive {
|
|
35
|
+
constructor(partInfo) {
|
|
36
|
+
super(partInfo);
|
|
37
|
+
}
|
|
38
|
+
update(part, [importPromise, value]) {
|
|
39
|
+
if (!resolved.has(part)) {
|
|
40
|
+
importPromise();
|
|
41
|
+
resolved.add(part);
|
|
42
|
+
}
|
|
43
|
+
return this.render(importPromise, value);
|
|
44
|
+
}
|
|
45
|
+
render(_importPromise, value) {
|
|
46
|
+
return value();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
export const lazyLoadTemplate = directive(LazyLoadTemplate);
|
|
50
|
+
//# sourceMappingURL=lazy-load-template.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lazy-load-template.js","sourceRoot":"","sources":["../../../src/util/lazy-load-template.ts"],"names":[],"mappings":"AACA,OAAO,EACL,SAAS,EACT,SAAS,GAKV,MAAM,kBAAkB,CAAC;AAE1B,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAE,CAAC;AAc/B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,MAAM,OAAO,gBAAiB,SAAQ,SAAS;IAC7C,YAAY,QAAkB;QAC5B,KAAK,CAAC,QAAQ,CAAC,CAAC;IAClB,CAAC;IAED,MAAM,CAAC,IAAU,EAAE,CAAC,aAAa,EAAE,KAAK,CAA4B;QAClE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YACxB,aAAa,EAAE,CAAC;YAChB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,aAAa,EAAE,KAAK,CAAC,CAAC;IAC3C,CAAC;IAED,MAAM,CAAC,cAAmC,EAAE,KAA2B;QACrE,OAAO,KAAK,EAAE,CAAC;IACjB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,SAAS,CAAC,gBAAgB,CAAC,CAAC","sourcesContent":["import type { TemplateResult } from 'lit';\nimport {\n Directive,\n directive,\n DirectiveParameters,\n DirectiveResult,\n Part,\n PartInfo,\n} from 'lit/directive.js';\n\nconst resolved = new WeakSet();\n\n/**\n * A LazyLoadedTemplate is a wrapper for a TemplateResult\n * lazy-loaded with the `lazyLoadTemplate` function.\n *\n * It can be used in an html`` block, eg.\n *\n * html`\n * ${this.radioPlayerTemplate} <-- see `radioPlayerTemplate` example below\n * `\n */\nexport type LazyLoadedTemplate = DirectiveResult<typeof LazyLoadTemplate>;\n\n/**\n * This utility let's you asynchronously load a webcomponent.\n *\n * Derived from an example shown in:\n * https://www.youtube.com/watch?v=x9YDQUJx2uw\n *\n * Example use:\n *\n * get radioPlayerTemplate(): LazyLoadedTemplate {\n * return lazyLoadTemplate(\n * async (): Promise<void> => {\n * await import('./players/radio-player');\n * },\n * (): TemplateResult => {\n * return html`\n * <radio-player\n * .metadataResponse=${this.metadataResponse}\n * .browserHistoryHandler=${this.browserHistoryHandler}\n * >\n * </radio-player>\n * `;\n * },\n * );\n * }\n *\n * ...\n *\n * return html`\n * ${this.radioPlayerTemplate}\n * `\n */\nexport class LazyLoadTemplate extends Directive {\n constructor(partInfo: PartInfo) {\n super(partInfo);\n }\n\n update(part: Part, [importPromise, value]: DirectiveParameters<this>) {\n if (!resolved.has(part)) {\n importPromise();\n resolved.add(part);\n }\n return this.render(importPromise, value);\n }\n\n render(_importPromise: () => Promise<void>, value: () => TemplateResult) {\n return value();\n }\n}\n\nexport const lazyLoadTemplate = directive(LazyLoadTemplate);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@internetarchive/elements",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A web component library from the Internet Archive.",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"types": "./dist/src/elements/index.d.ts",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"test": "wireit"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
+
"@lit/localize": "^0.12.2",
|
|
29
30
|
"lit": "^3.3.1",
|
|
30
31
|
"magic-snowflakes": "^7.0.2",
|
|
31
32
|
"tslib": "^2.8.1"
|