@studious-creative/yumekit 0.1.9 → 0.1.10
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/components/y-avatar.js +31 -3
- package/dist/components/y-card.js +9 -0
- package/dist/components/y-dialog.js +16 -0
- package/dist/components/y-progress.d.ts +0 -1
- package/dist/components/y-progress.js +28 -15
- package/dist/components/y-theme.js +6 -1
- package/dist/components/y-toast.d.ts +0 -1
- package/dist/components/y-toast.js +25 -93
- package/dist/components/y-tooltip.d.ts +0 -1
- package/dist/components/y-tooltip.js +25 -93
- package/dist/icons/all.js +69 -0
- package/dist/index.js +153 -156
- package/dist/modules/helpers.d.ts +9 -0
- package/dist/modules/helpers.js +26 -0
- package/dist/yumekit.min.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a [background, foreground] CSS variable pair for a color scheme.
|
|
3
|
+
* Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
|
|
4
|
+
* @param {string} color — one of base, primary, secondary, success, warning, error, help
|
|
5
|
+
* @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
|
|
6
|
+
* Use `null` to pass the raw `color` string through as the background instead.
|
|
7
|
+
* @returns {[string, string]} — [bg var, fg var]
|
|
8
|
+
*/
|
|
9
|
+
function getColorVarPair(color, fallbackColor = "base") {
|
|
10
|
+
const map = {
|
|
11
|
+
base: ["var(--base-content--)", "var(--base-content-inverse)"],
|
|
12
|
+
primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
|
|
13
|
+
secondary: [
|
|
14
|
+
"var(--secondary-content--)",
|
|
15
|
+
"var(--secondary-content-inverse)",
|
|
16
|
+
],
|
|
17
|
+
success: ["var(--success-content--)", "var(--success-content-inverse)"],
|
|
18
|
+
warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
|
|
19
|
+
error: ["var(--error-content--)", "var(--error-content-inverse)"],
|
|
20
|
+
help: ["var(--help-content--)", "var(--help-content-inverse)"],
|
|
21
|
+
};
|
|
22
|
+
if (map[color]) return map[color];
|
|
23
|
+
if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
|
|
24
|
+
return map[fallbackColor] || map.base;
|
|
25
|
+
}
|
|
26
|
+
|
|
1
27
|
class YumeAvatar extends HTMLElement {
|
|
2
28
|
static get observedAttributes() {
|
|
3
|
-
return ["src", "alt", "size", "shape"];
|
|
29
|
+
return ["src", "alt", "size", "shape", "color"];
|
|
4
30
|
}
|
|
5
31
|
|
|
6
32
|
constructor() {
|
|
@@ -19,7 +45,9 @@ class YumeAvatar extends HTMLElement {
|
|
|
19
45
|
const src = this.getAttribute("src");
|
|
20
46
|
const altRaw = this.getAttribute("alt") || "AN";
|
|
21
47
|
const shape = this.getAttribute("shape") || "circle";
|
|
48
|
+
const color = this.getAttribute("color") || "primary";
|
|
22
49
|
const borderRadius = `var(--component-avatar-border-radius-${shape}, 9999px)`;
|
|
50
|
+
const [bgColor, textColor] = getColorVarPair(color);
|
|
23
51
|
|
|
24
52
|
let dimensions;
|
|
25
53
|
const size = this.getAttribute("size") || "medium";
|
|
@@ -68,8 +96,8 @@ class YumeAvatar extends HTMLElement {
|
|
|
68
96
|
width: 100%;
|
|
69
97
|
height: 100%;
|
|
70
98
|
border-radius: ${borderRadius};
|
|
71
|
-
background-color:
|
|
72
|
-
color:
|
|
99
|
+
background-color: ${bgColor};
|
|
100
|
+
color: ${textColor};
|
|
73
101
|
display: flex;
|
|
74
102
|
align-items: center;
|
|
75
103
|
justify-content: center;
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a [background, foreground] CSS variable pair for a color scheme.
|
|
3
|
+
* Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
|
|
4
|
+
* @param {string} color — one of base, primary, secondary, success, warning, error, help
|
|
5
|
+
* @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
|
|
6
|
+
* Use `null` to pass the raw `color` string through as the background instead.
|
|
7
|
+
* @returns {[string, string]} — [bg var, fg var]
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
// helpers/slot-utils.js
|
|
2
11
|
function hideEmptySlotContainers(shadowRoot, slotsConfig = {}) {
|
|
3
12
|
Object.entries(slotsConfig).forEach(([slotName, containerSelector]) => {
|
|
@@ -208,6 +208,22 @@ class YumeDialog extends HTMLElement {
|
|
|
208
208
|
dialog.appendChild(body);
|
|
209
209
|
dialog.appendChild(footer);
|
|
210
210
|
this.shadowRoot.appendChild(dialog);
|
|
211
|
+
|
|
212
|
+
// Hide slot containers that have no slotted content
|
|
213
|
+
const hideIfEmpty = (wrapper) => {
|
|
214
|
+
const slot = wrapper.querySelector("slot");
|
|
215
|
+
if (!slot) return;
|
|
216
|
+
const update = () => {
|
|
217
|
+
const hasContent =
|
|
218
|
+
slot.assignedNodes({ flatten: true }).length > 0;
|
|
219
|
+
wrapper.style.display = hasContent ? "" : "none";
|
|
220
|
+
};
|
|
221
|
+
slot.addEventListener("slotchange", update);
|
|
222
|
+
update();
|
|
223
|
+
};
|
|
224
|
+
if (!this.closable) hideIfEmpty(header);
|
|
225
|
+
hideIfEmpty(body);
|
|
226
|
+
hideIfEmpty(footer);
|
|
211
227
|
}
|
|
212
228
|
}
|
|
213
229
|
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Return a [background, foreground] CSS variable pair for a color scheme.
|
|
3
|
+
* Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
|
|
4
|
+
* @param {string} color — one of base, primary, secondary, success, warning, error, help
|
|
5
|
+
* @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
|
|
6
|
+
* Use `null` to pass the raw `color` string through as the background instead.
|
|
7
|
+
* @returns {[string, string]} — [bg var, fg var]
|
|
8
|
+
*/
|
|
9
|
+
function getColorVarPair(color, fallbackColor = "base") {
|
|
10
|
+
const map = {
|
|
11
|
+
base: ["var(--base-content--)", "var(--base-content-inverse)"],
|
|
12
|
+
primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
|
|
13
|
+
secondary: [
|
|
14
|
+
"var(--secondary-content--)",
|
|
15
|
+
"var(--secondary-content-inverse)",
|
|
16
|
+
],
|
|
17
|
+
success: ["var(--success-content--)", "var(--success-content-inverse)"],
|
|
18
|
+
warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
|
|
19
|
+
error: ["var(--error-content--)", "var(--error-content-inverse)"],
|
|
20
|
+
help: ["var(--help-content--)", "var(--help-content-inverse)"],
|
|
21
|
+
};
|
|
22
|
+
if (map[color]) return map[color];
|
|
23
|
+
if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
|
|
24
|
+
return map[fallbackColor] || map.base;
|
|
25
|
+
}
|
|
26
|
+
|
|
1
27
|
class YumeProgress extends HTMLElement {
|
|
2
28
|
static get observedAttributes() {
|
|
3
29
|
return [
|
|
@@ -154,19 +180,6 @@ class YumeProgress extends HTMLElement {
|
|
|
154
180
|
return Math.max(0, Math.min(100, pct));
|
|
155
181
|
}
|
|
156
182
|
|
|
157
|
-
getBarColor(color) {
|
|
158
|
-
const colorMap = {
|
|
159
|
-
primary: "var(--primary-content--)",
|
|
160
|
-
secondary: "var(--secondary-content--)",
|
|
161
|
-
base: "var(--base-content--)",
|
|
162
|
-
success: "var(--success-content--)",
|
|
163
|
-
warning: "var(--warning-content--)",
|
|
164
|
-
error: "var(--error-content--)",
|
|
165
|
-
help: "var(--help-content--)",
|
|
166
|
-
};
|
|
167
|
-
return colorMap[color] || color;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
183
|
getSizeVar(size) {
|
|
171
184
|
const map = {
|
|
172
185
|
small: "var(--component-progress-size-small)",
|
|
@@ -194,7 +207,7 @@ class YumeProgress extends HTMLElement {
|
|
|
194
207
|
render() {
|
|
195
208
|
const isIndeterminate = this.indeterminate;
|
|
196
209
|
const pct = this.percentage;
|
|
197
|
-
const barColor =
|
|
210
|
+
const [barColor, barTextColor] = getColorVarPair(this.color, null);
|
|
198
211
|
const sizeVar = this.getSizeVar(this.size);
|
|
199
212
|
const isDisabled = this.disabled;
|
|
200
213
|
const showLabel = this.labelDisplay && !isIndeterminate;
|
|
@@ -272,7 +285,7 @@ class YumeProgress extends HTMLElement {
|
|
|
272
285
|
}
|
|
273
286
|
|
|
274
287
|
.value-label--bar {
|
|
275
|
-
color:
|
|
288
|
+
color: ${barTextColor};
|
|
276
289
|
width: calc(100% / (${pct || 1} / 100));
|
|
277
290
|
}
|
|
278
291
|
|
|
@@ -56,7 +56,12 @@ class YumeTheme extends HTMLElement {
|
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
this.shadowRoot.innerHTML = `
|
|
59
|
-
<style
|
|
59
|
+
<style>
|
|
60
|
+
${variablesCSS}
|
|
61
|
+
:host {
|
|
62
|
+
font-family: var(--font-family-body, sans-serif);
|
|
63
|
+
}
|
|
64
|
+
</style>
|
|
60
65
|
${themeCSS ? `<style>${themeCSS}</style>` : ""}
|
|
61
66
|
<slot></slot>
|
|
62
67
|
`;
|
|
@@ -1,79 +1,27 @@
|
|
|
1
|
-
// helpers/slot-utils.js
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Resolve a CSS custom-property value to a concrete color string.
|
|
5
|
-
* Reads from the given element's computed style.
|
|
6
|
-
* @param {string} varExpr — e.g. "var(--primary-content--)"
|
|
7
|
-
* @param {HTMLElement} el — element to resolve against
|
|
8
|
-
* @returns {string} — resolved color or fallback
|
|
9
|
-
*/
|
|
10
|
-
function resolveCSSColor(varExpr, el) {
|
|
11
|
-
const match = varExpr.match(/var\(\s*(--[^,)]+)/);
|
|
12
|
-
if (!match) return varExpr;
|
|
13
|
-
const val = getComputedStyle(el).getPropertyValue(match[1]).trim();
|
|
14
|
-
return val || varExpr;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Parse a CSS color string (#hex, rgb(), etc.) to {r, g, b}.
|
|
19
|
-
* Returns null if it can't parse.
|
|
20
|
-
*/
|
|
21
|
-
function parseColor(colorStr) {
|
|
22
|
-
// #RGB, #RRGGBB, #RRGGBBAA
|
|
23
|
-
const hexMatch = colorStr.match(
|
|
24
|
-
/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,
|
|
25
|
-
);
|
|
26
|
-
if (hexMatch) {
|
|
27
|
-
let hex = hexMatch[1];
|
|
28
|
-
if (hex.length <= 4) {
|
|
29
|
-
hex = hex
|
|
30
|
-
.split("")
|
|
31
|
-
.map((c) => c + c)
|
|
32
|
-
.join("");
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
r: parseInt(hex.slice(0, 2), 16),
|
|
36
|
-
g: parseInt(hex.slice(2, 4), 16),
|
|
37
|
-
b: parseInt(hex.slice(4, 6), 16),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
// rgb(r, g, b) or rgba(r, g, b, a)
|
|
41
|
-
const rgbMatch = colorStr.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
42
|
-
if (rgbMatch) {
|
|
43
|
-
return {
|
|
44
|
-
r: parseInt(rgbMatch[1], 10),
|
|
45
|
-
g: parseInt(rgbMatch[2], 10),
|
|
46
|
-
b: parseInt(rgbMatch[3], 10),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
1
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
2
|
+
* Return a [background, foreground] CSS variable pair for a color scheme.
|
|
3
|
+
* Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
|
|
4
|
+
* @param {string} color — one of base, primary, secondary, success, warning, error, help
|
|
5
|
+
* @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
|
|
6
|
+
* Use `null` to pass the raw `color` string through as the background instead.
|
|
7
|
+
* @returns {[string, string]} — [bg var, fg var]
|
|
55
8
|
*/
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const parsed = parseColor(bgColor);
|
|
73
|
-
if (!parsed) return "var(--neutral-white, #ffffff)";
|
|
74
|
-
return luminance(parsed) > 0.179
|
|
75
|
-
? "var(--neutral-black, #000000)"
|
|
76
|
-
: "var(--neutral-white, #ffffff)";
|
|
9
|
+
function getColorVarPair(color, fallbackColor = "base") {
|
|
10
|
+
const map = {
|
|
11
|
+
base: ["var(--base-content--)", "var(--base-content-inverse)"],
|
|
12
|
+
primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
|
|
13
|
+
secondary: [
|
|
14
|
+
"var(--secondary-content--)",
|
|
15
|
+
"var(--secondary-content-inverse)",
|
|
16
|
+
],
|
|
17
|
+
success: ["var(--success-content--)", "var(--success-content-inverse)"],
|
|
18
|
+
warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
|
|
19
|
+
error: ["var(--error-content--)", "var(--error-content-inverse)"],
|
|
20
|
+
help: ["var(--help-content--)", "var(--help-content-inverse)"],
|
|
21
|
+
};
|
|
22
|
+
if (map[color]) return map[color];
|
|
23
|
+
if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
|
|
24
|
+
return map[fallbackColor] || map.base;
|
|
77
25
|
}
|
|
78
26
|
|
|
79
27
|
class YumeToast extends HTMLElement {
|
|
@@ -150,11 +98,9 @@ class YumeToast extends HTMLElement {
|
|
|
150
98
|
toast.setAttribute("aria-live", "assertive");
|
|
151
99
|
toast.setAttribute("part", "toast");
|
|
152
100
|
|
|
153
|
-
const
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
toast.style.backgroundColor = bgVar;
|
|
157
|
-
toast.style.color = textColor;
|
|
101
|
+
const [bg, fg] = getColorVarPair(color);
|
|
102
|
+
toast.style.backgroundColor = bg;
|
|
103
|
+
toast.style.color = fg;
|
|
158
104
|
|
|
159
105
|
if (icon) {
|
|
160
106
|
const iconEl = document.createElement("y-icon");
|
|
@@ -253,20 +199,6 @@ class YumeToast extends HTMLElement {
|
|
|
253
199
|
return map[pos] || map["bottom-right"];
|
|
254
200
|
}
|
|
255
201
|
|
|
256
|
-
// "base" inverts the page: light content on dark, dark on light.
|
|
257
|
-
_getColorBg(color) {
|
|
258
|
-
const map = {
|
|
259
|
-
base: "var(--base-content--, #fff)",
|
|
260
|
-
primary: "var(--primary-content--, #0070f3)",
|
|
261
|
-
secondary: "var(--secondary-content--, #6c757d)",
|
|
262
|
-
success: "var(--success-content--, #28a745)",
|
|
263
|
-
warning: "var(--warning-content--, #ffc107)",
|
|
264
|
-
error: "var(--error-content--, #dc3545)",
|
|
265
|
-
help: "var(--help-content--, #6f42c1)",
|
|
266
|
-
};
|
|
267
|
-
return map[color] || map.base;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
202
|
render() {
|
|
271
203
|
this.shadowRoot.innerHTML = `
|
|
272
204
|
<style>
|
|
@@ -1,79 +1,27 @@
|
|
|
1
|
-
// helpers/slot-utils.js
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Resolve a CSS custom-property value to a concrete color string.
|
|
5
|
-
* Reads from the given element's computed style.
|
|
6
|
-
* @param {string} varExpr — e.g. "var(--primary-content--)"
|
|
7
|
-
* @param {HTMLElement} el — element to resolve against
|
|
8
|
-
* @returns {string} — resolved color or fallback
|
|
9
|
-
*/
|
|
10
|
-
function resolveCSSColor(varExpr, el) {
|
|
11
|
-
const match = varExpr.match(/var\(\s*(--[^,)]+)/);
|
|
12
|
-
if (!match) return varExpr;
|
|
13
|
-
const val = getComputedStyle(el).getPropertyValue(match[1]).trim();
|
|
14
|
-
return val || varExpr;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Parse a CSS color string (#hex, rgb(), etc.) to {r, g, b}.
|
|
19
|
-
* Returns null if it can't parse.
|
|
20
|
-
*/
|
|
21
|
-
function parseColor(colorStr) {
|
|
22
|
-
// #RGB, #RRGGBB, #RRGGBBAA
|
|
23
|
-
const hexMatch = colorStr.match(
|
|
24
|
-
/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,
|
|
25
|
-
);
|
|
26
|
-
if (hexMatch) {
|
|
27
|
-
let hex = hexMatch[1];
|
|
28
|
-
if (hex.length <= 4) {
|
|
29
|
-
hex = hex
|
|
30
|
-
.split("")
|
|
31
|
-
.map((c) => c + c)
|
|
32
|
-
.join("");
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
r: parseInt(hex.slice(0, 2), 16),
|
|
36
|
-
g: parseInt(hex.slice(2, 4), 16),
|
|
37
|
-
b: parseInt(hex.slice(4, 6), 16),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
// rgb(r, g, b) or rgba(r, g, b, a)
|
|
41
|
-
const rgbMatch = colorStr.match(/rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/);
|
|
42
|
-
if (rgbMatch) {
|
|
43
|
-
return {
|
|
44
|
-
r: parseInt(rgbMatch[1], 10),
|
|
45
|
-
g: parseInt(rgbMatch[2], 10),
|
|
46
|
-
b: parseInt(rgbMatch[3], 10),
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
1
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
2
|
+
* Return a [background, foreground] CSS variable pair for a color scheme.
|
|
3
|
+
* Background is `--{color}-content--`, foreground is `--{color}-content-inverse`.
|
|
4
|
+
* @param {string} color — one of base, primary, secondary, success, warning, error, help
|
|
5
|
+
* @param {string} [fallbackColor="base"] — color to fall back to when `color` is unrecognised.
|
|
6
|
+
* Use `null` to pass the raw `color` string through as the background instead.
|
|
7
|
+
* @returns {[string, string]} — [bg var, fg var]
|
|
55
8
|
*/
|
|
56
|
-
function
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const parsed = parseColor(bgColor);
|
|
73
|
-
if (!parsed) return "var(--neutral-white, #ffffff)";
|
|
74
|
-
return luminance(parsed) > 0.179
|
|
75
|
-
? "var(--neutral-black, #000000)"
|
|
76
|
-
: "var(--neutral-white, #ffffff)";
|
|
9
|
+
function getColorVarPair(color, fallbackColor = "base") {
|
|
10
|
+
const map = {
|
|
11
|
+
base: ["var(--base-content--)", "var(--base-content-inverse)"],
|
|
12
|
+
primary: ["var(--primary-content--)", "var(--primary-content-inverse)"],
|
|
13
|
+
secondary: [
|
|
14
|
+
"var(--secondary-content--)",
|
|
15
|
+
"var(--secondary-content-inverse)",
|
|
16
|
+
],
|
|
17
|
+
success: ["var(--success-content--)", "var(--success-content-inverse)"],
|
|
18
|
+
warning: ["var(--warning-content--)", "var(--warning-content-inverse)"],
|
|
19
|
+
error: ["var(--error-content--)", "var(--error-content-inverse)"],
|
|
20
|
+
help: ["var(--help-content--)", "var(--help-content-inverse)"],
|
|
21
|
+
};
|
|
22
|
+
if (map[color]) return map[color];
|
|
23
|
+
if (fallbackColor === null) return [color, "var(--base-content-inverse)"];
|
|
24
|
+
return map[fallbackColor] || map.base;
|
|
77
25
|
}
|
|
78
26
|
|
|
79
27
|
class YumeTooltip extends HTMLElement {
|
|
@@ -152,9 +100,8 @@ class YumeTooltip extends HTMLElement {
|
|
|
152
100
|
this._visible = true;
|
|
153
101
|
const tip = this.shadowRoot.querySelector(".tooltip");
|
|
154
102
|
if (tip) {
|
|
155
|
-
const
|
|
156
|
-
|
|
157
|
-
tip.style.color = contrastTextColor(resolvedBg);
|
|
103
|
+
const [, fg] = getColorVarPair(this.color);
|
|
104
|
+
tip.style.color = fg;
|
|
158
105
|
tip.classList.add("visible");
|
|
159
106
|
}
|
|
160
107
|
}, this.delay);
|
|
@@ -185,24 +132,9 @@ class YumeTooltip extends HTMLElement {
|
|
|
185
132
|
}
|
|
186
133
|
}
|
|
187
134
|
|
|
188
|
-
_getBg() {
|
|
189
|
-
const map = {
|
|
190
|
-
base: "var(--base-content--, #555)",
|
|
191
|
-
primary: "var(--primary-content--, #0070f3)",
|
|
192
|
-
secondary: "var(--secondary-content--, #6c757d)",
|
|
193
|
-
success: "var(--success-content--, #28a745)",
|
|
194
|
-
warning: "var(--warning-content--, #ffc107)",
|
|
195
|
-
error: "var(--error-content--, #dc3545)",
|
|
196
|
-
help: "var(--help-content--, #6f42c1)",
|
|
197
|
-
};
|
|
198
|
-
return map[this.color] || map.base;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
135
|
render() {
|
|
202
136
|
const pos = this.position;
|
|
203
|
-
const bg = this.
|
|
204
|
-
const resolvedBg = resolveCSSColor(bg, this);
|
|
205
|
-
const fg = contrastTextColor(resolvedBg);
|
|
137
|
+
const [bg, fg] = getColorVarPair(this.color);
|
|
206
138
|
|
|
207
139
|
this.shadowRoot.innerHTML = `
|
|
208
140
|
<style>
|
package/dist/icons/all.js
CHANGED
|
@@ -49,6 +49,52 @@ var collapseLeft = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 2
|
|
|
49
49
|
|
|
50
50
|
var comments = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z\"/>\n</svg>\n";
|
|
51
51
|
|
|
52
|
+
var compAppbar = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"3\" width=\"20\" height=\"5\" rx=\"1.5\"/>\n <line x1=\"4\" y1=\"13\" x2=\"20\" y2=\"13\"/>\n <line x1=\"4\" y1=\"17\" x2=\"15\" y2=\"17\"/>\n <line x1=\"4\" y1=\"21\" x2=\"10\" y2=\"21\"/>\n</svg>\n";
|
|
53
|
+
|
|
54
|
+
var compAvatar = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"/>\n <circle cx=\"12\" cy=\"10\" r=\"3\"/>\n <path d=\"M6 20.5c0-3 2.7-5.5 6-5.5s6 2.5 6 5.5\"/>\n</svg>\n";
|
|
55
|
+
|
|
56
|
+
var compBadge = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"6\" width=\"16\" height=\"16\" rx=\"2\"/>\n <circle cx=\"20\" cy=\"5\" r=\"3.5\"/>\n</svg>\n";
|
|
57
|
+
|
|
58
|
+
var compButton = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"7\" width=\"20\" height=\"10\" rx=\"3\"/>\n <line x1=\"8\" y1=\"12\" x2=\"16\" y2=\"12\"/>\n</svg>\n";
|
|
59
|
+
|
|
60
|
+
var compCard = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"2\" width=\"18\" height=\"20\" rx=\"2\"/>\n <line x1=\"3\" y1=\"8\" x2=\"21\" y2=\"8\"/>\n <line x1=\"7\" y1=\"12\" x2=\"17\" y2=\"12\"/>\n <line x1=\"7\" y1=\"16\" x2=\"13\" y2=\"16\"/>\n</svg>\n";
|
|
61
|
+
|
|
62
|
+
var compCheckbox = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"3\"/>\n <polyline points=\"7 12.5 10.5 16 17 8\"/>\n</svg>\n";
|
|
63
|
+
|
|
64
|
+
var compDialog = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"5\" width=\"18\" height=\"14\" rx=\"2\"/>\n <line x1=\"7\" y1=\"9\" x2=\"17\" y2=\"9\"/>\n <line x1=\"7\" y1=\"13\" x2=\"13\" y2=\"13\"/>\n</svg>\n";
|
|
65
|
+
|
|
66
|
+
var compDrawer = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"3\" width=\"20\" height=\"18\" rx=\"2\"/>\n <line x1=\"9\" y1=\"3\" x2=\"9\" y2=\"21\"/>\n <line x1=\"4\" y1=\"8\" x2=\"7\" y2=\"8\"/>\n <line x1=\"4\" y1=\"12\" x2=\"7\" y2=\"12\"/>\n</svg>\n";
|
|
67
|
+
|
|
68
|
+
var compIcon = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M12 2c0 5.52-4.48 10-10 10 5.52 0 10 4.48 10 10 0-5.52 4.48-10 10-10-5.52 0-10-4.48-10-10z\"/>\n</svg>\n";
|
|
69
|
+
|
|
70
|
+
var compInput = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"6\" width=\"20\" height=\"12\" rx=\"2\"/>\n <line x1=\"6\" y1=\"10\" x2=\"6\" y2=\"14\"/>\n</svg>\n";
|
|
71
|
+
|
|
72
|
+
var compMenu = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"2\" width=\"18\" height=\"20\" rx=\"2\"/>\n <line x1=\"7\" y1=\"7\" x2=\"17\" y2=\"7\"/>\n <line x1=\"7\" y1=\"12\" x2=\"17\" y2=\"12\"/>\n <line x1=\"7\" y1=\"17\" x2=\"17\" y2=\"17\"/>\n</svg>\n";
|
|
73
|
+
|
|
74
|
+
var compPanelbar = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"2\" width=\"20\" height=\"20\" rx=\"2\"/>\n <line x1=\"2\" y1=\"9\" x2=\"22\" y2=\"9\"/>\n <line x1=\"2\" y1=\"16\" x2=\"22\" y2=\"16\"/>\n</svg>\n";
|
|
75
|
+
|
|
76
|
+
var compProgress = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"8\" width=\"20\" height=\"8\" rx=\"4\"/>\n <line x1=\"6\" y1=\"12\" x2=\"13\" y2=\"12\" stroke-width=\"3\" stroke-linecap=\"round\"/>\n</svg>\n";
|
|
77
|
+
|
|
78
|
+
var compRadio = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"/>\n <circle cx=\"12\" cy=\"12\" r=\"4\" fill=\"currentColor\" stroke=\"none\"/>\n</svg>\n";
|
|
79
|
+
|
|
80
|
+
var compSelect = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"7\" width=\"20\" height=\"10\" rx=\"2\"/>\n <line x1=\"6\" y1=\"12\" x2=\"13\" y2=\"12\"/>\n <polyline points=\"16 10 18 13 20 10\"/>\n</svg>\n";
|
|
81
|
+
|
|
82
|
+
var compSlider = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <line x1=\"2\" y1=\"12\" x2=\"22\" y2=\"12\"/>\n <circle cx=\"15\" cy=\"12\" r=\"4\"/>\n</svg>\n";
|
|
83
|
+
|
|
84
|
+
var compSwitch = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"6\" width=\"20\" height=\"12\" rx=\"6\"/>\n <circle cx=\"16\" cy=\"12\" r=\"4\"/>\n</svg>\n";
|
|
85
|
+
|
|
86
|
+
var compTable = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"3\" width=\"20\" height=\"18\" rx=\"2\"/>\n <line x1=\"2\" y1=\"9\" x2=\"22\" y2=\"9\"/>\n <line x1=\"2\" y1=\"15\" x2=\"22\" y2=\"15\"/>\n <line x1=\"10\" y1=\"3\" x2=\"10\" y2=\"21\"/>\n</svg>\n";
|
|
87
|
+
|
|
88
|
+
var compTabs = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"9\" width=\"20\" height=\"12\" rx=\"2\"/>\n <path d=\"M5 9V6a1.5 1.5 0 0 1 1.5-1.5h5A1.5 1.5 0 0 1 13 6v3\"/>\n <line x1=\"16\" y1=\"6\" x2=\"20\" y2=\"6\"/>\n</svg>\n";
|
|
89
|
+
|
|
90
|
+
var compTag = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"2\" y=\"7\" width=\"20\" height=\"10\" rx=\"5\"/>\n <line x1=\"15\" y1=\"10\" x2=\"17\" y2=\"14\"/>\n <line x1=\"17\" y1=\"10\" x2=\"15\" y2=\"14\"/>\n</svg>\n";
|
|
91
|
+
|
|
92
|
+
var compTheme = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"/>\n <path d=\"M12 2a10 10 0 0 1 0 20z\" fill=\"currentColor\"/>\n</svg>\n";
|
|
93
|
+
|
|
94
|
+
var compToast = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"7\" width=\"18\" height=\"10\" rx=\"2\"/>\n <circle cx=\"8\" cy=\"12\" r=\"2\"/>\n <line x1=\"12\" y1=\"12\" x2=\"18\" y2=\"12\"/>\n</svg>\n";
|
|
95
|
+
|
|
96
|
+
var compTooltip = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <path d=\"M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5l-2 4-2-4H5a2 2 0 0 1-2-2z\"/>\n</svg>\n";
|
|
97
|
+
|
|
52
98
|
var compass = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <circle cx=\"12\" cy=\"12\" r=\"10\"/>\n <polygon points=\"16.24 7.76 14.12 14.12 7.76 16.24 9.88 9.88 16.24 7.76\"/>\n</svg>\n";
|
|
53
99
|
|
|
54
100
|
var diagram = "<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\">\n <rect x=\"3\" y=\"3\" width=\"6\" height=\"6\" rx=\"1\"/>\n <rect x=\"15\" y=\"3\" width=\"6\" height=\"6\" rx=\"1\"/>\n <rect x=\"9\" y=\"15\" width=\"6\" height=\"6\" rx=\"1\"/>\n <line x1=\"6\" y1=\"9\" x2=\"6\" y2=\"15\"/>\n <line x1=\"6\" y1=\"15\" x2=\"9\" y2=\"15\"/>\n <line x1=\"18\" y1=\"9\" x2=\"18\" y2=\"15\"/>\n <line x1=\"18\" y1=\"15\" x2=\"15\" y2=\"15\"/>\n</svg>\n";
|
|
@@ -128,6 +174,29 @@ registerIcons({
|
|
|
128
174
|
close,
|
|
129
175
|
"collapse-left": collapseLeft,
|
|
130
176
|
comments,
|
|
177
|
+
"comp-appbar": compAppbar,
|
|
178
|
+
"comp-avatar": compAvatar,
|
|
179
|
+
"comp-badge": compBadge,
|
|
180
|
+
"comp-button": compButton,
|
|
181
|
+
"comp-card": compCard,
|
|
182
|
+
"comp-checkbox": compCheckbox,
|
|
183
|
+
"comp-dialog": compDialog,
|
|
184
|
+
"comp-drawer": compDrawer,
|
|
185
|
+
"comp-icon": compIcon,
|
|
186
|
+
"comp-input": compInput,
|
|
187
|
+
"comp-menu": compMenu,
|
|
188
|
+
"comp-panelbar": compPanelbar,
|
|
189
|
+
"comp-progress": compProgress,
|
|
190
|
+
"comp-radio": compRadio,
|
|
191
|
+
"comp-select": compSelect,
|
|
192
|
+
"comp-slider": compSlider,
|
|
193
|
+
"comp-switch": compSwitch,
|
|
194
|
+
"comp-table": compTable,
|
|
195
|
+
"comp-tabs": compTabs,
|
|
196
|
+
"comp-tag": compTag,
|
|
197
|
+
"comp-theme": compTheme,
|
|
198
|
+
"comp-toast": compToast,
|
|
199
|
+
"comp-tooltip": compTooltip,
|
|
131
200
|
compass,
|
|
132
201
|
diagram,
|
|
133
202
|
discord,
|