GithubHelp home page GithubHelp logo

mir4a / colorfast Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 1.35 MB

Tool which helps developers to manage color schemas in projects by gathering and representing all colors in project files.

Home Page: https://www.mir4a.pp.ua/colorfast/

License: ISC License

JavaScript 37.85% TypeScript 57.02% CSS 5.13%
color-scheme color colors colorscheme colorschemes color-palette tool developer-tools stylesheets stylesheet

colorfast's Introduction

According to LEXICO colorfast is:

Dyed in colors that will not fade or be washed out.

In fact, this tool will help developers to vanish all extra colors in a project which supposed to be the same as color schema, but went uncontrollable during development. Once I saw a project which had clear and strict color schema of about 16 colors, but it turned out that project files contain over 200 variations of origin schema. This is why Colorfast was made.

colorfast

Installation

npm install --save-dev colorfast

Usage

CLI

npx colorfast --input ./path/to/styles/directory --scheme ./path/to/sass/variables --report ./path/where/to/save/report

API

See full documentation here

Gather colors info

Default function is gathering colors info from the given styles path and returns ColorMap

import colorfast from "colorfast";

const colorMap = colorfast(stylesDirPath, pathToSassVariables);

Helpers and algorithms

  1. Sorting colors

Simple insertion sort is using for sorting array of colors by their index (hex value).

import { insertionSortForColors } from "colorfast";

const unsortedColors = ["#fff", "rgb(0, 0, 0)", "#336699"];
const sortedColors = insertionSortForColors(unsortedColors); // ["rgb(0, 0, 0)", "#336699", "#fff"]
  1. Color helpers

Range of helpers for converting different color format to HEX and get color index.

import { convertRGBtoHEX, getColorIndex, getHEXValue, fullHEX } from "colorfast";

convertRGBtoHEX("rgb(0, 0, 0)"); // "#000"
convertRGBtoHEX("rgba(0, 0, 0, 0.5)"); // "#000"
convertRGBtoHEX("rgba(0, 0, 0, 0.5, 0)"); // ""

getColorIndex("rgb(255, 255, 255)"); // 16777215
getColorIndex("#000"); // 0

getHEXValue("#fff"); // 16777215

fullHEX("#fff"); // #ffffff
fullHEX("#369"); // #336699

colorfast's People

Contributors

dependabot[bot] avatar mir4a avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

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.