LESS: darken () for current color

I want to call the LESS function darken()for any current color (I do not have the current color in any variable). Is it possible?

+4
source share
1 answer

according to request for seven phases max; in your node backend let say express

var less = require('less'); //also the body parser, express, etc

....

from your page you make an asynchronous request with the actual color of your page, just grab it by js and make a request. then in the expression:

app.post('/whateveryourroute', function(req, res) {
    var colorFromReq = req.body.color;
    less.render('.class { color: darken(`colorFromReq`, 20%) }', function (e, css) {
      res.header("Content-type", "text/css");
      res.send(css);
    });
});

Something like this would be, not tested, but possible.

0
source

All Articles