Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

css-runtime-theme

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

css-runtime-theme

This script allow you to generate color.less which will enable you to change theme in browser

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

css-runtime-theme

This script allows you to generate a less file color.less which you can import in your index.html file and then you can change color specific theme on runtime in browser without any new build.

const options = {
    source: path.join(__dirname, './src/index.css'), // File or css string,
    variables: {
        '@color1': '#cccccc', // must add @ sign 
        '@color2': '#343312'
    },
    stylesDir: path.join(__dirname, './src'), // if your styles are in multiple files, specifiy the directory
    output: path.join(__dirname, './dist/color.less'), // output file path, filename should have .less extension and folder should be there, omit if you don't want to create file, it will return generated less
    withoutGrey: false, // set to true to remove rules that only have grey colors
    withoutMonochrome: false, // set to true to remove rules that only have grey, black, or white colors
};

generateTheme(options).then(less => {
  console.log('Theme generated successfully');
})
.catch(error => {
  console.log('Error', error);
});

Add following lines in your main html file

<link rel="stylesheet/less" type="text/css" href="/color.less" />
<script>
  window.less = {
    async: false,
    env: 'production'
  };
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/less.js/2.7.2/less.min.js"></script>

Now you can update colors by updating less avriables like this

window.less.modifyVars({
  '@primary-color': '#0035ff'
})

Keywords

FAQs

Package last updated on 25 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc