Less Standalone Functions
Use less color functions without less.
Installation
% npm install lessly
Usage
Lessly is a hack around the color manipulation functions in Less.
; ;// outputs rgba(255, 0, 0, 0.9)
Alternatively, you can pass in any entity string that less would normally process.
; ;// outputs rgba(255, 0, 0, 0.9)
These operations happen recursively, so feel free to use any less color function.
; ;// outputs 255
Lessly will also crawl objects and parse each value
;// outputs {myRule: 'rgba(255, 0, 0, 0.9)'}
Variables
For entity parsing, you can pass in variables to be swapped out with a params object
; ;// outputs rgba(0, 0, 255, 0.9)
In keeping the React style convention, we'll also check camel case variables against dash variables.
; ;// outputs rgba(0, 0, 255, 0.9)
Themes
If you have an existing color configuration, we can bind these vars to all lessly calls.
; const lesslyTheme = ; ;// outputs rgba(0, 0, 255, 0.9) lesslyTheme;// outputs rgba(0, 0, 255, 0.9)
Dimensions
Dimensions made easy - basic operations are free too!
; // or dim for short ;// outputs 10px ;// outputs 10px ;// outputs 20px ;// outputs 5px ;// outputs 100px ;// outputs 20px
Lessly will also parse what looks like dimensions
;// outputs 20px
We'll also recurse any object and apply operations to child values
; // or dim for short ;// outputs {myRule: '10px'} ;// outputs {myRule: '20px'}
There's also handy shortcuts for every css unit.
; ;// outputs 10px ;// outputs 10% ;// outputs 10in ;// outputs 10mm ;// outputs 10vh ;// outputs 10vw ;// outputs 10rad ;// outputs 10pt ;// outputs 10cm
Further Documentation
Check out the less color definition functions. Every color definition function is supoorted.
The function list with sample arguments is available at test/functions.js
.
lessly is free software under the MIT license. It was created in sunny Santa Monica by Matthew Drake.