Giter VIP home page Giter VIP logo

less-plugin-dynamic-variable's Introduction

Hi 👋

I'm Arvin Xu, a design engineer.

✍️ Languages

HTML JavaScript TypeScript CSS Python

Top Langs

🛠 Tech Stack and Tools

End Stack
Frontend React antd Less umi
Backend Node Egg mongoDB
Devops GitHub Action Nginx Docker
IDE WebStorm PyCharm Visual Studio Code
Workflow Git GitHub Gitmoji

❤️ GitHub Stats

Arvin XU's github stats

less-plugin-dynamic-variable's People

Contributors

arvinxx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

less-plugin-dynamic-variable's Issues

插件动机 & 功能需求点

动机

简单来说,就是让 less 变量可以无痛迁移到 css variable 去。详见二楼 ⬇️

功能特性

  • 支持配置目标 less 变量
  • 支持自动生成全局作用域 css 变量
  • 支持自动生成局部作用域的 css 变量
  • 支持使用了 less function 的 less 变量

RoadMap

  • 确定需要转换为 css 变量的 less 变量
    • 集成 cosmiconfig
    • 设计配置清单
  • 在生成完毕数值后,基于相应数值添加 css 变量声明;
  • 在完成变量声明后,将原有 less 变量替换为 css 变量。

预期使用方法

1. 配置

使用 cosmiconfig 式配置。

暂且将配置命名为 dynamic-theme, 那么配置文件就是dynamic-theme.config.js.dynamic-themerc等形式。

准备暂且只支持一个 variables 参数,其他需求后面再看

module.exports = {
  variables: ["primary-color","green-4"]
}

如此一来,插件就会识别到 primary-colorgreen-4 变量是需要提升为 css variables 的。

2. 引入插件

lessc 直接执行的话

lessc file.less --css-variable-theme

引入到配置项中

const LessPluginCssVariablesTheme = require('less-plugin-css-variable-theme');

{
  //...
  lessLoaderOptions: {
    plugins: [CssVariablesWithFunctions];
  }
}

3. 使用

如下声明

@primary-color: #1890ff;
.use {
  color: @primary-color;
}

会生成

:root {
  --primary-color: #1890ff;
}
.use {
  color: var(--primary-color);
}

参考对象

社区插件仓库

开发笔记

资料库

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.