diff --git a/lib/collection.ts b/lib/collection.ts index ba4cb510..1328ad0e 100644 --- a/lib/collection.ts +++ b/lib/collection.ts @@ -327,45 +327,54 @@ function sortBy( * @param collection The property you want to distribute to the colors in the collection for example `hue | luminance` * @param options Optional overrides to change the default configursation */ -// function distribute< -// Iterable extends Collection, -// Options extends DistributionOptions, -// >(collection: Iterable, options?: Options): Collection { -// // Destructure the opts to check before distributing the factor -// let { -// extremum, -// excludeSelf, -// excludeAchromatic, -// colorspace, -// hueFixup, -// factor, -// } = or(options, {}) as Options; -// // Set the extremum to distribute to default to max if its not min -// extremum = or(extremum, "max"); - -// // Exclude the colorToken with the specified factor extremum being distributed -// excludeSelf = or(excludeSelf, false); - -// // Exclude achromatic colors from the manipulations. The colors are returned in the resultant collection -// excludeAchromatic = or(excludeAchromatic, false); - -// // The fixup to use when tweaking the hue channels -// // @ts-ignore -// hueFixup = factor === "hue" -// ? hueFixup === "longer" ? fixupHueLonger : fixupHueShorter -// : null; -// colorspace = or(colorspace, "lch"); -// const facts: { [K in Factor] } = { -// hue: "h", -// lightness: mcchn("l", colorspace), -// chroma: mcchn("c", colorspace), -// distance: 0, -// luminance: 0, -// contrast: 0, -// }; -// // v is expected to be a color object so that we can access the color's hue property during the mapping -// // set the callbacks depending on the type of factorStats -// } +function distribute< + Iterable extends Collection, + Options extends DistributionOptions, +>( + collection: Iterable, + options?: Options, +): Collection { + // Destructure the opts to check before distributing the factor + let { + extremum, + excludeSelf, + excludeAchromatic, + colorspace, + hueFixup, + factor, + } = or(options, {}) as Options; + // Set the extremum to distribute to default to max if its not min + extremum = or(extremum, "max"); + + // Exclude the colorToken with the specified factor extremum being distributed + excludeSelf = or(excludeSelf, false); + + // Exclude achromatic colors from the manipulations. The colors are returned in the resultant collection + excludeAchromatic = or( + excludeAchromatic, + false, + ); + + // The fixup to use when tweaking the hue channels + // @ts-ignore + hueFixup = + factor === "hue" + ? hueFixup === "longer" + ? fixupHueLonger + : fixupHueShorter + : null; + colorspace = or(colorspace, "lch"); + const facts: { [K in Factor] } = { + hue: "h", + lightness: mcchn("l", colorspace), + chroma: mcchn("c", colorspace), + distance: 0, + luminance: 0, + contrast: 0, + }; + // v is expected to be a color object so that we can access the color's hue property during the mapping + // set the callbacks depending on the type of factorStats +} /** * Filters a collection of colors using the specified `factor` as the criterion. diff --git a/www/package.json b/www/package.json index 38af8a85..cd4c42b7 100644 --- a/www/package.json +++ b/www/package.json @@ -10,9 +10,9 @@ "@docusaurus/core": "3.5.2", "@docusaurus/preset-classic": "3.5.2", "@mdx-js/react": "^3.0.0", - "clsx": "^2.0.0", - "docusaurus-lunr-search": "^3.5.0", - "prism-react-renderer": "^2.3.0", + "clsx": "2.0.0", + "docusaurus-lunr-search": "3.5.0", + "prism-react-renderer": "2.3.0", "react": "18.0.0", "react-dom": "18.0.0" }, @@ -23,20 +23,20 @@ }, "devDependencies": { "@docusaurus/module-type-aliases": "3.5.2", - "@docusaurus/plugin-google-tag-manager": "^3.5.2", - "@docusaurus/plugin-pwa": "^3.5.2", - "@docusaurus/plugin-sitemap": "^3.5.2", - "@docusaurus/theme-search-algolia": "^3.5.2", + "@docusaurus/plugin-google-tag-manager": "3.5.2", + "@docusaurus/plugin-pwa": "3.5.2", + "@docusaurus/plugin-sitemap": "3.5.2", + "@docusaurus/theme-search-algolia": "3.5.2", "@docusaurus/tsconfig": "3.5.2", "@docusaurus/types": "3.5.2", - "commitizen": "^4.3.0", - "cz-emoji-conventional": "^1.0.2", - "docusaurus-plugin-typedoc": "^1.0.5", - "typedoc": "^0.26.4", - "typedoc-plugin-frontmatter": "^1.0.0", + "commitizen": "4.3.0", + "cz-emoji-conventional": "1.0.2", + "docusaurus-plugin-typedoc": "1.0.5", + "typedoc": "0.26.4", + "typedoc-plugin-frontmatter": "1.0.0", "typedoc-plugin-markdown": "4.2.0", - "typedoc-plugin-remark": "^1.0.2", - "typescript": "~5.5.2", - "unified-prettier": "^2.0.1" + "typedoc-plugin-remark": "1.0.2", + "typescript": "5.5.2", + "unified-prettier": "2.0.1" } }