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

less-plugin-theme-easy

v2.0.9

Published

easy to write theme code.

Downloads

29

Readme

less-plugin-theme-easy

write theme style more easy!

lessc usage

npm install -g less-plugin-theme-easy

and then on the command line,

lessc file.less --theme-easy

Try the following code

// TODO
@color-font-regular: {
  white: #5D6588;
  black: #CBD7F0;
}

@color-panel-item-active: {
  white: #464e64;
  black: #ffffff;
}

.item {
  color: theme(@color-font-regular);
  background: theme(@color-panel-item-active);
  border-color: theme(@color-panel-item-active);

  * {
    font-size: 12px;
    line-height: 30px;
  }

  &:hover, &.active {
    //color: theme(@color-panel-item-active);
    background-color: theme({
      //color: theme(@color-panel-item
      white: #eef4ff;
      /*background-color: theme({
      white: #eef4ff;*/
      black: #19233C;
    });
    color: theme(@color-font-regular);
    /*background-color: theme({
      white: #eef4ff;
      black: #19233C;
    });*/
  }

  .favorite-icon {
    margin-right: 5px;

    &.star {
      color: theme({
        white: #7E9EFD;
        black: #5073FF;
      });
    }
  }
}

It will be compiled to

.white .item {
    color: #5D6588;
    background: #464e64;
    border-color: #464e64;
}
.black .item {
    color: #CBD7F0;
    background: #ffffff;
    border-color: #ffffff;
}
.item * {
    font-size: 12px;
    line-height: 30px;
}
.item:hover,
.item.active {
    /*background-color: theme({
        white: #eef4ff;
        black: #19233C;
      });*/
}
.white .item:hover,
.white .item.active {
    background-color: #eef4ff;
    color: #5D6588;
}
.black .item:hover,
.black .item.active {
    background-color: #19233C;
    color: #CBD7F0;
}
.item .favorite-icon {
    margin-right: 5px;
}
.white .item .favorite-icon.star {
    color: #7E9EFD;
}
.black .item .favorite-icon.star {
    color: #5073FF;
}

Then, you can control the global style by adding the desired attributes to your topmost element.

<!--Global Settings style-->
<body class="white">
  <div>...</div>
  <div class="item">
      <a class="favorite-icon">
        ...      
      </a>
  </div>
</body>

options

If you use the plug-in constructor alone, allow the following parameters to be passed in:

| option | Description | Type | Required | Default | | ------------------------- | ------------------------------------------------------------ | ------------------------------------------------- | -------- | ---------------------- | | themeIdentityKeyWord | The function name keyword to find in the value of the attribute to be replaced. | string | false | 'theme' | | themePropertyValueHandler | How to replace the attribute | function(option:{key:string;value:string}):string | false | Refer to the following | | mergeSelector | Whether to combine CSS chunks of the same selector(new option,it is added in 2.0.5+ ) | Boolean | false | true |

Default value of themePropertyValueHandler:

  function replace({key, value}) {
    return `each(${value}, {
							@class: replace(@key, '@', '');
								.@{class} & {
									${key}: @value;
								}
						});`
  }

If mergeSelector = false, the output will be like this, and the same selector css rules will not be merged.

.white .item {
    color: #5D6588;
}

.black .item {
    color: #CBD7F0;
}

.white .item {
    background: #464e64;
}

.black .item {
    background: #ffffff;
}

.white .item {
    border-color: #464e64;
}

.black .item {
    border-color: #ffffff;
}

.item * {
    font-size: 12px;
    line-height: 30px;
}

.item:hover,
.item.active {
    /*background-color: theme({
        white: #eef4ff;
        black: #19233C;
      });*/
}

.white .item:hover,
.white .item.active {
    background-color: #eef4ff;
}

.black .item:hover,
.black .item.active {
    background-color: #19233C;
}

.white .item:hover,
.white .item.active {
    color: #5D6588;
}

.black .item:hover,
.black .item.active {
    color: #CBD7F0;
}

.item .favorite-icon {
    margin-right: 5px;
}

.white .item .favorite-icon.star {
    color: #7E9EFD;
}

.black .item .favorite-icon.star {
    color: #5073FF;
}

For example

import LessPluginTheme from 'less-plugin-theme'

new LessPluginTheme({
    themeIdentityKeyWord: 'a',
    themePropertyValueHandler: ({key,value})=>{return ...},
    mergeSelector: true
})

Vue-cli config

If you use it in vue-cli, just add it in the vue.config.js file

const LessThemePlugin = require('less-plugin-theme-easy')

module.exports = {
  // ...
  css: {
    loaderOptions: {
      less: {
        plugins: [
          new LessThemePlugin(/** ...options */),
        ],
      }
    }
  }
}