All Projects → raohong → antd-color-replacer

raohong / antd-color-replacer

Licence: other
适用于 webpack 环境下 的 主题切换插件

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects

Projects that are alternatives of or similar to antd-color-replacer

Webpack-Starter-Kit
Webpack 4 stater kit with SCSS, PostCSS, Babel & ESLint
Stars: ✭ 41 (+86.36%)
Mutual labels:  postcss, webpack4
React Redux Boilerplate
Awesome React Redux Workflow Boilerplate with Webpack 4
Stars: ✭ 307 (+1295.45%)
Mutual labels:  postcss, webpack4
React Antd Admin
后台前端管理系统,基于react、typescript、antd、dva及一些特别优秀的开源库实现
Stars: ✭ 117 (+431.82%)
Mutual labels:  antd, webpack4
Reactspa
combination of react teconology stack
Stars: ✭ 911 (+4040.91%)
Mutual labels:  antd, webpack4
mobxSpa
企业级SPA项目,完整开发脚手架
Stars: ✭ 96 (+336.36%)
Mutual labels:  antd, webpack4
React Redux Antdesign Webpack Starter
react + redux + ant design + react-router 4 + webpack 4 starter
Stars: ✭ 44 (+100%)
Mutual labels:  antd, webpack4
polymerx-cli
⚡ Unlock the power of Polymer 3, Web Components and modern web tools.
Stars: ✭ 30 (+36.36%)
Mutual labels:  postcss, webpack4
Fashop Admin
微信小程序商城后台,微信小程序微店后台,接口基于FaShop
Stars: ✭ 198 (+800%)
Mutual labels:  antd, webpack4
webpack-boilerplate
Webpack 4 boilerplate (babel, eslint, prettier, jest, sass, postcss, hmr, browsersync)
Stars: ✭ 33 (+50%)
Mutual labels:  postcss, webpack4
Reactql
Universal React+GraphQL starter kit: React 16, Apollo 2, MobX, Emotion, Webpack 4, GraphQL Code Generator, React Router 4, PostCSS, SSR
Stars: ✭ 1,833 (+8231.82%)
Mutual labels:  postcss, webpack4
React Latest Framework
a client framework of React
Stars: ✭ 835 (+3695.45%)
Mutual labels:  antd, webpack4
dva-typescript-antd-starter-kit
A admin dashboard application demo based on antd by typescript and dva
Stars: ✭ 61 (+177.27%)
Mutual labels:  postcss, antd
React Design Editor
React Design Editor has started to developed direct manipulation of editable design tools like Powerpoint, We've developed it with reactjs, ant.design, fabricjs
Stars: ✭ 687 (+3022.73%)
Mutual labels:  antd, webpack4
Typescript React Hot Reload
A very simple boilerplate for creating React web applications with TypeScript.
Stars: ✭ 92 (+318.18%)
Mutual labels:  antd, webpack4
Tonzhon Music
将QQ音乐、网易云音乐和酷我音乐上的歌添加到一个列表来播放!
Stars: ✭ 257 (+1068.18%)
Mutual labels:  antd, webpack4
Webpack4.x
webpack4.x详细配置步骤
Stars: ✭ 103 (+368.18%)
Mutual labels:  postcss, webpack4
react-starter-kit
基于webpack4 + ES6/7 + less + React16 + Redux4 + React-Router4 + react-hot-loader4 + antd
Stars: ✭ 27 (+22.73%)
Mutual labels:  antd, webpack4
react-cli
基于 create-react-app 搭建的前端脚手架
Stars: ✭ 18 (-18.18%)
Mutual labels:  postcss, antd
trackupdates
A simple yaml-based xpath crawler framework for easy tracking site updates. https://zhupeng.github.io/
Stars: ✭ 20 (-9.09%)
Mutual labels:  antd
vue-startup
A template with webpack 4 + vuejs 2 + + babel 7 setup for projects startup
Stars: ✭ 44 (+100%)
Mutual labels:  webpack4

一个 webpack 主题切换器

Build Status

食用方法

ant pro demo

  1. npm i antd-color-replacer
  1. 如果你使用 ant-pro

    1. 在 config/plugin 文件
    import AntdColorReplacer from 'antd-color-replacer';
    import defaultSettings from '../src/defaultSettings';
    
    config.plugin('antd-color-replacer').use(AntdColorReplacer, [
      {
        primaryColor: defaultSettings.primaryColor,
      },
    ]);

    替换原来引入的插件

    import AntdColorReplacerClient from 'AntdColorReplacerClient/lib/client';
  1. 其它
import AntdColorReplacer from 'antd-color-replacer';

const webpackConfig = {
  plugins: [
    new AntdColorReplacer({
      primaryColor: primaryColor,
    }),
  ],
};

import AntdColorReplacerClient from 'AntdColorReplacerClient/lib/client';

AntdColorReplacerClient.compile(newPrimaryColor);

配置项

  1. AntdColorReplacer
class AntdColorReplacer {
  constructor(options?: AntdColorReplacerOptions);
}

interface AntdColorReplacerOptions {
  // 是否是 antd 使用 默认 true , 此时 colors 已经生成
  antd?: boolean;
  // 主色
  primaryColor?: string;
  // 要替换的颜色数组
  colors?: string[];
  // 生成的 css 名称 默认是 css/theme-color.css
  filename?: string;
  // production 环境时 filename  是否生成 hash 默认是 即 css/theme-color.[hash].css
  hash?: boolean;
  // 是否开启宽松模式 即 不在符合主题颜色的情况下 颜色亮度值 在 luminance 设定的范围内 即可保留
  readonly loose: boolean;
  // 目标 css prop  default ['border', 'color', 'background', 'outline', 'box-shadow']
  looseProps: string[];
  // 参照 https://github.com/misund/get-relative-luminance
  luminance: [number, number];
  // css 选择适配器 参照 antd-color-replacer/src/adapter.antdSelectorAdapter]
  selectorAdapter?: AntdColorReplacerAdapter;
}

/**
 * 自定义 css node 节点处理器
 * 参考 postcss api
 * Tips: 如果要增加新的节点 请添加在当前节点前面
 */
type AntdColorReplacerAdapterCustomHandle = (node: postcss.Rule, postCss: typeof postcss) => void;

type IAdapterResult = string | false | AntdColorReplacerAdapterCustomHandle | void;

type AntdColorReplacerAdapter = (selector: string) => IAdapterResult;
  1. AntdColorReplacerClient.compile:
AntdColorReplacerClient.compile:  (options?: string | AntdColorReplacerClientOptions) => Promise<void>;

type IMeatFilenameCustomHandle = (metaFilename: string) => string;

interface AntdColorReplacerClientOptions {
  // 保存编译时的数据 json 文件路径
  metaFilename?: string | IMeatFilenameCustomHandle;
  // 主色
  primaryColor?: string;
  // 颜色数组
  colors?: string[];
  // 是否是 antd
  antd?: boolean;
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].