diff --git a/demo.js b/demo.js new file mode 100644 index 00000000..72811bf8 --- /dev/null +++ b/demo.js @@ -0,0 +1,76 @@ +import * as huetiful from '../src/index.js'; +import { log } from 'console'; + +// (1. Parsing color tokens to different types +var [colArrWithAlpha, colorObj, namedColor, colorNum, colorHex, sample] = [ + ['rgb', 100, 30, 80, 0.2], + { l: 20, c: 40, h: 80, mode: 'lch' }, + pink, + 6000, + '#fc3ba1', + [ + '#00ffdc', + '#00ff78', + '#00c000', + '#007e00', + '#164100', + '#ffff00', + '#310000', + '#3e0000', + '#4e0000', + '#600000', + '#720000' + ] +]; + +log(huetiful.color2hex(colorObj)); +log(huetiful.num2color(colorNum)); +log(huetiful.toCIE('lab')(namedColor)); +log(huetiful.color2hex(colArrWithAlpha)); +log(huetiful.color2tuple(colorHex, 'oklch')); + +// (2. Fetching swatches from bundled color maps +let swatches = huetiful.tailwindColors('all', '400'); +log(swatches); +// (3. Getting and setting properties + +// Setting luminance +let setLum = huetiful.setLuminance(colArrWithAlpha, 0.5); + +// Check the color's initial luminance +log(huetiful.getLuminance(colArrWithAlpha)); + +log(huetiful.getLuminance(setLum)); + +// (4. Sorting and filtering collections of color + +// sort colors by hue angle in descending order +console.log(huetiful.sortByHue(sample, 'desc')); + +// Filter out colors that have chroma channel below 0.1 +console.log(filterByChroma(sample, 0.1)); + +// (5. Getting the stats of color attributes in a collection + +let [meanHue, meanDistance] = [ + huetiful.getMeanHue(sample, 'lch'), + huetiful.getMeanDistance(sample, 'blue') +]; + +// log the mean hue angle from the collection +log(meanHue); + +// log the mean distance between colors in the collection +log(meanDistance); + +// (6. Method chaining + +// Chaining collection methods +let chain1 = huetiful + .load(sample) + .filterByHue(30, 80) + .sortByHue('desc') + .output(); + +// Chaining color methods we first convert it to a pastel color and then return the color visision deficiency simulation of the color for someone who has trouble seeing red. +let chain2 = huetiful.color(colorHex).pastel().deficiency('red', 0.4); diff --git a/demo/demo.js b/demo/demo.js new file mode 100644 index 00000000..d5622e8f --- /dev/null +++ b/demo/demo.js @@ -0,0 +1,75 @@ +import * as huetiful from '../src/index.js'; +import { log } from 'console'; + +// (1. Parsing color tokens to different types +var [colArrWithAlpha, colorObj, namedColor, colorNum, colorHex, sample] = [ + ['rgb', 100, 30, 80, 0.2], + { l: 20, c: 40, h: 80, mode: 'lch' }, + 'pink', + 6000, + '#fc3ba1', + [ + '#00ffdc', + '#00ff78', + '#00c000', + '#007e00', + '#164100', + '#ffff00', + '#310000', + '#3e0000', + '#4e0000', + '#600000', + '#720000' + ] +]; + +log(huetiful.color2hex(colorObj)); +log(huetiful.num2color(colorNum)); +log(huetiful.color2hex(colArrWithAlpha)); +log(huetiful.color2tuple(colorHex, 'oklch')); + +// (2. Fetching swatches from bundled color maps +let swatches = huetiful.tailwindColors('all', '400'); +log(swatches); +// (3. Getting and setting properties + +// Setting luminance +let setLum = huetiful.setLuminance(colArrWithAlpha, 0.5); + +// Check the color's initial luminance +log(huetiful.getLuminance(colArrWithAlpha)); + +log(huetiful.getLuminance(setLum)); + +// (4. Sorting and filtering collections of color + +// sort colors by hue angle in descending order +console.log(huetiful.sortByHue(sample, 'desc')); + +// Filter out colors that have chroma channel below 0.1 +console.log(huetiful.filterByChroma(sample, 0.1)); + +// (5. Getting the stats of color attributes in a collection + +let [meanHue, meanDistance] = [ + huetiful.getMeanHue(sample, 'lch'), + huetiful.getMeanDistance(sample, 'blue') +]; + +// log the mean hue angle from the collection +log(meanHue); + +// log the mean distance between colors in the collection +log(meanDistance); + +// (6. Method chaining + +// Chaining collection methods +let chain1 = huetiful + .load(sample) + .filterByHue(30, 80) + .sortByHue('desc') + .output(); + +// Chaining color methods we first convert it to a pastel color and then return the color visision deficiency simulation of the color for someone who has trouble seeing red. +let chain2 = huetiful.color(colorHex).pastel().deficiency('red', 0.4); diff --git a/demo/sample.png b/demo/sample.png new file mode 100644 index 00000000..ab1b168e Binary files /dev/null and b/demo/sample.png differ diff --git a/docs/assets/gulpfile.js b/docs/assets/gulpfile.js index f291ad14..07d19d45 100644 --- a/docs/assets/gulpfile.js +++ b/docs/assets/gulpfile.js @@ -63,17 +63,17 @@ export async function xml() { path: ['./xml/'], manageEnv: ApiDocsEnv(srcFile, { previous: { - href: idx > 0 ? `/api/${moduleNames[--idx]}` : '/index.html', - title: idx > 0 ? moduleNames[--idx] : `Return to home page` + href: idx > 0 ? `/api/${moduleNames[idx - 1]}` : '/index.html', + title: idx > 0 ? moduleNames[idx - 1] : `Return to home page` }, next: { href: idx < moduleNames.length - ? `/api/${moduleNames[++idx]}` + ? `/api/${moduleNames[idx + 1]}` : `/api`, title: - idx < moduleNames.length - ? moduleNames[++idx] + idx <= moduleNames.length + ? moduleNames[idx + 1] : `Return to home page` } }), diff --git a/docs/assets/js/docs.cjs b/docs/assets/js/docs.cjs index 4f10db11..407e8f93 100644 --- a/docs/assets/js/docs.cjs +++ b/docs/assets/js/docs.cjs @@ -123,7 +123,6 @@ function generateDocs(source, cb = null) { // Loop through the markdown files for modules function buildDataObject(sourceModule, markupTransform = null) { var time = new Intl.DateTimeFormat('en-US', { - weekday: 'long', month: 'short', day: 'numeric', diff --git a/docs/assets/js/main.js b/docs/assets/js/main.js index 9928506b..6619cac1 100644 --- a/docs/assets/js/main.js +++ b/docs/assets/js/main.js @@ -23,6 +23,8 @@ function setProgress() { progressBar.style.width = width; } +setProgress(); + window.addEventListener('scroll', setProgress); /* Dark/light mode toggle */ diff --git a/docs/assets/pages/api.md b/docs/assets/pages/api.md index 914d5d4d..a0313ba6 100644 --- a/docs/assets/pages/api.md +++ b/docs/assets/pages/api.md @@ -4,13 +4,13 @@ The library is split into individual modules each with functions that have the s ### Modules -- [accessibility](api/accessibility) -- [colors](api/colors) -- [converters](api/converters) -- [filterBy](api/filterBy) -- [generators](api/generators) -- [sortBy](api/sortBy) -- [stats](api/stats) -- [types](api/types) -- [utils](api/utils) -- [wrappers](api/wrappers) +- [accessibility](accessibility) +- [colors](colors) +- [converters](converters) +- [filterBy](filterBy) +- [generators](generators) +- [sortBy](sortBy) +- [stats](stats) +- [types](types) +- [utils](utils) +- [wrappers](wrappers) diff --git a/docs/assets/tailwind.config.js b/docs/assets/tailwind.config.js index cef6284e..b0564eda 100644 --- a/docs/assets/tailwind.config.js +++ b/docs/assets/tailwind.config.js @@ -46,7 +46,6 @@ export default { backdropSepia: ({ theme }) => theme('sepia'), backgroundColor: ({ theme }) => theme('colors'), backgroundImage: { - 'hero-home': 'url(assets/img/night-sky-over-mountains.jpg)', none: 'none', 'gradient-to-t': 'linear-gradient(to top, var(--tw-gradient-stops))', 'gradient-to-tr': diff --git a/docs/assets/xml/layouts/base.njk b/docs/assets/xml/layouts/base.njk index a8bf601a..f744dc5f 100644 --- a/docs/assets/xml/layouts/base.njk +++ b/docs/assets/xml/layouts/base.njk @@ -2,7 +2,7 @@ {% include "partials/head.njk" %} -
+ {% include "partials/navbar.njk" %} {% block content %} {% endblock content %} @@ -60,7 +60,7 @@+