6.0.1 • Published 21 days ago

color-sorter v6.0.1

Weekly downloads
324
License
MIT
Repository
github
Last release
21 days ago

color-sorter

Color sorter

Sort CSS colors by hue, then by saturation. Black-grey-white colors (colors with 0% saturation) are shifted to the end. Fully transparent colors are placed at the very end.

This sorting algorithm is very opinionated and might not fit your needs!

Usage

import { sortFn, sort } from "color-sorter";
var colors = ["#000", "red", "hsl(0, 10%, 60%)"];
var sorted = colors.sort(sortFn);
// Or:
// sorted = sort(colors)

// => sorted:
// [
//  'red',
//  'hsl(0, 10%, 60%)',
//  '#000'
// ]

Want to try it out?

Examples

These examples can be seen on Project Wallace where this package is used for sorting the colors.

CSS-Tricks

CSS Tricks color sort example

Smashing Magazine

Smashing Magazine color sort example

Bootstrap

Bootstrap color sort example

Zurb Foundation

Zurb Foundation color sort example

Project Wallace

Project Wallace color sort example

Related projects

  • CSS Analyzer - Generate analysis for a string of CSS
  • Wallace - CLI tool for @projectwallace/css-analyzer
  • Constyble - A CSS complexity linter, based on css-analyzer. Don't let your CSS grow beyond the thresholds that you provide.

License

MIT © Bart Veneman

6.0.1

21 days ago

6.0.0

10 months ago

5.0.3

2 years ago

5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.0.1

4 years ago

4.0.0

5 years ago

3.0.0

5 years ago

2.2.1

6 years ago

2.2.0

6 years ago

2.1.0

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago