Git Product home page Git Product logo

hue-radar's Introduction

hue-radar

๐ŸŽจ A tool for discovering all of the colors used in your project.


hue-radar is a CLI tool for discovering all of the colors used in your project.

Purpose

If not maintained well, large and long-running web app projects are likely to have colors littered throughout the codebase. This can make it difficult for your design or front-end team to audit, scale and maintain in the long run. This tool was created to help you identify and wrangle every color in your codebase.

It's sort of like greping for various colors, but better for the following reasons:

  • Handles lots of edge-cases that a complex grep may miss.
  • Supports all color types (eg: hex, hsl, rgb(a)).
  • Presents findings in a normalized and reasonable way.
  • Can produce a comprehensive color audit report for you.

Installation

Note: This has only been tested on NodeJS v12+. It is unlikely to work on versions below this.

Install the tool in your project, or (optionally) you can do it globally.

yarn add hue-radar
npm i hue-radar

# Or globally
npm i -g hue-radar

Usage

Call hue-radar with the options you desire, in the project.

hue-radar -p "*/**.{less,jsx}"

Options

Option Description Default Notes
--pattern, -p Glob pattern for files to match. More info. "**/*.css,!node_modules/**/*" Defaults are always included before these patterns., so specify overrides if these do not suit you.
--debug, -d Print debug statements. false
--format, -f Output format for the color report, json or html json
--output, -o Path to the color report outputted file (optional). hue-radar.report.{format}
--sort-algorithm, -s Algorithm for sorting colors (`distance deltaE`). distance
--convert-to-hex, -h Converts all rgb/hsl colors in the report to hex, for grouping purposes. false You will still see the discovered source color, this just helps group same colors.

Contributing

Feel free to file issues with ideas or questions, or submit pull requests with new features or bugfixes.

When submitting pull requests, at the very least please add unit tests for any new functionality, and follow the code styles set forth in the config.

License

FOSSA Status


โœŒ๏ธ Built by Dave.

hue-radar's People

Contributors

fossabot avatar himynameisdave avatar

Watchers

 avatar  avatar  avatar

Forkers

fossabot jsfix-ci

hue-radar's Issues

Support HSL/HSLA colors

Forgot to include a regex for HSL colors, which should be included before this is published to NPM.

Calculate & group colors based on color difference

It would be very very handy and helpful to sort/group colors together in the final report.

There's a very cool library (called chroma.js) that could help with this. Not sure which of these two methods to use, and how to pass them to a .sort call, but that could be figured out.

If using deltaE, rather than sorting them all based on the difference between each other, create an "anchor" color and then have them all diffed from that, and then sort them based on those numbers. You could use black or white, or perhaps elect one of the colors to be the "anchor" (perhaps the most used color that we discover).

Improve HTML report: Discovery list

The discovery list is fine as it is right now, but could be greatly improved.

  • Make each row expand and display all the discovered lines of code and where we found them.
  • Make the list sortable would be a nice to have.

Improve HTML report: PieChart

The HTML report looks a biiiit janky as is right now. We should look to make the PieChart nicer looking so that is is more useful to the user.

Current state:

Screen Shot 2020-10-23 at 11 43 36 AM

Documentation

Provide a comprehensive documentation to help the user understand how to use.

HTML report

Users should be able to generate an HTML-style report, which would make it easy for users to see which colors are most often used, and where those colors are in their code.

Rough sketch:
IMG_20201021_101316

Add e2e tests

Add some integration/end-to-end tests, to ensure the entire thing works as expected.

This probably entails creating a dummy project and then testing on that.

Add unit tests

Add some unit tests, to ensure that individual components work as expected. Also setup .travis.yml because y the mal not?

Normalize colors to a single format/type

Some colors will appear more than once if they are the same color but in a different format. For example:

rgb(0, 0, 0) == '#000' == '#000000' == 'black'

This means that some results will be verbose if the same color is used in different formats. Luckily there are libraries we can use to convert them:

Note that we'll want to retain the original color in the verbatim string.

This should be configurable with a CLI option:

--color-format hex
--color-format rgb
--color-format rgba

Options should be anything we support, except named CSS colors.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.