Skip to content

Commit 8b71783

Browse files
authored
Merge branch 'color-js:main' into main
2 parents 62ee351 + 3a96e39 commit 8b71783

39 files changed

+4350
-3680
lines changed

Diff for: README.md

+27-4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ all with sensible defaults
2929
</header>
3030

3131
<section>
32-
32+
3333
## Impact
3434

3535
- Has been used to create demos for several W3C specifications
3636
- Has been used by browsers to test their CSS Color 4/5 implementations
37-
- Over [3 million total npm downloads](https://limonte.dev/total-npm-downloads/?package=colorjs.io)!
37+
- Over [10 million total npm downloads](https://limonte.dev/total-npm-downloads/?package=colorjs.io)!
3838
- Used by several [high impact projects](https://www.npmjs.com/browse/depended/colorjs.io), including [Sass](https://sass-lang.com/), [Open Props](https://open-props.style/), [axe](https://www.deque.com/axe/) accessibility testing engine, and [OddContrast](https://www.oddcontrast.com/) and [CSS HD Gradients](https://gradient.style/) color tools
3939
- Parts of Color.js’s API are used as a testing ground for the design of a [native `Color` object for the Web platform](https://github.com/wicg/color-api).
4040

@@ -72,8 +72,8 @@ import deltaE200 from "https://colorjs.io/src/deltaE/deltaE2000.js";
7272

7373
Warning: To use `import` statements in a browser, your `<script>` needs `type="module"`
7474

75-
Are you old school and prefer to simply have a global `Color` variable?
76-
We’ve got you covered!
75+
Are you old school and prefer to simply have a global `Color` variable?
76+
We’ve got you covered!
7777
Just include the following script in your HTML:
7878

7979
```html
@@ -255,3 +255,26 @@ Color.mix("color(display-p3 0 1 0)", "red", .5);
255255
<p class="read-more"><a href="https://colorjs.io/docs/interpolation.html">Read more about interpolation</a></p>
256256

257257
</section>
258+
259+
<section>
260+
261+
## Other Color.js Initiatives
262+
263+
These are all very experimental and not as polished as Color.js itself, but we are excited about their potential.
264+
265+
### [Color Elements](https://elements.colorjs.io)
266+
267+
This is a set of (currently 10) web components for building color-related apps (the first library of its kind to our knowledge).
268+
It includes things like color pickers, color charts, interactive color scales, and more.
269+
270+
### [Color Apps](https://apps.colorjs.io)
271+
272+
A set of color-related apps, such as color pickers, converters, and more.
273+
274+
### [Color Palettes](https://palettes.colorjs.io)
275+
276+
A research project which aims to analyze designer-created color palettes in a variety of color spaces,
277+
both to document patterns (e.g. what hue names are most popular?)
278+
and to understand what makes aesthetically pleasing color scales.
279+
280+
</section>

Diff for: _build/eleventy.js

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createRequire } from "module";
2+
import { EleventyRenderPlugin } from "@11ty/eleventy";
23
const require = createRequire(import.meta.url);
34
import * as filters from "./filters.js";
45

@@ -24,10 +25,13 @@ export default config => {
2425
config.addFilter(f, filters[f]);
2526
}
2627

28+
config.addPlugin(EleventyRenderPlugin);
29+
2730
return {
2831
markdownTemplateEngine: "njk",
2932
templateFormats: ["md", "njk"],
3033
dir: {
34+
data: "data",
3135
output: ".",
3236
},
3337
};

Diff for: _build/filters.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,13 @@ export function unslugify (slug) {
1212
}
1313

1414
export function number (value, options) {
15-
return value.toLocaleString("en", options);
15+
return value?.toLocaleString("en", options);
16+
}
17+
18+
export function randomNumber (max, min, step) {
19+
step ??= (max - min) / 100;
20+
// Round to nearest power of 10
21+
step = Math.pow(10, Math.floor(Math.log10(step)));
22+
23+
return Math.floor(Math.random() * (max - min + step) / step) * step + min;
1624
}

Diff for: _build/rollup.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ const fnBundles = [
2727
"sourcemap": true,
2828
"exports": "named",
2929
},
30+
{
31+
"file": "dist/color-fn.js",
32+
"format": "esm",
33+
"sourcemap": true,
34+
},
3035
];
3136

3237
// Add minified versions of every bundle

Diff for: assets/css/docs.css

+85-59
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ main {
1111
}
1212

1313
@media (min-width: 1480px) {
14-
position: fixed;
15-
top: 11rem;
16-
right: calc(var(--page-width) + var(--page-margin) + 1em);
17-
width: fit-content;
18-
max-width: calc(var(--page-margin) - 1em);
19-
margin-left: 1em;
20-
21-
@supports (top: max(1em, 1px)) {
22-
top: max(0em, 11rem - var(--scrolltop) * 1px);
14+
--_gap: 1rem;
15+
box-sizing: border-box;
16+
/* Stretch out #toc in the margin, so it can be a container for the sticky list. */
17+
position: absolute;
18+
right: 100%;
19+
height: 100%;
20+
padding-inline: var(--_gap);
21+
max-width: calc(var(--page-margin) - 2 * var(--_gap));
22+
width: max-content;
23+
24+
& > ul {
25+
position: sticky;
26+
top: var(--_gap);
2327
}
2428
}
2529

@@ -50,70 +54,92 @@ main {
5054
}
5155
}
5256

53-
[mv-app="colorSpaces"] {
54-
& [mv-list-item][property="space"] {
55-
display: grid;
56-
grid-template-columns: 1fr auto;
57-
grid-gap: 0 1em;
58-
margin: 1em 0;
57+
#space-tree {
58+
width: 100%;
5959

60-
& .alias-of {
61-
font-style: italic;
62-
}
60+
svg {
61+
width: 100%;
62+
overflow: visible;
63+
}
6364

64-
& > * {
65-
grid-column: 1;
66-
}
6765

68-
& > header {
69-
grid-column: 1 / span 2;
70-
display: flex;
71-
align-items: center;
7266

73-
& h2 {
74-
margin: 0 auto 0 0;
67+
.node text {
68+
font-weight: 500;
69+
font-size: 44px !important;
70+
}
7571

76-
& code {
77-
font-family: var(--font-monospace);
78-
font-weight: bold;
79-
font-size: 70%;
72+
.root text {
73+
font-weight: bold;
74+
font-size: 66px !important;
75+
translate: 0 -10px;
76+
}
77+
}
8078

81-
&::before {
82-
content: "#";
83-
}
84-
}
85-
}
79+
.color-space {
80+
display: grid;
81+
grid-template-columns: 1fr auto;
82+
grid-gap: 0 1em;
83+
margin: 1em 0;
84+
85+
.alias-of {
86+
font-style: italic;
87+
}
88+
89+
> * {
90+
grid-column: 1;
91+
}
92+
93+
> header {
94+
grid-column: 1 / span 2;
95+
display: flex;
96+
align-items: center;
97+
98+
h2 {
99+
margin: 0 auto 0 0;
100+
101+
code {
102+
font-family: var(--font-monospace);
103+
font-weight: bold;
104+
font-size: 70%;
86105

87-
& .file {
88-
font-style: italic;
89-
opacity: .6;
90-
filter: saturate(.1);
106+
&::before {
107+
content: "#";
108+
}
91109
}
92110
}
93111

94-
& [property="description"] {
95-
margin: .5em 0;
112+
& .file {
113+
font-style: italic;
114+
opacity: .6;
115+
filter: saturate(.1);
96116
}
117+
}
97118

98-
& dl {
99-
min-width: 10em;
100-
margin: 0;
101-
grid-row: 2 / span 3;
102-
grid-column: 2;
103-
background: hsl(var(--gray) 95%);
104-
border-radius: .2em;
105-
padding: 1em;
106-
107-
& dt {
108-
margin-top: .5em;
109-
font-size: 80%;
110-
}
119+
.description {
120+
margin: .5em 0;
121+
}
111122

112-
& dd {
113-
grid-column: 1;
114-
}
123+
dl {
124+
align-self: start;
125+
min-width: 10em;
126+
margin: 0;
127+
grid-row: 2 / span 3;
128+
grid-column: 2;
129+
background: hsl(var(--gray) 95%);
130+
border-radius: .2em;
131+
padding: 1em;
132+
133+
> div:not(:first-child) {
134+
margin-block-start: 1em;
115135
}
116-
}
117136

137+
dt {
138+
font-size: 80%;
139+
}
118140

141+
dd {
142+
grid-column: 1;
143+
}
144+
}
119145
}

Diff for: assets/js/docs.js

-68
Original file line numberDiff line numberDiff line change
@@ -82,71 +82,3 @@ function makePageToc (pageToc) {
8282
});
8383
});
8484
}
85-
86-
if (location.pathname.indexOf("/spaces") > -1) {
87-
await Mavo.all.colorSpaceData.dataLoaded;
88-
89-
let docsSpaces = Object.fromEntries(Mavo.all.colorSpaceData.root.data.space.map(space => [space.id, space]));
90-
91-
let spaces = Object.entries(Color.Space.registry).map(([id, space]) => {
92-
let docsSpace = docsSpaces[id];
93-
94-
return Object.assign(docsSpace || {
95-
description: "",
96-
url: "",
97-
}, {
98-
id,
99-
isAlias: space.id != id,
100-
aliasOf: space.id,
101-
aliasOfName: Color.Space.registry[space.id].name,
102-
base: space.base?.id,
103-
baseName: space.base?.name,
104-
name: space.name,
105-
coord: Object.entries(space.coords).map(([id, meta]) => {
106-
let range = meta.range || meta.refRange;
107-
return {
108-
id,
109-
name: meta.name,
110-
min: range?.[0],
111-
max: range?.[1],
112-
};
113-
}),
114-
whitePoint: Object.entries(Color.WHITES).find(([name, white]) => white === space.white)?.[0],
115-
cssId: space.cssId || space.id,
116-
});
117-
});
118-
119-
Mavo.all.colorSpaces.load({
120-
data: {space: spaces},
121-
});
122-
123-
Mavo.hooks.add("getdata-end", function (env) {
124-
if (this.id !== "colorSpaces") {
125-
return;
126-
}
127-
128-
// Do not try to store things we are getting on runtime from ColorSpace.registry
129-
for (let space of env.data.space) {
130-
delete space.coord;
131-
delete space.whitePoint;
132-
}
133-
});
134-
135-
Mavo.all.colorSpaces.dataLoaded.then(() => {
136-
return Mavo.defer(500);
137-
}).then(() => {
138-
$$("pre:not([class])").forEach(pre => {
139-
// Add class now to avoid race conditions where Prism highlights before expressions resolve
140-
pre.classList.add("language-javascript");
141-
Prism.highlightElement(pre);
142-
143-
Notebook.create(pre);
144-
});
145-
});
146-
147-
// if (Mavo.all.colorSpaces && Mavo.all.colorSpaces.root.children.space.children.length > 1) {
148-
// // Data has already rendered, re-render
149-
// Mavo.all.colorSpaces.render(Mavo.all.colorSpaces.getData());
150-
151-
// }
152-
}

Diff for: assets/js/index.js

-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,5 @@ if (location.pathname.indexOf("/docs/") > -1 && window.toc) {
99
import("./docs.js");
1010
}
1111

12-
let root = document.documentElement;
13-
1412
styleCallouts();
1513

16-
document.addEventListener("scroll", evt => {
17-
root.style.setProperty("--scrolltop", root.scrollTop);
18-
}, {passive: true});
File renamed without changes.

Diff for: get/modules.json renamed to data/modules.json

File renamed without changes.

0 commit comments

Comments
 (0)