Skip to content

Commit

Permalink
Merge pull request #91 from prjctimg/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
prjctimg authored Nov 20, 2023
2 parents bd7e946 + 2b2dffc commit 9770c32
Show file tree
Hide file tree
Showing 67 changed files with 700 additions and 638 deletions.
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run lint


2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
. "$(dirname -- "$0")/_/husky.sh"

# We cant push code that doesn't build.
npm run format
npm run lint && npm run format
26 changes: 9 additions & 17 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "ts-node",
"type": "node",
"request": "launch",
"runtimeExecutable": "node",
"runtimeArgs": [
"--nolazy",
"-r",
"ts-node/register/transpile-only"
],
"cwd": "${workspaceRoot}",
"internalConsoleOptions": "openOnSessionStart",
"skipFiles": [
"<node_internals>/**",
"node_modules/**"
]
}
{
"name": "Launch Program",
"program": "${workspaceFolder}/app.js",
"request": "launch",
"skipFiles": [
"<node_internals>/**"
],
"type": "node"
}
]
}
47 changes: 22 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@

![](./huetiful-logo.png)

#### JavaScript library for general purpose color manipulations.
![Logo](./huetiful-logo.png)

#### JavaScript library for general purpose color manipulations

The aim of this project is to help designers and developers alike work with color more programatically using utilities based on color theory. Though not necessarily a requirement, a basic background of color spaces, properties of color and any other color theory related information will make the library's use cases appear more simpler.

This project is inspired by projects such a [chroma-js](),[colorBrewer.org](),[TailwindCSS]() and borrows some of the reasoning behind them to build functionality. In fact this library uses [Culori]() as its core dependency because it provides a rich API of low level functions written in JavaScript to perform color conversions and other general purpose color manipulations.
This project is inspired by projects such a [chroma-js](https://gka.github.io/chroma.js),[colorbrewer](https://colorbrewer2.org),[TailwindCSS](https://tailwindcss.com) and borrows some of the reasoning behind them to build functionality. In fact this library uses [Culori](https://culorijs.org) as its core dependency because it provides a rich API of low level functions written in JavaScript to perform color conversions and other general purpose color manipulations.

## Getting started

Expand All @@ -19,11 +18,14 @@ Use [npm](https://www.npmjs.com/package/huetiful-js) to install the package.
npm i huetiful-js
```

For use in the browser use [CDN]() to load the package (UMD)
For use in the browser, you can use a CDN [you can use jsdelivr]() to load the library.

```html
https://cdn.jsdelivr.net/npm/huetiful-js/dist/huetiful.min.js

# With script tag

Code sample
<script type='module' src='https://cdn.jsdelivr.net/npm/huetiful-js/dist/huetiful.esm.min.mjs'></script>
```

## Overview
Expand Down Expand Up @@ -76,17 +78,15 @@ console.log(toHex(arrColorWithAlpha))

Note that toHex takes any color format and returns the hex string represantation of it:


We can even mix different color formats with no problem at all:


For more information on the color spaces supported by the library and the expected ranges, checkout the [Color Spaces page on the Culori docs]() . Or checkout the library's [Color conversions]() page.
For more information on the color spaces supported by the library and the expected ranges, checkout the [Color Spaces page on the Culori docs](https://culorijs.org/color-spaces) . Or checkout the library's [Color conversions](https://huetiful-docs.vercel.app/blog/color-spaces-and-converters) page.

> All the functions are internally guarded by `toHex()` so you don't have to worry about converting colors back and fourth.
#### Tailwind colors

As a starting point the library comes along with the default [TailwindCSS]() palette included.. This helps you get started easier when you're using [palette functions]() such as `hueShift()` and `earthtone()`
As a starting point the library comes along with the default TailwindCSS palette included.. This helps you get started easier when you're using [palette functions](https://huetiful-docs.vercel.app/blog/palette-utilities) such as `hueShift()` and `earthtone()`

The Tailwind colors are in the form of two wrapper functions that both take the same parameters but with a few differences: one is curried by default and the other is a tweaked variant of the same functionality but with a few improvements. Below are some examples showing the differences between the two functions:

Expand Down Expand Up @@ -154,7 +154,7 @@ The library has functions for sorting and filtering colors using their property

#### Sorting colors

Below is an example of sorting colors by the relative luminance as defined by [WCAG 2.0]().
Below is an example of sorting colors by the relative luminance as defined by WCAG 2.0.
> Note that you can specify the order as either ascending (`asc`) or descending (`desc`). The default is ascending. :
```js
Expand Down Expand Up @@ -202,7 +202,7 @@ console.log(sortedDescending)

#### Filtering colors

Below is an example of filtering colors by their hue angle. The function uses LCH internally because its more perceptually uniform than HSL. [George Francis explains this phenomena in detail here.]()
Below is an example of filtering colors by their hue angle. The function uses LCH internally because its more perceptually uniform than HSL. [George Francis explains this phenomena in detail here.](https://tympanus.net/codrops/2021/12/07/coloring-with-code-a-programmatic-approach-to-design/)

```js
let sample = [
Expand Down Expand Up @@ -235,13 +235,11 @@ console.log(filterByHue(sample, '<=100')
// [ '#ffff00', '#310000', '#3e0000', '#4e0000', '#600000', '#720000' ]

```
[See more about the parameter types and other sorting/filtering functions]()

[See more about the parameter types and other filtering functions](https://huetiful-docs.vercel.app/blog/sorting-color)

### Palette functions

A small collection of simple palette functions are included in the library. One of my favourites is the `hueShift()` (as a color becomes lighter, its hue shifts up and darker when its hue shifts down. ) , function which was inspired by (special thanks) [George Francis's implementation in this post]()

A small collection of simple palette functions are included in the library. One of my favourites is the `hueShift()` (as a color becomes lighter, its hue shifts up and darker when its hue shifts down. ) .
```js
import { hueShift } from "huetiful-js";

Expand All @@ -264,7 +262,6 @@ console.log(hueShiftedPalette);

There's more where that came from. [See the palettes page]()


### Predicates

Is this color cool or warm, is it achromatic (grayscale) or chromatic? Though its easy to tell colors apart visually when they're displayed on the screen it can be a bit confusing to tell colors apart using code. Below is an example of demonstrating how to determine if a color is gray or not:
Expand Down Expand Up @@ -391,28 +388,28 @@ console.log(getFarthestHue('lime', sample, 'lch'))

```



## What's next

The list of functions goes on beyond this. And since the library is pure JavaScript, you can hook it up with your creative coding library of choice like [p5js]() or [runejs](). The possibilities are limited by the imagination of the user.
The list of functions goes on beyond this. And since the library is pure JavaScript, you can hook it up with your creative coding library of choice like p5js or runejs. The possibilities are limited by the imagination of the user.

For an introduction to terminology used in color checkout this guide on my blog.

[See the full docs here]()

[See the full docs here](https:huetiful-docs.vercel.app)

## Need help ?

See some unexpected results? [Checkout our issue tracker]() to open an issue or search for the problem to see if your issue already exists
See some unexpected results? [Check the issue tracker](https://github.com/prjctimg/huetiful/issues) to open an issue or search for the problem to see if your issue already exists or has been resolved.

Would like to join the chat and share ideas and suggestions ? [See our discussions]() for the open topics.
Would like to join the chat and share ideas and suggestions ? [See the discussions and just say hi, or share a coding meme(whatever breaks the ice)](https://github.com/prjctimg/huetiful/discussions)

## Contributing

First of all, thank you for using huetiful-js! Its people like you that make open source software better for the community!
Contributions are welcome! Help make this project better and easier to use for other developers by sharing your ideas and stomping out bugs and feature suggestions. Please see the [CONTRIBUTING](./CONTRIBUTING.md) file for more information on how to get started.

## References

[Coloring with code: A programmatic approach by George Francis](https://tympanus.net/codrops/2021/12/07/coloring-with-code-a-programmatic-approach-to-design/)

> ## License
>
> Copyright (c) 2023
Expand Down
34 changes: 8 additions & 26 deletions build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// eslint-disable-next-line no-undef
var { build } = require('esbuild');

var { dependencies } = require('./package.json')


const sharedConfig = {
Expand All @@ -31,7 +31,7 @@ build({
format: 'esm',
outfile: 'dist/filterBy/index.esm.mjs',

platform: 'neutral'

});

// sortBy/ import
Expand All @@ -49,16 +49,8 @@ build({
format: 'esm',
entryPoints: ['.//src/colors/index.ts'],
outfile: 'dist/colors/index.esm.mjs',

});

// fp/ import
build({
...sharedConfig,
format: 'esm',
entryPoints: ['.//src/fp/index.ts'],
outfile: 'dist/fp/index.esm.mjs'
});

// core-utils/ import
build({
Expand All @@ -69,19 +61,15 @@ build({

});

//Bundled CJS minified
build({
...sharedConfig,
outfile: 'dist/huetiful.min.cjs',
minify: true,

});

//Bundled ESM
build({
...sharedConfig,
external: Object.keys(dependencies),
format: 'esm',
outfile: 'dist/huetiful.esm.mjs'
outfile: 'dist/huetiful.esm.mjs', minifySyntax: true,

});

//Bundled ESM minified
Expand All @@ -94,19 +82,13 @@ build({
});

//Bundled IIFE
build({
...sharedConfig,
format: 'iife',
outfile: 'dist/huetiful.js',
globalName: 'huetiful',
minify: false
});

//Bundled IIFE minified
build({
...sharedConfig,
format: 'iife',
outfile: 'dist/huetiful.min.js',
globalName: 'huetiful',
minify: true

});


31 changes: 19 additions & 12 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Changelog
Some of the major notable changes in the past releases.Please note that the list of changes is not final and is still a work in progress. More information will be updated from the Git commit history.


### v0.0.5

First publish, lots of broken code. Basically nothing worked well in this release. Deprecated
Expand Down Expand Up @@ -30,18 +34,21 @@ Changed docs to docsify

### 1.8.0 (stable)

Fully treeshakable
Added the `load()` to create read-manipulate-output chains like the one presented by the `chroma()` in chroma-js
Added the `toHex` utility which parses all known color tokens similar to chroma-js
Eliminated dependancy on lodash.
Used treeshaken Culori modules to reduce bundle size. Only 20KB when minified!
Created the `fp` directory with helpe functions used in the library grouped by input type
More modular codebase
Simplified code to make it more readable and easier to understand for other developers who may want to contribute
- Fully treeshakable
- Core-utils directory was split to submodules.
- Added the `load()` to create read-manipulate-output chains like the one presented by the `chroma()` constructor in chroma-js
- Added the `toHex` utility which parses all known color tokens similar to chroma-js
- Eliminated dependancy on lodash.
- Used treeshaken Culori modules to reduce bundle size. Only 20KB when minified!
- Created the `fp` directory with helper functions used in the library grouped by input type.
- More modular codebase
- Simplified code to make it more readable and easier to understand for other developers who may want to contribute
Over 50 utilities in the API now!
All palette functions have easings for internal computations
- All palette functions have easings for internal computations
Updated the docs!
Added introduction guides to help users understand the project
Rewrote the README and CONTRIBUTING. Added missing licenses for borrowed code.
Special thanks to [contributors]
- Improved the accuracy of temperature based utilities.
- All palette functions now take an optional overrides object to fine tune parameters like easing methods, fixups etc.
- Added introduction guides to help users understand the project
- Rewrote the README and CONTRIBUTING. Added missing licenses for borrowed code.
Special thanks to our [contributors!]()

2 changes: 1 addition & 1 deletion guides/palettes.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Palettes

A small collection of functions to help you kickstart your designs using mostly just a single base color and a few adjustable built-n parameters. All palette functions use `easingSmootherstep()` easing under the hood to ease certain values on channels being worked with.
A small collection of functions to help you kickstart your designs using mostly just a single base color and a few adjustable built-in parameters. All palette functions use `easingSmoothstep()` easing under the hood to ease certain values on channels being worked with.

Because certain end results are easier to achieve in different color spaces, colors are converted to a mode that is suited for the desired and result. For example pastel colors have a high `value` and low `saturation` there are easier to compute in the HSV color space. But for the most part colors are converted to LCH and then returned as optional hex strings or plain color objects.

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 15 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "huetiful-js",
"version": "1.7.5",
"version": "1.7.6",
"type": "module",
"main": "./dist/huetiful.cjs",
"module": "./dist/huetiful.esm.mjs",
"browser": "./dist/huetiful.min.js",
"exports": {
"./fp": "./dist/fp/index.esm.mjs",
"./core-utils": "./dist/core-utils/index.esm.mjs",
"./getters_and_setters/index.esm.mjs": "./dist/getters_and_setters/index.esm.mjs",
"./converters": "./dist/converters/index.esm.mjs",
"./palettes": "./dist/palettes/index.esm.mjs",
"./filterBy": "./dist/filterBy/index.esm.mjs",
"./sortBy": "./dist/sortBy/index.esm.mjs",
Expand Down Expand Up @@ -50,15 +50,24 @@
"dist",
"src"
],
"repository": "github:prjctimg/huetiful",
"repository": {
"type": "git",
"url": "git+https://github.com/prjctimg/huetiful.git"
},
"keywords": [
"lch",
"palette",
"palettes",
"color schemes",
"color",
"culori",
"gradients",
"tailwind"
"tailwind",
"cielab",
"rgb",
"hsl",
"hsv",
"colorbrewer",
"tailwindcss"
],
"author": "Dean Tarisai",
"email": "[email protected]",
Expand Down
Loading

0 comments on commit 9770c32

Please sign in to comment.