Giter Site home page Giter Site logo

stuneak / create-color Goto Github PK

View Code? Open in Web Editor NEW
54.0 0.0 1.0 677 KB

A tiny (565 B) JavaScript library to generate permanent color from any string, array or object.

License: MIT License

JavaScript 100.00%
color color-picker colorpicker generate-color stringtocolor

create-color's Introduction

Create color

npm version

A tiny (565 B) JavaScript library to generate permanent color from any string, array or object.

DEMO. Open in CodeSandbox

Install

npm install create-color
// or
yarn add create-color

Usage

const createColor = require("create-color");
// or
import createColor from "create-color";
// format by default: hex
const hex = createColor("canThereBeAnyText"); // => "#67cb22"
// from string
const hsl = createColor("canThereBeAnyText", { format: "hsl" }); // => "hsl(96,71%,46%)"

// from object
const hex = createColor(
  { name: "Andrey", age: 27, role: "user" },
  { format: "hex" }
); // => "#f6555d"

// from array
const rgb = createColor(["random", "color", "generation"], { format: "rgb" }); // => "rgb(218,179,136)"

create-color's People

Contributors

dependabot[bot] avatar meme-content avatar stuneak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mylocalcode

create-color's Issues

Some strings return invalid hex values

tl;dr

Some strings return invalid hex values ๐Ÿคทโ€โ™‚

More Details

I'm using user.id's to generate color values. These are uuid's and generally look like 9fc91124-0c99-48f8-863e-49f173ead3f7 as you'd expect. This is typically fine- and causes no issues. However, some uuid's return invalid hex values (like the one I'm using here).

import createColor from "create-color";

const background = createColor("9fc91124-0c99-48f8-863e-49f173ead3f7");

Demo

I've done a tiny amount of work to reproduce the issue, but not enough to understand the problem. Here's a demo with some of the evil strings.

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.