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

theme-generator-less

v1.0.1

Published

This a script to generate color specific styles less file and which you can use to change theme dynamically in browser

Downloads

5

Readme

forked form https://github.com/mzohaibqc/antd-theme-generator

源代码以及源文档: https://github.com/mzohaibqc/antd-theme-generator

更改部分代码以便适用于场景需求

theme-generator

提取源less文件中的颜色属性样式生成一个新的less文件,用于设置系统主题配置

目前针对antd库使用,后续增加可自定义的库以及系统自身使用

Example:

const { generateTheme } = require('theme-generator');

const options = {
  antDir: path.join(__dirname, './node_modules/antd'), // antd的目录
  stylesDir: path.join(__dirname, './src/styles'),  // 项目的样式目录
  varFile: path.join(__dirname, './src/styles/variables.less'), // 项目的变量定义文件路径
  mainLessFile: path.join(__dirname, './src/styles/index.less'),
  themeVariables: ['@primary-color'],  // 需要设置主题配色修改的less颜色变量
  outputFilePath: path.join(__dirname, './public/color.less'), // if provided, file will be created with generated less/styles
  shadeVariables: ['@primary-color'],  // 可选,默认@primary-color,生成多层次颜色
}

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

注意:不同变量不要使用同一颜色,不然会被覆盖,设置主题的颜色变量必须包含横线。

eg: @test-color: #ad12ad; // 有效 @test: #ad12ad; // 无效

在入口index.html文件中添加以下代码

<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>

你可以使用下面代码更新颜色配置

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