color-elements 0.0.3 → 0.0.5
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/.claude/settings.local.json +30 -0
- package/.editorconfig +8 -0
- package/.prettierrc +17 -0
- package/.vscode/settings.json +7 -0
- package/README.md +27 -18
- package/_build/copy-config.js +15 -14
- package/_build/copy-config.json +4 -9
- package/_build/eleventy.js +8 -8
- package/_includes/component.njk +9 -14
- package/_includes/partials/_nav-links.njk +1 -0
- package/_includes/plain.njk +5 -0
- package/_redirects +1 -1
- package/assets/css/style.css +4 -4
- package/debug.html +38 -439
- package/package.json +24 -8
- package/src/channel-picker/channel-picker.css +4 -4
- package/src/channel-picker/channel-picker.js +16 -12
- package/src/channel-slider/channel-slider.css +14 -7
- package/src/channel-slider/channel-slider.js +14 -6
- package/src/color-chart/README.md +36 -5
- package/src/color-chart/color-chart-global.css +19 -14
- package/src/color-chart/color-chart-shadow.css +123 -0
- package/src/color-chart/color-chart.css +2 -112
- package/src/color-chart/color-chart.js +309 -107
- package/src/color-inline/color-inline.css +21 -16
- package/src/color-inline/color-inline.js +3 -4
- package/src/color-inline/style.css +1 -1
- package/src/color-picker/color-picker.css +3 -3
- package/src/color-picker/color-picker.js +15 -8
- package/src/color-scale/README.md +42 -2
- package/src/color-scale/color-scale.css +8 -13
- package/src/color-scale/color-scale.js +14 -11
- package/src/color-slider/README.md +17 -3
- package/src/color-slider/color-slider.css +54 -33
- package/src/color-slider/color-slider.js +10 -8
- package/src/color-swatch/color-swatch.css +52 -34
- package/src/color-swatch/color-swatch.js +20 -10
- package/src/common/color-element.js +63 -51
- package/src/common/dom.js +4 -2
- package/src/common/util.js +66 -1
- package/src/gamut-badge/gamut-badge.css +33 -13
- package/src/gamut-badge/gamut-badge.js +10 -8
- package/src/space-picker/space-picker.css +3 -3
- package/src/space-picker/space-picker.js +29 -11
- package/src/src.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
:host {
|
|
2
2
|
--border-width: 1px;
|
|
3
|
-
--border-color: rgb(0 0 0 / .2);
|
|
4
|
-
--border-radius: .2em;
|
|
3
|
+
--border-color: rgb(0 0 0 / 0.2);
|
|
4
|
+
--border-radius: 0.2em;
|
|
5
5
|
|
|
6
|
-
padding: .3em .5em;
|
|
6
|
+
padding: 0.3em 0.5em;
|
|
7
7
|
|
|
8
8
|
border-radius: var(--border-radius);
|
|
9
9
|
border: var(--border-width) solid var(--border-color);
|
|
@@ -3,7 +3,7 @@ import ColorElement from "../common/color-element.js";
|
|
|
3
3
|
const Self = class SpacePicker extends ColorElement {
|
|
4
4
|
static tagName = "space-picker";
|
|
5
5
|
static url = import.meta.url;
|
|
6
|
-
static
|
|
6
|
+
static styles = "./space-picker.css";
|
|
7
7
|
static shadowTemplate = `<select id="picker" part="base"></select>`;
|
|
8
8
|
|
|
9
9
|
constructor () {
|
|
@@ -29,11 +29,14 @@ const Self = class SpacePicker extends ColorElement {
|
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
propChangedCallback ({name, prop, detail: change}) {
|
|
32
|
+
propChangedCallback ({ name, prop, detail: change }) {
|
|
33
33
|
if (name === "spaces") {
|
|
34
34
|
if (!this.groups) {
|
|
35
35
|
this._el.picker.innerHTML = Object.entries(this.spaces)
|
|
36
|
-
.map(
|
|
36
|
+
.map(
|
|
37
|
+
([id, space]) =>
|
|
38
|
+
`<option value="${id}">${this.getSpaceLabel(space)}</option>`,
|
|
39
|
+
)
|
|
37
40
|
.join("\n");
|
|
38
41
|
}
|
|
39
42
|
else {
|
|
@@ -42,7 +45,9 @@ const Self = class SpacePicker extends ColorElement {
|
|
|
42
45
|
// Remove empty groups
|
|
43
46
|
groups = Object.entries(groups).filter(([type, spaces]) => {
|
|
44
47
|
if (Object.keys(spaces).length === 0) {
|
|
45
|
-
console.warn(
|
|
48
|
+
console.warn(
|
|
49
|
+
`Removed empty group of color spaces with the label "${type}."`,
|
|
50
|
+
);
|
|
46
51
|
return false;
|
|
47
52
|
}
|
|
48
53
|
|
|
@@ -50,17 +55,26 @@ const Self = class SpacePicker extends ColorElement {
|
|
|
50
55
|
});
|
|
51
56
|
|
|
52
57
|
if (!groups.length) {
|
|
53
|
-
console.warn(
|
|
58
|
+
console.warn(
|
|
59
|
+
"All provided groups of color spaces are empty. Falling back to default grouping.",
|
|
60
|
+
);
|
|
54
61
|
groups = [["All spaces", this.spaces]];
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
this._el.picker.innerHTML = groups
|
|
64
|
+
this._el.picker.innerHTML = groups
|
|
65
|
+
.map(
|
|
66
|
+
([type, spaces]) => `
|
|
58
67
|
<optgroup label="${type}">
|
|
59
68
|
${Object.entries(spaces)
|
|
60
|
-
.map(
|
|
69
|
+
.map(
|
|
70
|
+
([id, space]) =>
|
|
71
|
+
`<option value="${id}">${this.getSpaceLabel(space)}</option>`,
|
|
72
|
+
)
|
|
61
73
|
.join("\n")}
|
|
62
74
|
</optgroup>
|
|
63
|
-
|
|
75
|
+
`,
|
|
76
|
+
)
|
|
77
|
+
.join("\n");
|
|
64
78
|
}
|
|
65
79
|
|
|
66
80
|
this._el.picker.value = this.value;
|
|
@@ -76,7 +90,9 @@ const Self = class SpacePicker extends ColorElement {
|
|
|
76
90
|
let currentSpace = this._el.picker.value;
|
|
77
91
|
let fallback = spaces.includes(currentSpace) ? currentSpace : firstSpace;
|
|
78
92
|
|
|
79
|
-
console.warn(
|
|
93
|
+
console.warn(
|
|
94
|
+
`No color space found with id = "${value}". Choose one of the following: ${spaces.join(", ")}. Falling back to "${fallback}".`,
|
|
95
|
+
);
|
|
80
96
|
this.value = value = fallback;
|
|
81
97
|
}
|
|
82
98
|
|
|
@@ -140,7 +156,9 @@ const Self = class SpacePicker extends ColorElement {
|
|
|
140
156
|
return value;
|
|
141
157
|
},
|
|
142
158
|
stringify (value) {
|
|
143
|
-
return Object.entries(value)
|
|
159
|
+
return Object.entries(value)
|
|
160
|
+
.map(([id, space]) => id)
|
|
161
|
+
.join(", ");
|
|
144
162
|
},
|
|
145
163
|
},
|
|
146
164
|
|
|
@@ -201,7 +219,7 @@ const Self = class SpacePicker extends ColorElement {
|
|
|
201
219
|
},
|
|
202
220
|
};
|
|
203
221
|
|
|
204
|
-
static
|
|
222
|
+
static formBehavior = {
|
|
205
223
|
like: el => el._el.picker,
|
|
206
224
|
role: "combobox",
|
|
207
225
|
changeEvent: "change",
|
package/src/src.json
CHANGED