Socket
Socket
Sign inDemoInstall

color-sorter

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

color-sorter

Sort colors by hue, then saturation.


Version published
Weekly downloads
4K
increased by0.73%
Maintainers
1
Weekly downloads
 
Created
Source

color-sorter

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

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

Usage

const sortColors = require('color-sorter');

const colors = [
  { value: '#000' },
  { value: 'red' },
  { value: 'hsl(0, 10%, 60%)' }
];

const sorted = sortColors(colors);

// => sorted:
// [
//  { value: 'red' },
//  { value: 'hsl(0, 10%, 60%)' },
//  { value: '#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

CSS Tricks color sort example

Bootstrap

CSS Tricks color sort example

Foundation

CSS Tricks color sort example

Project Wallace

CSS Tricks color sort example

Keywords

FAQs

Package last updated on 23 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc