Giter Club home page Giter Club logo

Comments (7)

makepanic avatar makepanic commented on May 17, 2024 2

There is already a handelbars helper called hex2rgb which returns the incoming hex string as an {r, g, b} object. (It's nearly the same as the inkscape template)

You basically have to call the helper on each color.hex and put the result where you want it to be (in the .css template file).

I could do it if nobody else wants to take this issue.

from open-color.

sairion avatar sairion commented on May 17, 2024 1

we can use https://github.com/sindresorhus/hex-rgb

from open-color.

sairion avatar sairion commented on May 17, 2024

Hi! That seems to be great idea, even though I'm not familiar with new css custom props. Currently Open color is being automatically generated from configuration file (https://github.com/yeun/open-color/blob/master/open-color.json) and they are described as HEX values, so it needs to be converted while they are generated. (https://github.com/yeun/open-color/blob/master/compile-templates.js) I'll take a look when I'll have time, but of course you can submit PR if you want. Thanks for suggestion 😄

from open-color.

lukasoppermann avatar lukasoppermann commented on May 17, 2024

Hey, great, it should be pretty easy. This works fine and gives you an array with the rgb values.

const hexToRgb = hex =>
  hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i
             ,(m, r, g, b) => '#' + r + r + g + g + b + b)
    .substring(1).match(/.{2}/g)
    .map(x => parseInt(x, 16))

Usage e.g.:

console.log(hexToRgb("#0033ff")) // [0, 51, 255]

source: http://stackoverflow.com/questions/5623838/rgb-to-hex-and-hex-to-rgb

CSS Custom properties is the official name for css variables, as use in https://github.com/yeun/open-color/blob/master/open-color.css

from open-color.

lukasoppermann avatar lukasoppermann commented on May 17, 2024

Even better.

from open-color.

lukasoppermann avatar lukasoppermann commented on May 17, 2024

@makepanic I will not get to it soo, so if you could do it that would be great.

from open-color.

sairion avatar sairion commented on May 17, 2024

@makepanic Oh, I haven't noticed. Please work on, if you don't mind 😄

from open-color.

Related Issues (20)

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.