├── examples ├── react-ts-demo │ ├── .env │ ├── src │ │ ├── react-app-env.d.ts │ │ ├── setupTests.ts │ │ ├── App.test.tsx │ │ ├── index.css │ │ ├── index.tsx │ │ ├── components │ │ │ ├── TabComp.tsx │ │ │ ├── SliderComp.tsx │ │ │ ├── PickerComp.tsx │ │ │ ├── SelectComp.tsx │ │ │ ├── InputComp.tsx │ │ │ ├── TableComp.tsx │ │ │ ├── LayoutComp.tsx │ │ │ ├── RadioComp.tsx │ │ │ ├── NewMenuComp.tsx │ │ │ ├── MenuComp.tsx │ │ │ ├── TableSelectComp.tsx │ │ │ └── TreeComp.tsx │ │ ├── App.css │ │ ├── logo.svg │ │ ├── App.tsx │ │ └── serviceWorker.ts │ ├── public │ │ ├── robots.txt │ │ ├── favicon.ico │ │ ├── logo192.png │ │ ├── logo512.png │ │ ├── manifest.json │ │ └── index.html │ ├── .gitignore │ ├── tsconfig.json │ ├── package.json │ └── README.md └── next-demo │ ├── static │ ├── favicon.ico │ ├── antd.svg │ └── markdown.css │ ├── now.json │ ├── .babelrc │ ├── pages │ ├── Calendar.js │ ├── Steps.js │ ├── Timeline.js │ ├── _error.js │ ├── DatePicker.js │ ├── Switch.js │ ├── Slider.js │ ├── TimePicker.js │ ├── _app.js │ ├── Radio.js │ ├── Tree.js │ ├── index.js │ ├── Input.js │ ├── Table.js │ ├── Select.js │ ├── Transfer.js │ ├── TreeSelect.js │ └── Button.js │ ├── .gitignore │ ├── package.json │ ├── LICENSE │ ├── next.config.js │ ├── docs │ ├── README_zh_CN.md │ └── README.md │ ├── components │ └── Layout.js │ └── README.md ├── index.js ├── custom-css.gif ├── dynamic-antd-theme.png ├── .npmignore ├── docs └── DEVDOCS.md ├── .gitignore ├── webpack.config.js ├── tsconfig.json ├── index.d.ts ├── utils └── autoCss2Str.js ├── LICENSE ├── package.json ├── src ├── dynamic-antd-theme.js └── core │ ├── util.js │ └── theme.js ├── README.md └── README_zh_CN.md /examples/react-ts-demo/.env: -------------------------------------------------------------------------------- 1 | SKIP_PREFLIGHT_CHECK=true -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./src/dynamic-antd-theme'); -------------------------------------------------------------------------------- /custom-css.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luffyZh/dynamic-antd-theme/HEAD/custom-css.gif -------------------------------------------------------------------------------- /examples/react-ts-demo/src/react-app-env.d.ts: -------------------------------------------------------------------------------- 1 | /// 2 | -------------------------------------------------------------------------------- /dynamic-antd-theme.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luffyZh/dynamic-antd-theme/HEAD/dynamic-antd-theme.png -------------------------------------------------------------------------------- /examples/react-ts-demo/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /examples/next-demo/static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luffyZh/dynamic-antd-theme/HEAD/examples/next-demo/static/favicon.ico -------------------------------------------------------------------------------- /examples/react-ts-demo/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luffyZh/dynamic-antd-theme/HEAD/examples/react-ts-demo/public/favicon.ico -------------------------------------------------------------------------------- /examples/react-ts-demo/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luffyZh/dynamic-antd-theme/HEAD/examples/react-ts-demo/public/logo192.png -------------------------------------------------------------------------------- /examples/react-ts-demo/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luffyZh/dynamic-antd-theme/HEAD/examples/react-ts-demo/public/logo512.png -------------------------------------------------------------------------------- /examples/next-demo/now.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 2, 3 | "name": "dynamic-antd-theme", 4 | "builds": [{ "src": "package.json", "use": "@now/next" }] 5 | } 6 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /.git/ 2 | /.vscode/ 3 | /node_modules/ 4 | /examples/ 5 | /docs/ 6 | .gitignore 7 | .npmignore 8 | .prettierrc 9 | .editorconfig 10 | .env 11 | tslint.json 12 | tsconfig.json 13 | *.log 14 | *.gif -------------------------------------------------------------------------------- /examples/next-demo/.babelrc: -------------------------------------------------------------------------------- 1 | 2 | { 3 | "presets": ["next/babel"], 4 | "plugins": [ 5 | [ 6 | "import", 7 | { 8 | "libraryName": "antd", 9 | "style": true 10 | } 11 | ] 12 | ] 13 | } -------------------------------------------------------------------------------- /examples/next-demo/pages/Calendar.js: -------------------------------------------------------------------------------- 1 | import { Calendar } from 'antd'; 2 | 3 | function onPanelChange(value, mode) { 4 | console.log(value, mode); 5 | } 6 | 7 | export default () => ( 8 | 9 | ); -------------------------------------------------------------------------------- /docs/DEVDOCS.md: -------------------------------------------------------------------------------- 1 | # 在设置淘宝镜像的时候发布不成功的解决办法 2 | 3 | ```bash 4 | # 登陆 5 | yarn login --registry http://registry.npmjs.org 6 | 7 | # 发布 8 | yarn publish --registry http://registry.npmjs.org 9 | 10 | # 用户名输入错误可以重新推出 11 | yarn logout 12 | ``` -------------------------------------------------------------------------------- /examples/react-ts-demo/src/setupTests.ts: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom/extend-expect'; 6 | -------------------------------------------------------------------------------- /examples/next-demo/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/ignore-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | 6 | # testing 7 | /coverage 8 | 9 | # production 10 | /build 11 | /dist 12 | /.next 13 | 14 | # misc 15 | .DS_Store 16 | .env 17 | npm-debug.log* 18 | yarn-debug.log* 19 | yarn-error.log* 20 | -------------------------------------------------------------------------------- /examples/react-ts-demo/src/App.test.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { render } from '@testing-library/react'; 3 | import App from './App'; 4 | 5 | test('renders learn react link', () => { 6 | const { getByText } = render(); 7 | const linkElement = getByText(/learn react/i); 8 | expect(linkElement).toBeInTheDocument(); 9 | }); 10 | -------------------------------------------------------------------------------- /examples/next-demo/pages/Steps.js: -------------------------------------------------------------------------------- 1 | import { Steps } from 'antd'; 2 | 3 | const { Step } = Steps; 4 | 5 | export default () => ( 6 | 7 | 8 | 9 | 10 | 11 | ); -------------------------------------------------------------------------------- /examples/next-demo/pages/Timeline.js: -------------------------------------------------------------------------------- 1 | import { Timeline } from 'antd'; 2 | 3 | export default () => ( 4 | 5 | Create a services site 2015-09-01 6 | Solve initial network problems 2015-09-01 7 | Technical testing 2015-09-01 8 | Network problems being solved 2015-09-01 9 | 10 | ); -------------------------------------------------------------------------------- /examples/react-ts-demo/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /examples/react-ts-demo/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /examples/next-demo/pages/_error.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Empty } from 'antd'; 3 | 4 | export default class Error extends React.Component { 5 | static getInitialProps({ res, err }) { 6 | const statusCode = res ? res.statusCode : err ? err.statusCode : null; 7 | return { statusCode }; 8 | } 9 | 10 | render() { 11 | return ( 12 | 13 | ); 14 | } 15 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | demo/node_modules/ 2 | examples/node_modules/ 3 | examples/.next/ 4 | docs/ 5 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 6 | 7 | # dependencies 8 | /node_modules 9 | /demo 10 | 11 | # testing 12 | /coverage 13 | 14 | # production 15 | /build 16 | 17 | # misc 18 | .DS_Store 19 | .env 20 | .env.local 21 | .env.development.local 22 | .env.test.local 23 | .env.production.local 24 | 25 | npm-debug.log* 26 | yarn-debug.log* 27 | yarn-error.log* 28 | -------------------------------------------------------------------------------- /examples/react-ts-demo/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import * as serviceWorker from './serviceWorker'; 6 | 7 | ReactDOM.render( 8 | , 9 | document.getElementById('root') 10 | ); 11 | 12 | // If you want your app to work offline and load faster, you can change 13 | // unregister() to register() below. Note this comes with some pitfalls. 14 | // Learn more about service workers: https://bit.ly/CRA-PWA 15 | serviceWorker.unregister(); 16 | -------------------------------------------------------------------------------- /examples/next-demo/pages/DatePicker.js: -------------------------------------------------------------------------------- 1 | import { DatePicker } from 'antd'; 2 | 3 | const { RangePicker, MonthPicker, WeekPicker } = DatePicker; 4 | 5 | export default () => ( 6 | <> 7 | console.log(dateString)} /> 8 |

9 | console.log(dateString)} /> 10 |

11 | console.log(dateString)} /> 12 |

13 | console.log(dateString)} /> 14 | 15 | ) -------------------------------------------------------------------------------- /examples/next-demo/pages/Switch.js: -------------------------------------------------------------------------------- 1 | import { Switch } from 'antd'; 2 | 3 | export default () => ( 4 | <> 5 | 6 |

7 | 8 |

9 | 10 |

11 | 12 |

13 | 14 |

15 | 16 |

17 | 18 |

19 | 20 | ) -------------------------------------------------------------------------------- /examples/react-ts-demo/src/components/TabComp.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Tabs } from 'antd'; 3 | 4 | const { TabPane } = Tabs; 5 | 6 | function callback(key: any) { 7 | console.log(key); 8 | } 9 | 10 | const TabComp = () => ( 11 | 12 | 13 | Content of Tab Pane 1 14 | 15 | 16 | Content of Tab Pane 2 17 | 18 | 19 | Content of Tab Pane 3 20 | 21 | 22 | ); 23 | 24 | export default TabComp; -------------------------------------------------------------------------------- /examples/next-demo/pages/Slider.js: -------------------------------------------------------------------------------- 1 | import { Slider } from 'antd'; 2 | 3 | const marks = { 4 | 0: '0°C', 5 | 26: '26°C', 6 | 37: '37°C', 7 | 100: { 8 | style: { 9 | color: '#f50', 10 | }, 11 | label: 100°C, 12 | }, 13 | }; 14 | 15 | export default () => ( 16 | <> 17 | 18 | 19 | 20 |

21 | 22 | 23 | 24 | 25 | ) -------------------------------------------------------------------------------- /examples/react-ts-demo/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /examples/next-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dynamic-antd-theme-demo", 3 | "scripts": { 4 | "start": "next", 5 | "build": "next build", 6 | "prod": "next start" 7 | }, 8 | "dependencies": { 9 | "@mdx-js/loader": "^1.5.1", 10 | "@next/mdx": "^9.1.4", 11 | "@zeit/next-less": "^1.0.1", 12 | "antd": "^3.25.3", 13 | "babel-plugin-import": "^1.13.0", 14 | "dynamic-antd-theme": "latest", 15 | "less": "^3.10.3", 16 | "moment": "^2.24.0", 17 | "next": "^9.1.4", 18 | "null-loader": "^3.0.0", 19 | "react": "^16.12.0", 20 | "react-dom": "^16.12.0" 21 | }, 22 | "version": "0.4.0" 23 | } 24 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const CleanWebpackPlugin = require('clean-webpack-plugin'); 3 | 4 | module.exports = { 5 | mode: 'production', 6 | entry: { 7 | index: './index.js' 8 | }, 9 | output: { 10 | filename: '[name].js', 11 | path: path.resolve(__dirname, "lib"), 12 | libraryTarget: 'commonjs2' 13 | }, 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.js$/, 18 | exclude: /node_modules/, 19 | loader: 'babel-loader?presets[]=env&presets[]=react&presets[]=stage-1' 20 | } 21 | ] 22 | }, 23 | plugins: [ 24 | new CleanWebpackPlugin(['lib']) 25 | ] 26 | } -------------------------------------------------------------------------------- /examples/react-ts-demo/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "lib": [ 5 | "dom", 6 | "dom.iterable", 7 | "esnext" 8 | ], 9 | "allowJs": true, 10 | "skipLibCheck": true, 11 | "esModuleInterop": true, 12 | "allowSyntheticDefaultImports": true, 13 | "noFallthroughCasesInSwitch": true, 14 | "strict": true, 15 | "forceConsistentCasingInFileNames": true, 16 | "module": "esnext", 17 | "moduleResolution": "node", 18 | "resolveJsonModule": true, 19 | "isolatedModules": true, 20 | "noEmit": true, 21 | "jsx": "react" 22 | }, 23 | "include": [ 24 | "src" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./lib", 4 | "noImplicitAny": false, 5 | "target": "es5", 6 | "lib": ["dom", "dom.iterable", "esnext"], 7 | "allowJs": true, 8 | "skipLibCheck": true, 9 | "esModuleInterop": true, 10 | "allowSyntheticDefaultImports": true, 11 | "strict": true, 12 | "forceConsistentCasingInFileNames": true, 13 | "module": "commonjs", 14 | "moduleResolution": "node", 15 | "resolveJsonModule": true, 16 | "isolatedModules": true, 17 | "jsx": "react", 18 | "baseUrl": "./", 19 | "paths": { "*": ["types/*"] } 20 | }, 21 | "exclude": ["node_modules", "lib"], 22 | "include": ["src/**/*"] 23 | } -------------------------------------------------------------------------------- /examples/next-demo/pages/TimePicker.js: -------------------------------------------------------------------------------- 1 | import { TimePicker } from 'antd'; 2 | import moment from 'moment'; 3 | 4 | function onChange(time, timeString) { 5 | console.log(time, timeString); 6 | } 7 | 8 | export default () => ( 9 | <> 10 | 11 |

12 | 13 |

14 |
15 | 16 | 17 | 18 |
19 | 20 | ); -------------------------------------------------------------------------------- /examples/next-demo/pages/_app.js: -------------------------------------------------------------------------------- 1 | import App from 'next/app'; 2 | import Head from 'next/head'; 3 | import Layout from '../components/Layout'; 4 | 5 | class MyApp extends App { 6 | render() { 7 | const { Component, pageProps, router } = this.props; 8 | return ( 9 | <> 10 | 11 | 🌈 Dynamic-Antd-Theme 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | ); 20 | } 21 | } 22 | 23 | export default MyApp; 24 | -------------------------------------------------------------------------------- /examples/react-ts-demo/src/components/SliderComp.tsx: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Slider, Switch } from 'antd'; 3 | 4 | class SliderComp extends Component { 5 | state = { 6 | disabled: false, 7 | }; 8 | 9 | handleDisabledChange = (disabled: any) => { 10 | this.setState({ disabled }); 11 | }; 12 | 13 | render() { 14 | const { disabled } = this.state; 15 | return ( 16 | <> 17 | 18 | 19 | Disabled: 20 | 21 | ); 22 | } 23 | } 24 | 25 | export default SliderComp; -------------------------------------------------------------------------------- /examples/react-ts-demo/src/components/PickerComp.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { DatePicker, Space } from 'antd'; 3 | 4 | const { RangePicker } = DatePicker; 5 | 6 | function onChange(date: any, dateString: any) { 7 | console.log(date, dateString); 8 | } 9 | 10 | function onOk(value: any) { 11 | console.log('onOk: ', value); 12 | } 13 | 14 | function PickerComp() { 15 | return ( 16 | 17 | 18 | 19 | 25 | 26 | ) 27 | } 28 | 29 | export default PickerComp; -------------------------------------------------------------------------------- /index.d.ts: -------------------------------------------------------------------------------- 1 | /** Declaration file generated by dts-gen */ 2 | import React from 'react'; 3 | import { ColorInputWithoutInstance } from 'tinycolor2'; 4 | 5 | export interface IComponentProps { 6 | primaryColor?: ColorInputWithoutInstance; 7 | storageName?: string; 8 | style?: CSSStyleDeclaration; 9 | placement?: 'bottomRight' | 'bottom' | 'bottomLeft' | 'left' | 'topLeft' | 'top' | 'topRight' | 'right', 10 | themeChangeCallback?: (color: ColorInputWithoutInstance) => void 11 | } 12 | 13 | export function changeAntdTheme(color: ColorInputWithoutInstance, customCss?: string): void; 14 | 15 | declare class DynamicAntdTheme extends React.Component { 16 | static defaultProps: IComponentProps; 17 | constructor(props: IComponentProps); 18 | } 19 | 20 | export default DynamicAntdTheme; 21 | 22 | -------------------------------------------------------------------------------- /examples/react-ts-demo/src/App.css: -------------------------------------------------------------------------------- 1 | @import '~antd/dist/antd.css'; 2 | 3 | .App { 4 | text-align: center; 5 | padding: 20px; 6 | max-width: 600px; 7 | margin: auto; 8 | } 9 | 10 | .App-logo { 11 | height: 40vmin; 12 | pointer-events: none; 13 | } 14 | 15 | @media (prefers-reduced-motion: no-preference) { 16 | .App-logo { 17 | animation: App-logo-spin infinite 20s linear; 18 | } 19 | } 20 | 21 | .App-header { 22 | background-color: #282c34; 23 | min-height: 100vh; 24 | display: flex; 25 | flex-direction: column; 26 | align-items: center; 27 | justify-content: center; 28 | font-size: calc(10px + 2vmin); 29 | color: white; 30 | } 31 | 32 | .App-link { 33 | color: #61dafb; 34 | } 35 | 36 | @keyframes App-logo-spin { 37 | from { 38 | transform: rotate(0deg); 39 | } 40 | to { 41 | transform: rotate(360deg); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /examples/next-demo/pages/Radio.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { Radio } from 'antd'; 3 | 4 | export default () => { 5 | const [value, setValue] = useState(1); 6 | const onChange = e => { 7 | console.log('radio checked', e.target.value); 8 | setValue(e.target.value); 9 | }; 10 | return ( 11 | <> 12 | Radio 13 |

14 | 15 | A 16 | B 17 | C 18 | D 19 | 20 |

21 | 22 | Hangzhou 23 | Shanghai 24 | Beijing 25 | Chengdu 26 | 27 | 28 | ) 29 | } -------------------------------------------------------------------------------- /examples/next-demo/pages/Tree.js: -------------------------------------------------------------------------------- 1 | import { Tree } from 'antd'; 2 | 3 | const { TreeNode } = Tree; 4 | 5 | const onSelect = (selectedKeys, info) => { 6 | console.log('selected', selectedKeys, info); 7 | }; 8 | 9 | const onCheck = (checkedKeys, info) => { 10 | console.log('onCheck', checkedKeys, info); 11 | }; 12 | 13 | export default () => ( 14 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | sss} key="0-0-1-0" /> 29 | 30 | 31 | 32 | ); -------------------------------------------------------------------------------- /examples/react-ts-demo/src/components/SelectComp.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Select } from 'antd'; 3 | 4 | const { Option } = Select; 5 | 6 | function handleChange(value: string) { 7 | console.log(`selected ${value}`); 8 | } 9 | 10 | const SelectComp = () => ( 11 | <> 12 | 20 | 23 | 26 | 29 | 30 | ); 31 | 32 | export default SelectComp; -------------------------------------------------------------------------------- /utils/autoCss2Str.js: -------------------------------------------------------------------------------- 1 | const css2str = require('css2str'); 2 | const path = require('path'); 3 | const fs = require('fs'); 4 | 5 | /** 6 | * @description 读取路径信息 7 | * @param {string} path 路径 8 | */ 9 | function getFileStat(path){ 10 | return new Promise((resolve, reject) => { 11 | fs.stat(path, (err, stats) => { 12 | if(err) { 13 | resolve(false); 14 | } else { 15 | resolve(stats); 16 | } 17 | }); 18 | }); 19 | } 20 | 21 | // 输入的 theme.css 22 | const inFilePath = path.join(`${__dirname}/../src/core/theme.css`); 23 | // 输出的 theme.js 24 | const outFilePath = path.join(`${__dirname}/../src/core/theme.js`); 25 | 26 | /** 27 | * @description 先删除再创建,保证每次都是最新的css文件 28 | */ 29 | async function intialCss2JsFile() { 30 | const isExist = await getFileStat(outFilePath); 31 | // 存在文件,删除 32 | if (isExist) { 33 | fs.unlinkSync(outFilePath); 34 | } 35 | // css 字符串 36 | const cssStr = css2str(fs.readFileSync(inFilePath)); 37 | const inStr = `module.exports = \`\r\n\t${cssStr}\r\n\`;`; 38 | // 删除之后重新创建一个空文件 39 | fs.writeFileSync(outFilePath, inStr); 40 | } 41 | 42 | intialCss2JsFile(); -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 luffyZh 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /examples/react-ts-demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-ts-demo", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^4.2.4", 7 | "@testing-library/react": "^9.3.2", 8 | "@testing-library/user-event": "^7.1.2", 9 | "@types/jest": "^24.0.0", 10 | "@types/node": "^12.0.0", 11 | "@types/react": "^16.9.0", 12 | "@types/react-dom": "^16.9.0", 13 | "antd": "latest", 14 | "rc-util": "^5.8.1", 15 | "react": "^16.13.1", 16 | "react-dom": "^16.13.1", 17 | "react-scripts": "^4.0.0", 18 | "typescript": "~3.7.2" 19 | }, 20 | "scripts": { 21 | "start": "react-scripts start", 22 | "build": "react-scripts build", 23 | "test": "react-scripts test", 24 | "eject": "react-scripts eject" 25 | }, 26 | "eslintConfig": { 27 | "extends": "react-app" 28 | }, 29 | "browserslist": { 30 | "production": [ 31 | ">0.2%", 32 | "not dead", 33 | "not op_mini all" 34 | ], 35 | "development": [ 36 | "last 1 chrome version", 37 | "last 1 firefox version", 38 | "last 1 safari version" 39 | ] 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /examples/next-demo/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 luffyZhou 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "dynamic-antd-theme", 3 | "version": "0.8.7", 4 | "description": "Dynamic change ant-design theme by simply method.", 5 | "main": "lib/index.js", 6 | "types": "index.d.ts", 7 | "repository": "https://github.com/luffyZh/dynamic-antd-theme.git", 8 | "homepage": "https://dynamic-antd-theme.luffyzh.now.sh/", 9 | "author": "luffyZh ", 10 | "license": "MIT", 11 | "scripts": { 12 | "dev": "webpack --progress --mode development", 13 | "prebuild": "node utils/autoCss2Str.js", 14 | "build": "webpack -p --progress", 15 | "watch": "webpack --watch --progress" 16 | }, 17 | "keywords": [ 18 | "react", 19 | "antd", 20 | "dynamic-theme", 21 | "css" 22 | ], 23 | "devDependencies": { 24 | "babel-core": "^6.26.3", 25 | "babel-loader": "^7.1.4", 26 | "babel-preset-env": "^1.7.0", 27 | "babel-preset-react": "^6.24.1", 28 | "babel-preset-stage-1": "^6.24.1", 29 | "bezier-easing": "^2.1.0", 30 | "clean-webpack-plugin": "^0.1.19", 31 | "css2str": "^0.1.1", 32 | "prop-types": "^15.6.2", 33 | "react": "^16.8.6", 34 | "react-color": "^2.17.3", 35 | "tinycolor2": "^1.4.1", 36 | "webpack": "^4.8.3", 37 | "webpack-cli": "^3.1.2" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /examples/next-demo/next.config.js: -------------------------------------------------------------------------------- 1 | const withLess = require('@zeit/next-less'); 2 | 3 | const withMDX = require('@next/mdx')({ 4 | extension: /\.mdx?$/ 5 | }) 6 | 7 | module.exports = withMDX(withLess({ 8 | pageExtensions: ['js', 'jsx', 'md', 'mdx'], 9 | lessLoaderOptions: { 10 | javascriptEnabled: true, 11 | localIdentName: '[local]___[hash:base64:5]', 12 | }, 13 | webpack: (config, { isServer }) => { 14 | if (isServer) { 15 | // deal antd style 16 | const antStyles = /antd\/.*?\/style.*?/ 17 | const origExternals = [...config.externals] 18 | config.externals = [ 19 | (context, request, callback) => { 20 | if (request.match(antStyles)) return callback() 21 | if (typeof origExternals[0] === 'function') { 22 | origExternals[0](context, request, callback) 23 | } else { 24 | callback() 25 | } 26 | }, 27 | ...(typeof origExternals[0] === 'function' ? [] : origExternals), 28 | ] 29 | config.module.rules.unshift({ 30 | test: antStyles, 31 | use: 'null-loader', 32 | }) 33 | } 34 | // Fixes npm packages that depend on `fs` module 35 | config.node = { 36 | fs: 'empty' 37 | } 38 | 39 | return config 40 | } 41 | })); 42 | -------------------------------------------------------------------------------- /examples/next-demo/pages/index.js: -------------------------------------------------------------------------------- 1 | import { useState } from 'react'; 2 | import { Select } from 'antd'; 3 | import Head from 'next/head'; 4 | import dynamic from 'next/dynamic' 5 | 6 | const README_EN = dynamic(() => import('../docs/README.md')); 7 | const README_ZH_CN = dynamic(() => import('../docs/README_zh_CN.md')); 8 | 9 | 10 | const { Option } = Select; 11 | 12 | const Home = () => { 13 | const [language, setLanguage] = useState('English'); 14 | return ( 15 | <> 16 | 17 | 18 | 19 |
20 | 25 | 33 |
34 | { 35 | language === 'English' 36 | ? 37 | : 38 | } 39 |
40 |
41 | 42 | ) 43 | } 44 | 45 | export default Home; 46 | -------------------------------------------------------------------------------- /examples/next-demo/pages/Input.js: -------------------------------------------------------------------------------- 1 | import { Input } from 'antd'; 2 | 3 | const { Search, TextArea } = Input; 4 | 5 | export default () => ( 6 | <> 7 | 12 |
13 |

14 |

15 | 16 |
17 |
18 | console.log(value)} 21 | style={{ width: 200 }} 22 | /> 23 |
24 |
25 | console.log(value)} enterButton /> 26 |
27 |
28 | console.log(value)} 33 | /> 34 |
35 |
36 |