JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3482
  • Score
    100M100P100Q126178F
  • License MIT

Sort colors in a visually pleasing way.

Package Exports

  • color-sorter

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (color-sorter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

color-sorter

NPM Version Build Known Vulnerabilities Dependencies Status Dependencies Status XO code style Project: Wallace

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

var colorSort = require('color-sorter')
var colors = ['#000', 'red', 'hsl(0, 10%, 60%)']
var sorted = colors.sort(colorSort.sortFn)
// Or: 
// sorted = colorSort(colors)

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

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

  • 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