npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lessly

v0.2.4

Published

Less functions without less

Downloads

19

Readme

Less Standalone Functions Build Status

Use less color functions without less.

NPM

Installation

% npm install lessly

Usage

Lessly is a hack around the color manipulation functions in Less.

import {fade} from 'lessly';

fade('red', .9);
// outputs rgba(255, 0, 0, 0.9)

Alternatively, you can pass in any entity string that less would normally process.

import lessly from 'lessly';

lessly('fade(red, .9)');
// outputs rgba(255, 0, 0, 0.9)

These operations happen recursively, so feel free to use any less color function.

import lessly from 'lessly';

lessly('red(fade(red, .9))');
// outputs 255

Lessly will also crawl objects and parse each value

lessly({
    myRule: 'fade(red, 90%)'
});
// 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

import lessly from 'lessly';

lessly('fade(@mycolor, .9)', {mycolor: 'blue'});
// outputs rgba(0, 0, 255, 0.9)

In keeping the React style convention, we'll also check camel case variables against dash variables.

import lessly from 'lessly';

lessly('fade(@my-color, .9)', {myColor: 'blue'});
// outputs rgba(0, 0, 255, 0.9)

Themes

If you have an existing color configuration, we can bind these vars to all lessly calls.

import {theme} from 'lessly';

const lesslyTheme = theme({myColor: 'blue'});

lesslyTheme('fade(@my-color, .9)');
// outputs rgba(0, 0, 255, 0.9)

lesslyTheme.fade('@my-color', .9);
// outputs rgba(0, 0, 255, 0.9)

Dimensions

Dimensions made easy - basic operations are free too!

import {dimension} from 'lessly'; // or dim for short


dimension(10, 'px');
// outputs 10px

dimension('10px', 'px');
// outputs 10px

dimension('10px + 10');
// outputs 20px

dimension('10px -' , 5);
// outputs 5px

dimension('10px' , ' * 10');
// outputs 100px

dimension(10 , ' + 10px');
// outputs 20px

Lessly will also parse what looks like dimensions

lessly('10px + 10');
// outputs 20px

We'll also recurse any object and apply operations to child values

import {dimension} from 'lessly'; // or dim for short


dimension({
    myRule: 10
}, 'px');
// outputs {myRule: '10px'}

dimension({
    myRule: 10
}, '+ 10px');
// outputs {myRule: '20px'}

There's also handy shortcuts for every css unit.

import {px, percent, inch, mm, vh, vw, rad, pt, cm} from 'lessly';

px(10);
// outputs 10px

percent(10);
// outputs 10%

inch(10);
// outputs 10in

mm(10);
// outputs 10mm

vh(10);
// outputs 10vh

vw(10);
// outputs 10vw

rad(10);
// outputs 10rad

pt(10);
// outputs 10pt

cm(10);
// 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.