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.
Files changed (45) hide show
  1. package/.claude/settings.local.json +30 -0
  2. package/.editorconfig +8 -0
  3. package/.prettierrc +17 -0
  4. package/.vscode/settings.json +7 -0
  5. package/README.md +27 -18
  6. package/_build/copy-config.js +15 -14
  7. package/_build/copy-config.json +4 -9
  8. package/_build/eleventy.js +8 -8
  9. package/_includes/component.njk +9 -14
  10. package/_includes/partials/_nav-links.njk +1 -0
  11. package/_includes/plain.njk +5 -0
  12. package/_redirects +1 -1
  13. package/assets/css/style.css +4 -4
  14. package/debug.html +38 -439
  15. package/package.json +24 -8
  16. package/src/channel-picker/channel-picker.css +4 -4
  17. package/src/channel-picker/channel-picker.js +16 -12
  18. package/src/channel-slider/channel-slider.css +14 -7
  19. package/src/channel-slider/channel-slider.js +14 -6
  20. package/src/color-chart/README.md +36 -5
  21. package/src/color-chart/color-chart-global.css +19 -14
  22. package/src/color-chart/color-chart-shadow.css +123 -0
  23. package/src/color-chart/color-chart.css +2 -112
  24. package/src/color-chart/color-chart.js +309 -107
  25. package/src/color-inline/color-inline.css +21 -16
  26. package/src/color-inline/color-inline.js +3 -4
  27. package/src/color-inline/style.css +1 -1
  28. package/src/color-picker/color-picker.css +3 -3
  29. package/src/color-picker/color-picker.js +15 -8
  30. package/src/color-scale/README.md +42 -2
  31. package/src/color-scale/color-scale.css +8 -13
  32. package/src/color-scale/color-scale.js +14 -11
  33. package/src/color-slider/README.md +17 -3
  34. package/src/color-slider/color-slider.css +54 -33
  35. package/src/color-slider/color-slider.js +10 -8
  36. package/src/color-swatch/color-swatch.css +52 -34
  37. package/src/color-swatch/color-swatch.js +20 -10
  38. package/src/common/color-element.js +63 -51
  39. package/src/common/dom.js +4 -2
  40. package/src/common/util.js +66 -1
  41. package/src/gamut-badge/gamut-badge.css +33 -13
  42. package/src/gamut-badge/gamut-badge.js +10 -8
  43. package/src/space-picker/space-picker.css +3 -3
  44. package/src/space-picker/space-picker.js +29 -11
  45. 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
@@ -0,0 +1,8 @@
1
+ root = true
2
+
3
+ [*]
4
+ indent_style = tab
5
+ charset = utf-8
6
+ trim_trailing_whitespace = true
7
+ insert_final_newline = true
8
+ end_of_line = lf
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
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "editor.formatOnSave": true,
3
+ "editor.formatOnSaveMode": "file",
4
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
5
+ "prettier.enable": true,
6
+ "debug.enableStatusBarColor": false
7
+ }
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
- ### CDN
36
+ ### Via bare specifiers
37
37
 
38
- To include all components at once:
38
+ Install via npm:
39
39
 
40
- ```html
41
- <script src="https://elements.colorjs.io/index.js" type="module"></script>
40
+ ```bash
41
+ npm i color-elements
42
42
  ```
43
43
 
44
- To cherry-pick individual components, follow the instructions within the component’s page, but it generally looks like this:
44
+ To include all components at once:
45
45
 
46
- ```html
47
- <script src="https://elements.colorjs.io/src/COMPONENT_NAME/COMPONENT_NAME.js" type="module"></script>
46
+ ```js
47
+ import "color-elements";
48
48
  ```
49
49
 
50
- Each component imports its own dependencies and styles.
50
+ You can also import individual components:
51
51
 
52
- ### NPM
52
+ ```js
53
+ import "color-elements/COMPONENT_NAME";
54
+ ```
53
55
 
54
- As usual:
56
+ Each component also exports a standalone CSS file (for [CSS-only usage](src/color-slider/#css-only-usage)):
55
57
 
56
- ```bash
57
- npm i color-elements
58
+ ```css
59
+ @import url("color-elements/COMPONENT_NAME.css");
58
60
  ```
59
61
 
60
- and then:
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
- ```js
63
- import "color-elements";
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
- You can also import individual components:
73
+ To cherry-pick individual components:
67
74
 
68
- ```js
69
- import "color-elements/COMPONENT_NAME";
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.
@@ -1,23 +1,20 @@
1
- import { exec } from 'child_process';
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 ${ TEMP_REPO }`);
8
+ exec(`rm -rf ${TEMP_REPO}`);
9
9
 
10
10
  // Copy files from source repo
11
11
  let commands = [
12
- `git clone ${ config.source } ${ TEMP_REPO }`,
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 ${ TEMP_REPO }`);
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 { // not found
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(`${ TEMP_REPO }/package.json`, "utf8"));
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 (source_package_json.scripts[script] && package_json.scripts[script] !== source_package_json.scripts[script]) {
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: ${ missing_packages.join(", ") }`);
98
- exec(`npm install -D ${ missing_packages.join(" ") }`);
98
+ console.warn(`Installing packages: ${missing_packages.join(", ")}`);
99
+ exec(`npm install -D ${missing_packages.join(" ")}`);
99
100
  }
100
- }
101
+ }
@@ -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
- "build:html",
13
- "watch:html"
14
- ],
15
- "packages": [
16
- "@11ty/eleventy"
17
- ]
18
- }
11
+ "scripts": ["build:html", "watch:html"],
12
+ "packages": ["@11ty/eleventy"]
13
+ }
@@ -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
- "permalink": "{{ page.filePathStem | replace('README', '') | replace('index', '') }}/index.html",
9
- "body_classes": "cn-ignore",
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
- permalink: markdownItAnchor.permalink.headerLink(),
21
- level: 2,
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);
@@ -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
- The quick and dirty way is straight from the CDN (kindly provided by [Netlify](https://www.netlify.com/)):
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>
@@ -15,5 +15,6 @@
15
15
  <li><a href="https://github.com/color-js/elements/issues/new{{ ('?title=[' + name + '] ') if name }}">New</a></li>
16
16
  </ul>
17
17
  </div>
18
+ <a href="https://opencollective.com/color">♡&nbsp;Sponsor</a>
18
19
 
19
20
 
@@ -0,0 +1,5 @@
1
+ {% extends "plain-base.njk" %}
2
+
3
+ {% block head %}
4
+ <script src="/importmap.js"></script>
5
+ {% endblock %}
package/_redirects CHANGED
@@ -1,5 +1,5 @@
1
1
  # Specific versions
2
- node_modules/nude-element/* https://cdn.jsdelivr.net/npm/nude-element@0.0.12/:splat 200
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
@@ -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 -.7em hsl(var(--gray) 30%);
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;