Socket
Socket
Sign inDemoInstall

color-sorter

Package Overview
Dependencies
1
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    color-sorter

Sort colors in a visually pleasing way.


Version published
Weekly downloads
2.8K
decreased by-26.1%
Maintainers
1
Install size
127 kB
Created
Weekly downloads
 

Readme

Source

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?

  • Stackblitz example with ESM
  • Stackblitz example with CommonJS

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

Keywords

FAQs

Last updated on 16 Apr 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc