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

colorscss

v0.1.7

Published

Color themes tool for SASS

Downloads

3

Readme

Tool created for provide SASS color themes functionality in a handy way, allow to having separate *.scss file for each theme, but without generating multiple CSS files as an output. All theme-related styles are injected in the main stylesheet, so you can switch themes by simply change the HTML container class, without loading another CSS file.

This is implementation of the idea from http://www.sitepoint.com/sass-theming-neverending-story/ article. It may be a good solution, when you have got just a few color variants in your app, and it's great when you have to switch them on the fly.

Note: was tested with Node v6.5.0.

Instalation

$ npm install colorscss --save-dev

Setup

You can require module in your Gulpfile or any other JS file which will be executed by Node.js (by running $ node file.js e.g. from npm scripts, watch-run, webpack-shell-plugin).

const colorscss = require('colorscss');

In this file, call colorscss function generate() with arguments as listed in example below.

colorscss.generate({
    input: [
        {theme1_name_key: './themes_path/theme1.scss'},
        {theme2_name_key: './themes_path/theme2.scss'}
    ],
    output: './themes_path/generated_multitheme_file.scss'
});

Usage

####1.

Every input SASS file should contains the same color variables set, declared as color literals, hex values, color functions like rgba(), lighten(), darken(), or reference to a previous variable:

$var1: black;
$var2: rgba(#333, 0.5);
$var3: #F0F0F0;
$var4: lighten($var1, 20);

####2.

Generated output (which is also *.scss file) should be imported in your SASS stylesheet and be reachable from every file which using themed colors (so I recommend import it at the top of main stylesheet).

import './themes_path/generated_multitheme_file';

####3.

Instead of using colors directly in CSS properties, take advantage from using one of colorscss SASS mixins. These are the most common ones:

@include themify('border-color', $var1, '!important');
@include themifyRGBA('background-color', $var1, 0.7, '!important');

Note: '!important' is an optional argument.

In case that you need some more complex ones, like gradient or brightness functions, take a look at the list of available mixins.

####4.

Put chosen theme name key (passed in colorscss.generate() call) in <body> or <html> attribute class="". Voila!


##Available mixins

#####For solid color

  • themify(property, color, '!important')
    • @include themify('border-color', $var1, '!important');

#####For semi-transparent color

  • themifyRGBA(property, color, opacity, '!important')
    • @include themifyRGBA('background-color', $var1, 0.7, '!important');

#####For linear gradient

  • themifyGradient(direction, color1, opacity1, percent1, color2, opacity2, percent2)
    • @include themifyGradient('right', $var1, 0.2, '0%', $var3, 0.8, '50%');

#####For box shadow

  • themifyBoxShadow('inset x y blur spread', color, '!important')
    • @include themifyBoxShadow('3px 3px 10px', $var1, '!important');
    • @include themifyBoxShadow('inset 0 0 0 5px', $var1);

#####For darker shade

  • themifyDarken(property, color, value)
    • @include themifyDarken('border-color', $var3, '20%');

#####For brighter shade

  • themifyLighten(property, color, value)
    • @include themifyLighten('border-color', $var3, '20%');

#####For SVG fill color

  • themifySVG(color, '!important')
    • @include themifySVG($var1, '!important');