From 7af7e8382dfaf995f74c6bc4d8e74e272df70725 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 18 Nov 2016 15:38:36 +0800 Subject: [PATCH 1/2] Add customize-theme.md --- CHANGELOG.en-US.md | 2 +- CHANGELOG.zh-CN.md | 2 +- components/icon/index.en-US.md | 2 +- components/icon/index.zh-CN.md | 2 +- docs/react/customize-theme.en-US.md | 53 ++++++++++++++++++++++++++++ docs/react/customize-theme.zh-CN.md | 54 +++++++++++++++++++++++++++++ docs/react/upgrade-notes.md | 2 +- 7 files changed, 112 insertions(+), 5 deletions(-) create mode 100644 docs/react/customize-theme.en-US.md create mode 100644 docs/react/customize-theme.zh-CN.md diff --git a/CHANGELOG.en-US.md b/CHANGELOG.en-US.md index 8136f2c56f..6115162cbc 100644 --- a/CHANGELOG.en-US.md +++ b/CHANGELOG.en-US.md @@ -1,5 +1,5 @@ --- -order: 3 +order: 5 title: Change Log toc: false timeline: true diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 035a9c73af..999cdc030a 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -1,5 +1,5 @@ --- -order: 3 +order: 5 title: 更新日志 toc: false timeline: true diff --git a/components/icon/index.en-US.md b/components/icon/index.en-US.md index 4a6779b3fe..291e71f03e 100644 --- a/components/icon/index.en-US.md +++ b/components/icon/index.en-US.md @@ -123,7 +123,7 @@ ul.anticons-list li:hover .anticon { display: block; text-align: center; transform: scale(0.83); - font-family: Consolas; + font-family: "Lucida Console", Consolas; white-space: nowrap; } diff --git a/components/icon/index.zh-CN.md b/components/icon/index.zh-CN.md index 39fd4be213..0d172b7af7 100644 --- a/components/icon/index.zh-CN.md +++ b/components/icon/index.zh-CN.md @@ -124,7 +124,7 @@ ul.anticons-list li:hover .anticon { display: block; text-align: center; transform: scale(0.83); - font-family: Consolas; + font-family: "Lucida Console", Consolas; white-space: nowrap; } diff --git a/docs/react/customize-theme.en-US.md b/docs/react/customize-theme.en-US.md new file mode 100644 index 0000000000..7a8d65a295 --- /dev/null +++ b/docs/react/customize-theme.en-US.md @@ -0,0 +1,53 @@ +--- +order: 4 +title: Customize theme +--- + +Ant Design allow to customize some basic design tokens for meeting the needs of UI diversity from bussiness and brand, including primary color, border radius, border and etc. + +## Less variables + +We are using [Less](http://lesscss.org/) as development language of style. A series of less variables are defined for each design tokens which can be customized as your needs. + +- [Default Variables](https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less) + +Please report issue if the variables is not enough for you. + +## How to use it + +We recommand [modifyVars](http://lesscss.org/usage/#using-less-in-the-browser-modify-variables) to override the default variables. There are two way to achieve it in practive. + +You can run this [example](https://github.com/ant-design/antd-init/tree/master/examples/customize-antd-theme) for playground. + +### 1) package.theme (recommanded) + +Specify the `theme` field in 'package.json', which could be a object or file path. + +```js +"theme": { + "@primary-color": "#1DA57A", +}, +``` + +or: + +```js +"theme": "./theme.js", // https://github.com/ant-design/antd-init/blob/master/examples/customize-antd-theme/theme.js +``` + +This way is working only when using [atool-build](https://github.com/ant-tool/atool-build)(built in [antd-init](https://github.com/ant-design/antd-init) and [dva-cli](https://github.com/dvajs/dva-cli)). If you choose other boilerplates, you can write webpack config about [less-loader modifyVars](https://github.com/webpack/less-loader#less-options) like [atool-build ](https://github.com/ant-tool/atool-build/blob/a4b3e3eec4ffc09b0e2352d7f9d279c4c28fdb99/src/getWebpackCommonConfig.js#L131-L138) does. + +Note: importing less style is necessary. Please specify `style` option of `babel-plugin-import` to be `true` or `less` if you are using it. + +### 2) less + +Override variables via less definition files. + +Create a standalone less file like below, and import it in your project. + + ```css + @import "~antd/dist/antd.less"; // import official less entry file + @import "your-theme-file.less"; // override variables here + ``` + +Note: this way will load style of all component regardless of your demand, which cause `style` option of `babel-plugin-import` not working. diff --git a/docs/react/customize-theme.zh-CN.md b/docs/react/customize-theme.zh-CN.md new file mode 100644 index 0000000000..7c4fc743a5 --- /dev/null +++ b/docs/react/customize-theme.zh-CN.md @@ -0,0 +1,54 @@ +--- +order: 4 +title: 定制主题 +--- + +Ant Design 设计规范上支持一定程度的样式定制,以满足业务和品牌上多样化的视觉需求,包括但不限于主色、圆角、边框和部分组件的视觉定制。 + +## 样式变量 + +antd 的样式使用了 [Less](http://lesscss.org/) 作为开发语言,并定义了一系列全局/组件的样式变量,你可以根据需求进行相应调整。 + +- [默认样式变量](https://github.com/ant-design/ant-design/blob/master/components/style/themes/default.less) + +如果以上变量不能满足你的定制需求,可以给我们提 issue。 + +## 定制方式 + +我们使用 [modifyVars](http://lesscss.org/usage/#using-less-in-the-browser-modify-variables) 的方式来覆盖变量。 +在具体工程实践中,有 `package.theme` 和 `less` 两种方案,选择一种即可。 + +可以在本地运行[例子](https://github.com/ant-design/antd-init/tree/master/examples/customize-antd-theme) 查看定制效果。 + +### 1) package.theme(推荐) + +配置在 `package.json` 下的 `theme` 字段。theme 可以为配置为一个对象或文件路径。 + +```js +"theme": { + "@primary-color": "#1DA57A", +}, +``` + +或者: + +```js +"theme": "./theme.js", // https://github.com/ant-design/antd-init/blob/master/examples/customize-antd-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` 配置来覆盖原来的样式变量。 + +注意,样式必须加载 less 格式。如果您使用了 `babel-plugin-import`,请将 style 属性配置为 `true` 或 `less`。 + +### 2) less + +用 less 文件进行变量覆盖。 + +建立一个单独的 `less` 文件如下,再引入这个文件。 + + ```css + @import "~antd/dist/antd.less"; // 引入官方提供的 less 样式入口文件 + @import "your-theme-file.less"; // 用于覆盖上面定义的变量 + ``` + +注意:这种方式会载入所有组件的样式,无法和按需加载插件 `babel-plugin-import` 的 `style` 属性一起使用。 diff --git a/docs/react/upgrade-notes.md b/docs/react/upgrade-notes.md index ffa75959dc..965573861b 100644 --- a/docs/react/upgrade-notes.md +++ b/docs/react/upgrade-notes.md @@ -1,5 +1,5 @@ --- -order: 4 +order: 6 title: zh-CN: 升级指南 en-US: Upgrade Notes From 5982e9445689b541d80d0066ca7e417ff17ff971 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 18 Nov 2016 16:16:34 +0800 Subject: [PATCH 2/2] Add screenshot --- docs/react/customize-theme.en-US.md | 2 ++ docs/react/customize-theme.zh-CN.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/docs/react/customize-theme.en-US.md b/docs/react/customize-theme.en-US.md index 7a8d65a295..f4f64e80c3 100644 --- a/docs/react/customize-theme.en-US.md +++ b/docs/react/customize-theme.en-US.md @@ -5,6 +5,8 @@ title: Customize theme Ant Design allow to customize some basic design tokens for meeting the needs of UI diversity from bussiness and brand, including primary color, border radius, border and etc. +![](https://zos.alipayobjects.com/rmsportal/zTFoszBtDODhXfLAazfSpYbSLSEeytoG.png) + ## Less variables We are using [Less](http://lesscss.org/) as development language of style. A series of less variables are defined for each design tokens which can be customized as your needs. diff --git a/docs/react/customize-theme.zh-CN.md b/docs/react/customize-theme.zh-CN.md index 7c4fc743a5..16edca6c99 100644 --- a/docs/react/customize-theme.zh-CN.md +++ b/docs/react/customize-theme.zh-CN.md @@ -5,6 +5,8 @@ title: 定制主题 Ant Design 设计规范上支持一定程度的样式定制,以满足业务和品牌上多样化的视觉需求,包括但不限于主色、圆角、边框和部分组件的视觉定制。 +![](https://zos.alipayobjects.com/rmsportal/zTFoszBtDODhXfLAazfSpYbSLSEeytoG.png) + ## 样式变量 antd 的样式使用了 [Less](http://lesscss.org/) 作为开发语言,并定义了一系列全局/组件的样式变量,你可以根据需求进行相应调整。