projectwallace/color-sorter
projectwallace/color-sorter has 80 GitHub stars and 3 forks. Star changes are not measured yet. Last checked 2026-11-14 06:43 UTC. Last push 2026-11-01.
Crecimiento de estrellas medido
- in 24h
- Recopilando historial
- in 7 days
- Recopilando historial
- in 15 days
- Recopilando historial
- in 1 month
- Recopilando historial
Cambios netos en períodos que se solapan, no totales diarios. Los datos no disponibles se dejan en blanco. Las estrellas indican interés, no calidad.
Acerca de
Sort CSS colors by hue, then by saturation
DatosREADME.md
Originalcolor-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 { sort_fn, sort } from '@projectwallace/color-sorter'
var colors = ['#000', 'red', 'hsl(0, 10%, 60%)']
var sorted = colors.sort(sort_fn)
// Or:
// sorted = sort(colors)
// => sorted:
// [
// 'red',
// 'hsl(0, 10%, 60%)',
// '#000'
// ]
API
convert
Convert any CSS color to a color that we can use for comparison. Returns black in case parsing fails.
import { convert } from '@projectwallace/color-sorter'
const color = convert('#f00')
// => { hue: 0, saturation: 100, lightness: 50, alpha: 1, authored: '#f00' }
compare
Compare two converted colors to know where they must go while sorting.
import { convert, compare } from '@projectwallace/color-sorter'
const red = convert('rgb(255 0 0)')
const green = convert('#0f0')
const result = compare(red, green)
// => result < 0, making sure red ends up before green
color_group
Get the named group of a given color. Useful for making groups of colors.
import { color_group, convert } from '@projectwallace/color-sorter'
const color = convert('rgb(255 0 0)')
const group = color_group(color) // => 'red'
sort_fn
Callback sorting function that can be passed to a .sort() or toSorted(). Uses compare internally.
import { sort_fn } from '@projectwallace/color-sorter'
const sorted = ['rebeccapurple', '#f00'].toSorted(sort_fn)
//=> ['#f00', 'rebeccapurple']
Project rename
Prior to v9 this project was published as color-sorter. From v9 onwards it is published as @projectwallace/color-sorter.
Related projects
- CSS Analyzer - Generate analysis for a string of CSS
- Wallace CLI - CLI tool for @projectwallace/css-analyzer
- CSS Design Tokens - Create Design Tokens by going through CSS to find colors, font-sizes, gradients etcetera and turn them into a Design Tokens spec-compliant token format.
License
MIT © Bart Veneman
Explorar proyectos relacionados
Asabeneh/30-Days-Of-Python
El reto de programación 30 Days of Python es una guía paso a paso para aprender el lenguaje de programación Python en 30 días. Este reto puede llevar más de 100 días. Sigue tu propio ritmo. Estos vídeos también pueden ayudarte: https://www.youtube.com/channel/UC7PNRuno1rzYPb1xLa4yktw
78,718 estrellasgrafana/grafana
Plataforma abierta y componible de observabilidad y visualización de datos. Visualiza métricas, registros y trazas de múltiples fuentes, como Prometheus, Loki, Elasticsearch, InfluxDB, Postgres y muchas más.
77,897 estrellasredis/redis
Para los desarrolladores que crean aplicaciones en tiempo real basadas en datos, Redis es la opción preferida, la más rápida y la de más funciones como caché, servidor de estructuras de datos y motor de consultas de documentos y vectores.
77,491 estrellasapache/superset
Apache Superset es una plataforma de visualización y exploración de datos.
75,523 estrellas