From 0db233ddb623c2d29b6f8d898e7a499aefb1ac5a Mon Sep 17 00:00:00 2001 From: HeskeyBaozi Date: Thu, 19 Jul 2018 19:24:19 +0800 Subject: [PATCH] update icon chinese doc --- components/icon/demo/basic.md | 27 +++++++++++++++ components/icon/demo/custom.md | 50 +++++++++++++++++++++++++++ components/icon/demo/iconfont.md | 33 ++++++++++++++++++ components/icon/demo/svg-sprite.md | 55 ++++++++++++++++++++++++++++++ components/icon/index.zh-CN.md | 8 ++++- 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 components/icon/demo/basic.md create mode 100644 components/icon/demo/custom.md create mode 100644 components/icon/demo/iconfont.md create mode 100644 components/icon/demo/svg-sprite.md diff --git a/components/icon/demo/basic.md b/components/icon/demo/basic.md new file mode 100644 index 0000000000..ecef645e82 --- /dev/null +++ b/components/icon/demo/basic.md @@ -0,0 +1,27 @@ +--- +order: 0 +title: + zh-CN: 基本用法 + en-US: Basic +--- + +## zh-CN + +使用 `` 标签声明组件,指定图标对应的 `type` 属性。 + +## en-US + +Use tag `` to create an icon and set its type in the `type` prop. + +````jsx +import { Icon } from 'antd'; + +ReactDOM.render( +
+ + + +
, + mountNode +); +```` diff --git a/components/icon/demo/custom.md b/components/icon/demo/custom.md new file mode 100644 index 0000000000..37b72a9599 --- /dev/null +++ b/components/icon/demo/custom.md @@ -0,0 +1,50 @@ +--- +order: 1 +title: + zh-CN: 自定义图标 + en-US: Custom Icon +--- + +## zh-CN + +利用 `Icon` 提供的 `` 组件封装一个可复用的自定义图标。可以进一步通过 `component` 属性传入一个组件来修饰 `` 标签,以满足特定的需求。 + +## en-US + +Todo, Please replace me. + +````jsx +import { Icon } from 'antd'; +const CustomIcon = Icon.CustomIcon; + +const StarIcon = (props) => ( + + + +); + +const CoolStarIcon = (props) => ( + ( + + + + + + + + {React.cloneElement(svgProps.children, { fill: 'url(#Gradient01)' })} + + )} + /> +); + +ReactDOM.render( +
+ + + +
, + mountNode +); +```` diff --git a/components/icon/demo/iconfont.md b/components/icon/demo/iconfont.md new file mode 100644 index 0000000000..33fb181b0f --- /dev/null +++ b/components/icon/demo/iconfont.md @@ -0,0 +1,33 @@ +--- +order: 4 +title: + zh-CN: 使用 iconfont.cn + en-US: Use iconfont.cn +--- + +## zh-CN + +对于使用 [iconfont.cn](http://iconfont.cn/) 的用户,通过设置 `create` 方法中的 `namespace` 和 `scriptLink` 字段, 即可轻松地使用已有项目中的图标。 + +## en-US + +Todo, please replace me! + +````jsx +import { Icon } from 'antd'; + +const FooIcon = Icon.create({ + namespace: 'foo', + scriptLink: 'https://at.alicdn.com/t/font_8d5l8fzk5b87iudi.js', + prefix: 'icon-' +}); + +ReactDOM.render( +
+ + + +
, + mountNode +); +```` diff --git a/components/icon/demo/svg-sprite.md b/components/icon/demo/svg-sprite.md new file mode 100644 index 0000000000..83cd9468a0 --- /dev/null +++ b/components/icon/demo/svg-sprite.md @@ -0,0 +1,55 @@ +--- +order: 3 +title: + zh-CN: SVG Sprite + en-US: SVG Sprite +--- + +## zh-CN + +利用 `Icon` 提供的 `create` 方法来创建一个只用来引用 `symbol` 的组件来实现 `SVG Sprite`。**但是必须提前引入SVG符号定义。** + +## en-US + +Todo, Please Replace me! + +```jsx +import { Icon } from 'antd'; + +const DemoIcon = Icon.create({ + prefix: 'demo-', + viewBox: '0 0 1024 1024' +}); + +const svgSpriteRenderer = (nodeId, contents) => ` + `; + +const messageSymbol = ` + + +`; + +// insert SVG symbols into document.body +if(document) { + const nodeId = '__SVG_SPRITE_NODE__'; + const spriteContent = svgSpriteRenderer(nodeId, messageSymbol); + const existing = document.getElementById(nodeId); + if (!existing) { + document.body.insertAdjacentHTML('afterbegin', spriteContent); + } +} + +ReactDOM.render( +
+ +
, + mountNode +); +``` diff --git a/components/icon/index.zh-CN.md b/components/icon/index.zh-CN.md index f36287b777..1ff929a724 100644 --- a/components/icon/index.zh-CN.md +++ b/components/icon/index.zh-CN.md @@ -27,7 +27,6 @@ toc: false ``` -## 自定义图标 ## 图标列表 @@ -74,3 +73,10 @@ ReactDOM.render(, mountNode); | spin | 是否有旋转动画 | boolean | false | | style | 设置图标的样式,例如 fontSize 和 color | object | - | | type | 图标类型 | string | - | + +