color-elements 0.0.4 → 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/plain.njk +5 -0
- package/_redirects +1 -1
- package/assets/css/style.css +4 -4
- package/debug.html +46 -0
- package/package.json +19 -8
- package/src/channel-picker/channel-picker.css +4 -4
- package/src/channel-picker/channel-picker.js +15 -11
- package/src/channel-slider/channel-slider.css +14 -7
- package/src/channel-slider/channel-slider.js +13 -5
- package/src/color-chart/README.md +36 -5
- package/src/color-chart/color-chart-global.css +13 -12
- 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 +307 -103
- package/src/color-inline/color-inline.css +21 -16
- package/src/color-inline/color-inline.js +2 -3
- package/src/color-inline/style.css +1 -1
- package/src/color-picker/color-picker.css +3 -3
- package/src/color-picker/color-picker.js +14 -7
- package/src/color-scale/README.md +42 -2
- package/src/color-scale/color-scale.css +1 -1
- package/src/color-scale/color-scale.js +12 -9
- package/src/color-slider/README.md +17 -3
- package/src/color-slider/color-slider.css +54 -33
- package/src/color-slider/color-slider.js +9 -7
- package/src/color-swatch/color-swatch.css +41 -32
- package/src/color-swatch/color-swatch.js +17 -9
- package/src/common/color-element.js +34 -76
- package/src/common/dom.js +4 -2
- package/src/common/util.js +1 -1
- package/src/gamut-badge/gamut-badge.css +33 -13
- package/src/gamut-badge/gamut-badge.js +9 -7
- package/src/space-picker/space-picker.css +3 -3
- package/src/space-picker/space-picker.js +28 -10
- package/src/src.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(git fetch:*)",
|
|
5
|
+
"WebSearch",
|
|
6
|
+
"WebFetch(domain:www.npmjs.com)",
|
|
7
|
+
"Bash(npm info:*)",
|
|
8
|
+
"WebFetch(domain:github.com)",
|
|
9
|
+
"Bash(cat:*)",
|
|
10
|
+
"Bash(npm install:*)",
|
|
11
|
+
"Bash(npx nudeps:*)",
|
|
12
|
+
"Bash(npm run:*)",
|
|
13
|
+
"Bash(gh pr:*)",
|
|
14
|
+
"Bash(gh api:*)",
|
|
15
|
+
"WebFetch(domain:unpkg.com)",
|
|
16
|
+
"Bash(ls:*)",
|
|
17
|
+
"Bash(but:*)",
|
|
18
|
+
"WebFetch(domain:esm.sh)",
|
|
19
|
+
"Bash(npm pack:*)",
|
|
20
|
+
"Bash(mkdir -p /tmp/test-exports)",
|
|
21
|
+
"Read(//tmp/**)",
|
|
22
|
+
"Bash(rm -rf *)",
|
|
23
|
+
"Bash(npm init -y)",
|
|
24
|
+
"Bash(rm -rf /tmp/test-exports)",
|
|
25
|
+
"Read(//private/tmp/test-exports/**)",
|
|
26
|
+
"Bash(node:*)",
|
|
27
|
+
"Bash(rm:*)"
|
|
28
|
+
]
|
|
29
|
+
}
|
|
30
|
+
}
|
package/.editorconfig
ADDED
package/.prettierrc
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"plugins": [
|
|
3
|
+
"prettier-plugin-brace-style",
|
|
4
|
+
"prettier-plugin-space-before-function-paren",
|
|
5
|
+
"prettier-plugin-merge"
|
|
6
|
+
],
|
|
7
|
+
"braceStyle": "stroustrup",
|
|
8
|
+
"arrowParens": "avoid",
|
|
9
|
+
"bracketSpacing": true,
|
|
10
|
+
"endOfLine": "auto",
|
|
11
|
+
"semi": true,
|
|
12
|
+
"singleQuote": false,
|
|
13
|
+
"tabWidth": 4,
|
|
14
|
+
"useTabs": true,
|
|
15
|
+
"trailingComma": "all",
|
|
16
|
+
"printWidth": 100
|
|
17
|
+
}
|
package/README.md
CHANGED
|
@@ -33,38 +33,47 @@ Use at your own risk, the API can change at any point.
|
|
|
33
33
|
|
|
34
34
|
## Usage
|
|
35
35
|
|
|
36
|
-
###
|
|
36
|
+
### Via bare specifiers
|
|
37
37
|
|
|
38
|
-
|
|
38
|
+
Install via npm:
|
|
39
39
|
|
|
40
|
-
```
|
|
41
|
-
|
|
40
|
+
```bash
|
|
41
|
+
npm i color-elements
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
To
|
|
44
|
+
To include all components at once:
|
|
45
45
|
|
|
46
|
-
```
|
|
47
|
-
|
|
46
|
+
```js
|
|
47
|
+
import "color-elements";
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
You can also import individual components:
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
```js
|
|
53
|
+
import "color-elements/COMPONENT_NAME";
|
|
54
|
+
```
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
Each component also exports a standalone CSS file (for [CSS-only usage](src/color-slider/#css-only-usage)):
|
|
55
57
|
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
+
```css
|
|
59
|
+
@import url("color-elements/COMPONENT_NAME.css");
|
|
58
60
|
```
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
You can use these imports with [Nudeps](https://nudeps.dev) — no bundler needed
|
|
63
|
+
(this website does) — or with any bundler you already have.
|
|
61
64
|
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
### Via CDN
|
|
66
|
+
|
|
67
|
+
If you’d rather not set up any tooling, you can use a CDN such as [esm.sh](https://esm.sh):
|
|
68
|
+
|
|
69
|
+
```html
|
|
70
|
+
<script src="https://esm.sh/color-elements" type="module"></script>
|
|
64
71
|
```
|
|
65
72
|
|
|
66
|
-
|
|
73
|
+
To cherry-pick individual components:
|
|
67
74
|
|
|
68
|
-
```
|
|
69
|
-
|
|
75
|
+
```html
|
|
76
|
+
<script src="https://esm.sh/color-elements/COMPONENT_NAME" type="module"></script>
|
|
70
77
|
```
|
|
78
|
+
|
|
79
|
+
Each component imports its own dependencies and styles.
|
package/_build/copy-config.js
CHANGED
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
import { exec } from
|
|
1
|
+
import { exec } from "child_process";
|
|
2
2
|
import { writeFileSync, readFileSync } from "fs";
|
|
3
3
|
import config from "./copy-config.json" with { type: "json" };
|
|
4
4
|
|
|
5
5
|
const TEMP_REPO = "_build/.colorjs.io";
|
|
6
6
|
|
|
7
7
|
// Cleanup past attempts
|
|
8
|
-
exec(`rm -rf ${
|
|
8
|
+
exec(`rm -rf ${TEMP_REPO}`);
|
|
9
9
|
|
|
10
10
|
// Copy files from source repo
|
|
11
11
|
let commands = [
|
|
12
|
-
`git clone ${
|
|
12
|
+
`git clone ${config.source} ${TEMP_REPO}`,
|
|
13
13
|
...config.paths.map(path => {
|
|
14
14
|
let [current_path, new_path] = Array.isArray(path) ? path : [path, path];
|
|
15
15
|
let new_path_dir = new_path.split("/").slice(0, -1).join("/");
|
|
16
16
|
|
|
17
|
-
let commands = [
|
|
18
|
-
`rm -rf ./${new_path}`,
|
|
19
|
-
`cp -r ${TEMP_REPO}/${ current_path } ./${ new_path }`,
|
|
20
|
-
];
|
|
17
|
+
let commands = [`rm -rf ./${new_path}`, `cp -r ${TEMP_REPO}/${current_path} ./${new_path}`];
|
|
21
18
|
|
|
22
19
|
if (new_path_dir) {
|
|
23
20
|
commands.splice(1, 0, `mkdir -p ./${new_path_dir}`);
|
|
@@ -30,7 +27,7 @@ let commands = [
|
|
|
30
27
|
await new Promise(resolve => {
|
|
31
28
|
exec(commands.join(" && "), (err, stdout, stderr) => {
|
|
32
29
|
// Cleanup
|
|
33
|
-
exec(`rm -rf ${
|
|
30
|
+
exec(`rm -rf ${TEMP_REPO}`);
|
|
34
31
|
|
|
35
32
|
if (err) {
|
|
36
33
|
console.error(err);
|
|
@@ -54,7 +51,8 @@ for (let path of config.paths) {
|
|
|
54
51
|
if (i > -1) {
|
|
55
52
|
index = i;
|
|
56
53
|
}
|
|
57
|
-
else {
|
|
54
|
+
else {
|
|
55
|
+
// not found
|
|
58
56
|
gitignore.push(new_path);
|
|
59
57
|
paths_added_to_gitignore.push(new_path);
|
|
60
58
|
}
|
|
@@ -65,14 +63,17 @@ if (paths_added_to_gitignore.length > 0) {
|
|
|
65
63
|
console.log("Added paths to .gitignore: " + paths_added_to_gitignore.join(", "));
|
|
66
64
|
}
|
|
67
65
|
|
|
68
|
-
let source_package_json = JSON.parse(readFileSync(`${
|
|
66
|
+
let source_package_json = JSON.parse(readFileSync(`${TEMP_REPO}/package.json`, "utf8"));
|
|
69
67
|
let package_json = JSON.parse(readFileSync(`package.json`, "utf8"));
|
|
70
68
|
|
|
71
69
|
// Copy npm scripts
|
|
72
70
|
let scripts_copied = [];
|
|
73
71
|
|
|
74
72
|
for (let script of config.scripts) {
|
|
75
|
-
if (
|
|
73
|
+
if (
|
|
74
|
+
source_package_json.scripts[script] &&
|
|
75
|
+
package_json.scripts[script] !== source_package_json.scripts[script]
|
|
76
|
+
) {
|
|
76
77
|
package_json.scripts[script] = source_package_json.scripts[script];
|
|
77
78
|
scripts_copied.push(script);
|
|
78
79
|
}
|
|
@@ -94,7 +95,7 @@ if (source_package_json.devDependencies) {
|
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
if (missing_packages.length) {
|
|
97
|
-
console.warn(`Installing packages: ${
|
|
98
|
-
exec(`npm install -D ${
|
|
98
|
+
console.warn(`Installing packages: ${missing_packages.join(", ")}`);
|
|
99
|
+
exec(`npm install -D ${missing_packages.join(" ")}`);
|
|
99
100
|
}
|
|
100
|
-
}
|
|
101
|
+
}
|
package/_build/copy-config.json
CHANGED
|
@@ -3,16 +3,11 @@
|
|
|
3
3
|
"paths": [
|
|
4
4
|
"_includes/partials/_nav.njk",
|
|
5
5
|
"_includes/page.njk",
|
|
6
|
-
"_includes/plain.njk",
|
|
6
|
+
["_includes/plain.njk", "_includes/plain-base.njk"],
|
|
7
7
|
"data/eleventyComputed.js",
|
|
8
8
|
["_build/eleventy.js", "_build/eleventy-original.js"],
|
|
9
9
|
"_build/filters.js"
|
|
10
10
|
],
|
|
11
|
-
"scripts": [
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
],
|
|
15
|
-
"packages": [
|
|
16
|
-
"@11ty/eleventy"
|
|
17
|
-
]
|
|
18
|
-
}
|
|
11
|
+
"scripts": ["build:html", "watch:html"],
|
|
12
|
+
"packages": ["@11ty/eleventy"]
|
|
13
|
+
}
|
package/_build/eleventy.js
CHANGED
|
@@ -5,8 +5,8 @@ import configOriginal from "./eleventy-original.js";
|
|
|
5
5
|
import * as filters from "./filters-extra.js";
|
|
6
6
|
|
|
7
7
|
let data = {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
permalink: "{{ page.filePathStem | replace('README', '') | replace('index', '') }}/index.html",
|
|
9
|
+
body_classes: "cn-ignore",
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
let md = markdownIt({
|
|
@@ -14,12 +14,12 @@ let md = markdownIt({
|
|
|
14
14
|
linkify: true,
|
|
15
15
|
typographer: true,
|
|
16
16
|
})
|
|
17
|
-
.disable("code")
|
|
18
|
-
.use(markdownItAttrs)
|
|
19
|
-
.use(markdownItAnchor, {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
17
|
+
.disable("code")
|
|
18
|
+
.use(markdownItAttrs)
|
|
19
|
+
.use(markdownItAnchor, {
|
|
20
|
+
permalink: markdownItAnchor.permalink.headerLink(),
|
|
21
|
+
level: 2,
|
|
22
|
+
});
|
|
23
23
|
|
|
24
24
|
export default config => {
|
|
25
25
|
let ret = configOriginal(config);
|
package/_includes/component.njk
CHANGED
|
@@ -42,19 +42,7 @@
|
|
|
42
42
|
To install all color elements, check out the [instructions on the homepage](../).
|
|
43
43
|
The rest of this section is about using _only_ `{{ tag | safe }}`.
|
|
44
44
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```html
|
|
48
|
-
<script src="https://elements.colorjs.io/src/{{ name }}/{{ name }}.js" type="module"></script>
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
or in JS:
|
|
52
|
-
|
|
53
|
-
```js
|
|
54
|
-
import "https://elements.colorjs.io/src/{{ name }}/{{ name }}.js";
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
If you are using npm to manage your dependencies, you can import it via:
|
|
45
|
+
If you’re using a bundler, or an import map manager like [Nudeps](https://nudeps.dev/) or [JSPM](https://jspm.org/), you can import it via a bare specifier:
|
|
58
46
|
|
|
59
47
|
```js
|
|
60
48
|
import "color-elements/{{ name }}";
|
|
@@ -65,5 +53,12 @@ or:
|
|
|
65
53
|
```js
|
|
66
54
|
import { {{ name | tag_to_class }} } from "color-elements";
|
|
67
55
|
```
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
Otherwise, you can use a CDN such as [esm.sh](https://esm.sh):
|
|
59
|
+
|
|
60
|
+
```html
|
|
61
|
+
<script src="https://esm.sh/color-elements/{{ name }}" type="module"></script>
|
|
62
|
+
```
|
|
68
63
|
{% endmd %}
|
|
69
|
-
</section>
|
|
64
|
+
</section>
|
package/_redirects
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Specific versions
|
|
2
|
-
node_modules/nude-element/* https://cdn.jsdelivr.net/npm/nude-element@0.
|
|
2
|
+
node_modules/nude-element/* https://cdn.jsdelivr.net/npm/nude-element@0.1.1/:splat 200
|
|
3
3
|
|
|
4
4
|
# Catch all NPM fallback
|
|
5
5
|
node_modules/:modulename/* https://cdn.jsdelivr.net/npm/:modulename@latest/:splat 200
|
package/assets/css/style.css
CHANGED
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
overflow: hidden;
|
|
18
18
|
|
|
19
19
|
border: 1px solid var(--_border-color);
|
|
20
|
-
border-radius: .5em;
|
|
20
|
+
border-radius: 0.5em;
|
|
21
21
|
|
|
22
|
-
box-shadow: 0 .02em .5em
|
|
22
|
+
box-shadow: 0 0.02em 0.5em -0.7em hsl(var(--gray) 30%);
|
|
23
23
|
|
|
24
24
|
&:is(:hover, :focus-within) {
|
|
25
25
|
img {
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
img {
|
|
31
31
|
inline-size: 100%;
|
|
32
32
|
aspect-ratio: 4 / 3;
|
|
33
|
-
transition: scale .2s;
|
|
33
|
+
transition: scale 0.2s;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
figcaption {
|
|
37
37
|
margin: 0;
|
|
38
|
-
padding: 0 .7em .5em;
|
|
38
|
+
padding: 0 0.7em 0.5em;
|
|
39
39
|
border-block-start: 1px solid var(--_border-color);
|
|
40
40
|
background-color: hsl(var(--gray) 98%);
|
|
41
41
|
z-index: 1;
|
package/debug.html
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<!-- <html lang="en" style="color-scheme: dark;"> -->
|
|
4
|
+
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="UTF-8" />
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
|
+
<!-- <link rel="stylesheet" href="./src/color-chart/color-chart-global.css"> -->
|
|
9
|
+
<title>Document</title>
|
|
10
|
+
<style>
|
|
11
|
+
:root {
|
|
12
|
+
--test: red;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
html,
|
|
16
|
+
body {
|
|
17
|
+
margin: 0;
|
|
18
|
+
min-height: 100vh;
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
</head>
|
|
22
|
+
|
|
23
|
+
<!-- <body style="display: grid; place-items: center; align-content: center; margin: 2rem"> -->
|
|
24
|
+
|
|
25
|
+
<body style="display: grid; align-items: center; align-content: center; margin: 2rem">
|
|
26
|
+
<html-demo>
|
|
27
|
+
<space-picker
|
|
28
|
+
onspacechange="this.nextElementSibling.textContent = this.value"
|
|
29
|
+
></space-picker>
|
|
30
|
+
<output></output>
|
|
31
|
+
</html-demo>
|
|
32
|
+
|
|
33
|
+
<!-- <script src="./index.js" type="module"></script> -->
|
|
34
|
+
<!--<script src="./src/color-picker/color-picker.js" type="module"></script>-->
|
|
35
|
+
<!--<script src="./src/color-slider/color-slider.js" type="module"></script>-->
|
|
36
|
+
<!--<script src="./src/channel-slider/channel-slider.js" type="module"></script>-->
|
|
37
|
+
<!--<script src="./src/color-swatch/color-swatch.js" type="module"></script>-->
|
|
38
|
+
<!--<script src="./src/color-scale/color-scale.js" type="module"></script>-->
|
|
39
|
+
<!--<script src="./src/color-chart/color-chart.js" type="module"></script>-->
|
|
40
|
+
<script src="./src/space-picker/space-picker.js" type="module"></script>
|
|
41
|
+
<!--<script src="./src/channel-picker/channel-picker.js" type="module"></script>-->
|
|
42
|
+
<!--<script src="./src/gamut-badge/gamut-badge.js" type="module"></script> -->
|
|
43
|
+
<!--<script src="./src/color-inline/color-inline.js" type="module"></script>-->
|
|
44
|
+
<script src="https://nudeui.com/elements/html-demo/html-demo.js" type="module"></script>
|
|
45
|
+
</body>
|
|
46
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "color-elements",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "A set of web components for working with color. A Color.js project.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./*.css": "./src/*/*.css",
|
|
10
|
+
"./*": "./src/*/*.js"
|
|
11
|
+
},
|
|
7
12
|
"scripts": {
|
|
8
13
|
"eslint": "npx eslint .",
|
|
9
14
|
"eslint:fix": "npx eslint . --fix",
|
|
@@ -11,11 +16,13 @@
|
|
|
11
16
|
"build": "npm run build:html",
|
|
12
17
|
"watch": "run-p watch:*",
|
|
13
18
|
"prepack": "npm run build",
|
|
14
|
-
"release": "release-it",
|
|
19
|
+
"release": "npm login && release-it",
|
|
15
20
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
16
21
|
"build:html": "npx @11ty/eleventy --config=_build/eleventy.js",
|
|
17
22
|
"serve": "npx @11ty/eleventy --config=_build/eleventy.js --serve",
|
|
18
|
-
"watch:html": "npx @11ty/eleventy --config=_build/eleventy.js --serve"
|
|
23
|
+
"watch:html": "npx @11ty/eleventy --config=_build/eleventy.js --serve",
|
|
24
|
+
"dependencies": "npx nudeps",
|
|
25
|
+
"prepare": "npx nudeps"
|
|
19
26
|
},
|
|
20
27
|
"repository": {
|
|
21
28
|
"type": "git",
|
|
@@ -37,17 +44,21 @@
|
|
|
37
44
|
},
|
|
38
45
|
"homepage": "https://github.com/color-js/elements#readme",
|
|
39
46
|
"dependencies": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"nude-element": "latest"
|
|
47
|
+
"colorjs.io": ">=0.5.0",
|
|
48
|
+
"nude-element": "^0.1.1"
|
|
43
49
|
},
|
|
44
50
|
"devDependencies": {
|
|
51
|
+
"@11ty/eleventy": "^3.1.2",
|
|
45
52
|
"@stylistic/eslint-plugin": "latest",
|
|
46
53
|
"eslint": "latest",
|
|
47
54
|
"globals": "latest",
|
|
48
55
|
"markdown-it-anchor": "^8",
|
|
49
56
|
"markdown-it-attrs": "^4.1.6",
|
|
50
57
|
"npm-run-all": "^4.1.5",
|
|
51
|
-
"
|
|
58
|
+
"nudeps": "^0.2.3",
|
|
59
|
+
"prettier-plugin-brace-style": "latest",
|
|
60
|
+
"prettier-plugin-merge": "latest",
|
|
61
|
+
"prettier-plugin-space-before-function-paren": "latest",
|
|
62
|
+
"release-it": "^19.2.4"
|
|
52
63
|
}
|
|
53
|
-
}
|
|
64
|
+
}
|
|
@@ -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: var(--border-width) solid var(--border-color);
|
|
9
9
|
border-radius: var(--border-radius);
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
#space_picker {
|
|
26
26
|
padding: initial;
|
|
27
|
-
padding-inline-end: .4em;
|
|
27
|
+
padding-inline-end: 0.4em;
|
|
28
28
|
border-radius: 0;
|
|
29
29
|
border: none;
|
|
30
30
|
border-inline-end: var(--border-width) solid var(--border-color);
|
|
@@ -54,12 +54,12 @@ const Self = class ChannelPicker extends ColorElement {
|
|
|
54
54
|
let coords = space.coords;
|
|
55
55
|
|
|
56
56
|
if (space && !coords) {
|
|
57
|
-
console.warn(`Color space "${
|
|
57
|
+
console.warn(`Color space "${space.name}" has no coordinates.`);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
this._el.picker.innerHTML = Object.entries(coords)
|
|
62
|
-
.map(([id, coord]) => `<option value="${
|
|
62
|
+
.map(([id, coord]) => `<option value="${id}">${coord.name}</option>`)
|
|
63
63
|
.join("\n");
|
|
64
64
|
|
|
65
65
|
let [prevSpace, prevChannel] = this.value?.split(".") ?? [];
|
|
@@ -83,30 +83,34 @@ const Self = class ChannelPicker extends ColorElement {
|
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
if ([this._el.space_picker, this._el.picker].includes(event.target)) {
|
|
86
|
-
let value = `${
|
|
86
|
+
let value = `${this._el.space_picker.value}.${this._el.picker.value}`;
|
|
87
87
|
if (value !== this.value) {
|
|
88
88
|
this.value = value;
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
-
propChangedCallback ({name, prop, detail: change}) {
|
|
93
|
+
propChangedCallback ({ name, prop, detail: change }) {
|
|
94
94
|
if (name === "value" && this.value) {
|
|
95
95
|
let [space, channel] = (this.value + "").split(".");
|
|
96
96
|
|
|
97
97
|
let currentSpace = this._el.space_picker.value;
|
|
98
98
|
let currentCoord = this._el.picker.value;
|
|
99
|
-
let currentValue = `${
|
|
99
|
+
let currentValue = `${currentSpace}.${currentCoord}`;
|
|
100
100
|
|
|
101
101
|
if (!space || !channel) {
|
|
102
|
-
console.warn(
|
|
102
|
+
console.warn(
|
|
103
|
+
`Invalid value "${this.value}". Expected format: "space.channel". Falling back to "${currentValue}".`,
|
|
104
|
+
);
|
|
103
105
|
this.value = currentValue;
|
|
104
106
|
}
|
|
105
107
|
else {
|
|
106
108
|
let spaces = Object.keys(this._el.space_picker.spaces);
|
|
107
109
|
|
|
108
110
|
if (!spaces.includes(space)) {
|
|
109
|
-
console.warn(
|
|
111
|
+
console.warn(
|
|
112
|
+
`No "${space}" color space found. Choose one of the following: ${spaces.join(", ")}. Falling back to "${currentSpace}".`,
|
|
113
|
+
);
|
|
110
114
|
this.value = currentValue;
|
|
111
115
|
}
|
|
112
116
|
else {
|
|
@@ -123,13 +127,13 @@ const Self = class ChannelPicker extends ColorElement {
|
|
|
123
127
|
else {
|
|
124
128
|
currentCoord = coords.includes(currentCoord) ? currentCoord : coords[0];
|
|
125
129
|
|
|
126
|
-
let message = `Color space "${
|
|
130
|
+
let message = `Color space "${space}" has no coordinate "${channel}".`;
|
|
127
131
|
if (coords.length) {
|
|
128
|
-
message += ` Choose one of the following: ${
|
|
132
|
+
message += ` Choose one of the following: ${coords.join(", ")}.`;
|
|
129
133
|
}
|
|
130
|
-
message += ` Falling back to "${
|
|
134
|
+
message += ` Falling back to "${currentCoord}".`;
|
|
131
135
|
console.warn(message);
|
|
132
|
-
this.value = `${
|
|
136
|
+
this.value = `${space}.${currentCoord}`;
|
|
133
137
|
channel = currentCoord;
|
|
134
138
|
}
|
|
135
139
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
display: grid;
|
|
5
5
|
grid-template-columns: 1fr auto;
|
|
6
|
-
gap: .3em;
|
|
6
|
+
gap: 0.3em;
|
|
7
7
|
align-items: center;
|
|
8
8
|
|
|
9
9
|
em {
|
|
@@ -15,8 +15,15 @@
|
|
|
15
15
|
opacity: 0;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
input[type=number] {
|
|
19
|
-
--_border-color: var(
|
|
18
|
+
input[type="number"] {
|
|
19
|
+
--_border-color: var(
|
|
20
|
+
--border-color,
|
|
21
|
+
color-mix(
|
|
22
|
+
in oklab,
|
|
23
|
+
currentcolor calc(var(--_current-color-percent, 30) * 1%),
|
|
24
|
+
oklab(none none none / 0%)
|
|
25
|
+
)
|
|
26
|
+
);
|
|
20
27
|
|
|
21
28
|
all: unset;
|
|
22
29
|
|
|
@@ -24,8 +31,8 @@
|
|
|
24
31
|
width: calc(var(--content-width, 2ch) + 1.2em);
|
|
25
32
|
min-width: calc(2ch + 1.2em);
|
|
26
33
|
box-sizing: content-box;
|
|
27
|
-
padding: .1em .2em;
|
|
28
|
-
border-radius: .2em;
|
|
34
|
+
padding: 0.1em 0.2em;
|
|
35
|
+
border-radius: 0.2em;
|
|
29
36
|
border: 1px solid var(--_border-color);
|
|
30
37
|
text-align: center;
|
|
31
38
|
font-size: 90%;
|
|
@@ -33,7 +40,7 @@
|
|
|
33
40
|
transition-property: opacity, border-color;
|
|
34
41
|
|
|
35
42
|
&::-webkit-textfield-decoration-container {
|
|
36
|
-
gap: .2em;
|
|
43
|
+
gap: 0.2em;
|
|
37
44
|
}
|
|
38
45
|
|
|
39
46
|
&:not(:hover, :focus) {
|
|
@@ -44,7 +51,7 @@
|
|
|
44
51
|
|
|
45
52
|
&::-webkit-inner-spin-button {
|
|
46
53
|
/* Fade out the spin buttons in Chrome and Safari */
|
|
47
|
-
opacity: .35;
|
|
54
|
+
opacity: 0.35;
|
|
48
55
|
filter: contrast(2);
|
|
49
56
|
}
|
|
50
57
|
}
|
|
@@ -86,7 +86,7 @@ const Self = class ChannelSlider extends ColorElement {
|
|
|
86
86
|
return this._el.slider.progressAt(p);
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
propChangedCallback ({name, prop, detail: change}) {
|
|
89
|
+
propChangedCallback ({ name, prop, detail: change }) {
|
|
90
90
|
if (["space", "min", "max", "step", "value", "defaultValue"].includes(name)) {
|
|
91
91
|
prop.applyChange(this._el.slider, change);
|
|
92
92
|
|
|
@@ -104,11 +104,17 @@ const Self = class ChannelSlider extends ColorElement {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
-
if (
|
|
107
|
+
if (
|
|
108
|
+
name === "defaultColor" ||
|
|
109
|
+
name === "space" ||
|
|
110
|
+
name === "channel" ||
|
|
111
|
+
name === "min" ||
|
|
112
|
+
name === "max"
|
|
113
|
+
) {
|
|
108
114
|
this._el.slider.stops = this.stops;
|
|
109
115
|
|
|
110
116
|
if (name === "space" || name === "channel" || name === "min" || name === "max") {
|
|
111
|
-
this._el.channel_info.innerHTML = `${
|
|
117
|
+
this._el.channel_info.innerHTML = `${this.channelName} <em>(${this.min} – ${this.max})</em>`;
|
|
112
118
|
}
|
|
113
119
|
}
|
|
114
120
|
}
|
|
@@ -164,7 +170,9 @@ const Self = class ChannelSlider extends ColorElement {
|
|
|
164
170
|
|
|
165
171
|
if (!channelSpec && this.space) {
|
|
166
172
|
channelSpec = Object.values(this.space.coords)[0];
|
|
167
|
-
console.warn(
|
|
173
|
+
console.warn(
|
|
174
|
+
`Unknown channel ${this.channel} in space ${this.space}. Using first channel (${channelSpec.name}) instead.`,
|
|
175
|
+
);
|
|
168
176
|
}
|
|
169
177
|
|
|
170
178
|
return channelSpec;
|
|
@@ -274,7 +282,7 @@ const Self = class ChannelSlider extends ColorElement {
|
|
|
274
282
|
},
|
|
275
283
|
};
|
|
276
284
|
|
|
277
|
-
static
|
|
285
|
+
static formBehavior = {
|
|
278
286
|
like: el => el._el.slider,
|
|
279
287
|
role: "slider",
|
|
280
288
|
valueProp: "value",
|