docs: update customize theme doc

ref: dvajs/dva#562 dvajs/dva#575
This commit is contained in:
afc163 2017-02-09 14:44:36 +08:00
parent 4ec6bf3bcd
commit 10199e5d96
2 changed files with 7 additions and 5 deletions

View File

@ -21,9 +21,9 @@ We recommend [modifyVars](http://lesscss.org/usage/#using-less-in-the-browser-mo
You can use this [example](https://github.com/ant-design/antd-init/tree/master/examples/customize-antd-theme) as a playground.
### 1) Using 'theme' property in package.theme (recommended way)
### 1) Using `theme` property (recommended way)
Specify the `theme` property in `package.json` file, whose value can be either an object or the path to a JS file that contains the custom values of specific variables:
Specify the `theme` property in `package.json` or `.roadhogrc` file, whose value can be either an object or the path to a JS file that contains the custom values of specific variables:
- example of directly specifying the custom values as an object:
```js
"theme": {
@ -40,6 +40,7 @@ This approach is working only when using [atool-build](https://github.com/ant-to
Note:
- Importing style from less files is necessary. Please specify `style` option of `babel-plugin-import` to be `true`.
- You should write `theme` field in [.roadhogrc](https://github.com/dvajs/dva-example-user-dashboard/commit/d6da33b3a6e18eb7f003752a4b00b5a660747c31) rather then `package.json` when using `dva-cli@0.7.0+`.
- If you want to override `@icon-url`, the quotes must be contained in value like `"@icon-url": "'your-icon-font-path'"` ([A fix sample](https://github.com/visvadw/dvajs-user-dashboard/pull/2)).
### 2) Overriding Less variables (alternative way)

View File

@ -22,9 +22,9 @@ antd 的样式使用了 [Less](http://lesscss.org/) 作为开发语言,并定
可以在本地运行 [例子](https://github.com/ant-design/antd-init/tree/master/examples/customize-antd-theme) 查看定制效果。
### 1) package.theme推荐
### 1) theme 属性(推荐)
配置在 `package.json` 下的 `theme` 字段。theme 可以为配置为一个对象或文件路径。
配置在 `package.json` `.roadhogrc` 下的 `theme` 字段。theme 可以为配置为一个对象或文件路径。
```js
"theme": {
@ -38,11 +38,12 @@ antd 的样式使用了 [Less](http://lesscss.org/) 作为开发语言,并定
"theme": "./theme.js",
```
定义 `package.theme` 时, 需要配合 [atool-build](https://github.com/ant-tool/atool-build) 使用([antd-init](https://github.com/ant-design/antd-init) 和 [dva-cli](https://github.com/dvajs/dva-cli) 内建支持)。如果你使用的是其他脚手架,可以参考 [atool-build 中 less-loader 的 webpack 相关配置 ](https://github.com/ant-tool/atool-build/blob/a4b3e3eec4ffc09b0e2352d7f9d279c4c28fdb99/src/getWebpackCommonConfig.js#L131-L138),利用 [less-loader](https://github.com/webpack/less-loader#less-options) 的 `modifyVars` 配置来覆盖原来的样式变量。
定义 `theme` 属性时, 需要配合 [atool-build](https://github.com/ant-tool/atool-build) 使用([antd-init](https://github.com/ant-design/antd-init) 和 [dva-cli](https://github.com/dvajs/dva-cli) 内建支持)。如果你使用的是其他脚手架,可以参考 [atool-build 中 less-loader 的 webpack 相关配置 ](https://github.com/ant-tool/atool-build/blob/a4b3e3eec4ffc09b0e2352d7f9d279c4c28fdb99/src/getWebpackCommonConfig.js#L131-L138),利用 [less-loader](https://github.com/webpack/less-loader#less-options) 的 `modifyVars` 配置来覆盖原来的样式变量。
注意:
- 样式必须加载 less 格式。如果您使用了 `babel-plugin-import`,请将 style 属性配置为 `true`
- `dva-cli@0.7.0+``theme` 属性需要写在 [.roadhogrc](https://github.com/dvajs/dva-example-user-dashboard/commit/d6da33b3a6e18eb7f003752a4b00b5a660747c31) 文件里。
- 如果要覆盖 `@icon-url` 变量,内容需要包括引号 `"@icon-url": "'your-icon-font-path'"`[修正示例](https://github.com/visvadw/dvajs-user-dashboard/pull/2))。
### 2) less