From 716dda944b1a255958e4396c8d285cd372187b66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BD=97=E5=AE=AA?= Date: Fri, 10 Jul 2015 14:27:12 +0800 Subject: [PATCH 01/12] update motion ease and timer --- style/core/motion.less | 4 ++-- style/core/motion/fade.less | 4 ++-- style/core/motion/move.less | 4 ++-- style/core/motion/slide.less | 4 ++-- style/core/motion/zoom.less | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/style/core/motion.less b/style/core/motion.less index 4d676b6ab3..0dd042b19e 100644 --- a/style/core/motion.less +++ b/style/core/motion.less @@ -1,5 +1,5 @@ .motion-common() { - animation-duration: .22s; + animation-duration: .35s; animation-fill-mode: both; display: block !important; } @@ -28,4 +28,4 @@ @import "motion/other"; @import "motion/slide"; @import "motion/swing"; -@import "motion/zoom"; +@import "motion/zoom"; \ No newline at end of file diff --git a/style/core/motion/fade.less b/style/core/motion/fade.less index a05ca9460a..85b3f8492c 100644 --- a/style/core/motion/fade.less +++ b/style/core/motion/fade.less @@ -1,13 +1,13 @@ .fade-enter { opacity: 0; .motion-common(); - animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); + animation-timing-function: @ease-out; animation-play-state: paused; } .fade-leave { .motion-common(); - animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); + animation-timing-function: @ease-in; animation-play-state: paused; } diff --git a/style/core/motion/move.less b/style/core/motion/move.less index 48f04394e7..ae3f2cd8eb 100644 --- a/style/core/motion/move.less +++ b/style/core/motion/move.less @@ -2,10 +2,10 @@ .make-motion(@className, @keyframeName); .@{className}-enter { opacity: 0; - animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1); + animation-timing-function: @ease-out-circ; } .@{className}-leave { - animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34); + animation-timing-function: @ease-in-circ; } } diff --git a/style/core/motion/slide.less b/style/core/motion/slide.less index 25c50e1083..a237dbe47a 100644 --- a/style/core/motion/slide.less +++ b/style/core/motion/slide.less @@ -2,10 +2,10 @@ .make-motion(@className, @keyframeName); .@{className}-enter { opacity: 0; - animation-timing-function: cubic-bezier(0.08, 0.82, 0.17, 1); + animation-timing-function: @ease-out-circ; } .@{className}-leave { - animation-timing-function: cubic-bezier(0.6, 0.04, 0.98, 0.34); + animation-timing-function: @ease-in-circ; } } diff --git a/style/core/motion/zoom.less b/style/core/motion/zoom.less index 5964b6fe8b..9c2fd18b3e 100644 --- a/style/core/motion/zoom.less +++ b/style/core/motion/zoom.less @@ -2,10 +2,10 @@ .make-motion(@className, @keyframeName); .@{className}-enter { opacity: 0; - animation-timing-function: cubic-bezier(0.18, 0.89, 0.32, 1.28); + animation-timing-function: @ease-out-circ; } .@{className}-leave { - animation-timing-function: cubic-bezier(0.6, -0.3, 0.74, 0.05); + animation-timing-function: @ease-in-circ; } } From 83b5e34039712c34685b17cd623772b0d6ebd4f3 Mon Sep 17 00:00:00 2001 From: Benjy Cui Date: Fri, 10 Jul 2015 16:16:32 +0800 Subject: [PATCH 02/12] Update iconfont and relative code. --- style/components/inputNumber.less | 12 +++++------- style/core/iconfont.less | 7 +++---- style/themes/default/custom.less | 2 +- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/style/components/inputNumber.less b/style/components/inputNumber.less index 77c76cb4f8..f9b1ce2274 100644 --- a/style/components/inputNumber.less +++ b/style/components/inputNumber.less @@ -90,11 +90,11 @@ cursor: pointer; &-inner { top: 2px; - left: 4px; - transform: rotate(270deg); - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=3); &:before { - content: "\e611"; + content: "\e600"; + filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); + -ms-transform: rotate(180deg); + transform: rotate(180deg); } } } @@ -103,10 +103,8 @@ cursor: pointer; &-inner { bottom: 2px; - transform: rotate(90deg); - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=1); &:before { - content: "\e611"; + content: "\e600"; } } } diff --git a/style/core/iconfont.less b/style/core/iconfont.less index 9be47d2ede..fd8f744ada 100644 --- a/style/core/iconfont.less +++ b/style/core/iconfont.less @@ -55,12 +55,11 @@ .@{iconfont-css-prefix}-retweet:before {content:"\e659";} .@{iconfont-css-prefix}-right:before {content:"\e611";} -.@{iconfont-css-prefix}-down {.ie-rotate(1);} -.@{iconfont-css-prefix}-down:before {content:"\e611";.rotate(90deg);} +.@{iconfont-css-prefix}-down:before {content:"\e600";} .@{iconfont-css-prefix}-left {.ie-rotate(2);} .@{iconfont-css-prefix}-left:before {content:"\e611";.rotate(180deg);} -.@{iconfont-css-prefix}-up {.ie-rotate(3);} -.@{iconfont-css-prefix}-up:before {content:"\e611";.rotate(270deg);} +.@{iconfont-css-prefix}-up {.ie-rotate(2);} +.@{iconfont-css-prefix}-up:before {content:"\e600";.rotate(180deg);} // 提示性图标 .@{iconfont-css-prefix}-question:before {content:"\e655";} diff --git a/style/themes/default/custom.less b/style/themes/default/custom.less index 7c330fbb79..e2ef6d7094 100644 --- a/style/themes/default/custom.less +++ b/style/themes/default/custom.less @@ -20,7 +20,7 @@ // ICONFONT @iconfont-css-prefix : anticon; -@icon-url : "//at.alicdn.com/t/font_1436443521_8072257"; +@icon-url : "//at.alicdn.com/t/font_1436496908_974446"; // LINK @link-color : @primary-color; From 1164ba22a7d92dc34759911a36201e574b5da6c4 Mon Sep 17 00:00:00 2001 From: simaQ Date: Fri, 10 Jul 2015 17:17:58 +0800 Subject: [PATCH 03/12] update iconfont --- components/iconfont/index.md | 6 +++--- style/core/iconfont.less | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/components/iconfont/index.md b/components/iconfont/index.md index 4e4e61f97d..97b15a0bf1 100644 --- a/components/iconfont/index.md +++ b/components/iconfont/index.md @@ -13,11 +13,11 @@ 我们为每个图标赋予了语义化的命名。我们的命名规范如: -- 1. 使用 `-` 来连接单词; +- 使用 `-` 来连接单词; -- 2. 实心和描线图标保持同名,用 `-o` 来区分,比如 `question-circle`(实心) 和 `question-circle-o`(描线); +- 实心和描线图标保持同名,用 `-o` 来区分,比如 `question-circle`(实心) 和 `question-circle-o`(描线); -- 3. 命名顺序:`[icon名]-[描线与否]-[方向]`。 +- 命名顺序:`[icon名]-[描线与否]-[方向]`。 每个图标的类名需要在图标名称前加上 `anticon-` 前缀,如 `.anticon-question-circle`。 diff --git a/style/core/iconfont.less b/style/core/iconfont.less index fd8f744ada..ae30d71664 100644 --- a/style/core/iconfont.less +++ b/style/core/iconfont.less @@ -124,6 +124,7 @@ .@{iconfont-css-prefix}-link:before {content:"\e640";} .@{iconfont-css-prefix}-logout:before {content:"\e642";} .@{iconfont-css-prefix}-mail:before {content:"\e643";} +.@{iconfont-css-prefix}-menu-fold {.ie-rotate(2);} .@{iconfont-css-prefix}-menu-fold:before {content:"\e645";.rotate(180deg);} .@{iconfont-css-prefix}-menu-unfold:before {content:"\e645";} .@{iconfont-css-prefix}-mobile:before {content:"\e649";} @@ -171,7 +172,8 @@ .@{iconfont-css-prefix}-circle-o-left, .@{iconfont-css-prefix}-double-left, .@{iconfont-css-prefix}-verticle-left, - .@{iconfont-css-prefix}-backward { + .@{iconfont-css-prefix}-backward, + .@{iconfont-css-prefix}-menu-fold { filter: none; } } From 2a49e993f1e8f684a7dbd38ec9b5c09fa63f17e2 Mon Sep 17 00:00:00 2001 From: yiminghe Date: Sat, 11 Jul 2015 01:27:34 +0800 Subject: [PATCH 04/12] remove ms-transform --- style/components/inputNumber.less | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/style/components/inputNumber.less b/style/components/inputNumber.less index f9b1ce2274..de9e6f8b7c 100644 --- a/style/components/inputNumber.less +++ b/style/components/inputNumber.less @@ -92,8 +92,7 @@ top: 2px; &:before { content: "\e600"; - filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); - -ms-transform: rotate(180deg); + .ie-rotate(2); transform: rotate(180deg); } } From 4c28bc1fe20018f6354e5de4418d73467b188b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=B0=E6=96=87?= Date: Sat, 11 Jul 2015 10:17:58 +0800 Subject: [PATCH 05/12] feat: add component collapse --- components/collapse/demo/accordion.md | 32 ++++++++++++ components/collapse/demo/basic.md | 36 +++++++++++++ components/collapse/index.jsx | 19 +++++++ components/collapse/index.md | 18 +++++++ index.js | 3 +- package.json | 2 +- style/components/collapse.less | 74 +++++++++++++++++++++++++++ style/components/index.less | 1 + 8 files changed, 183 insertions(+), 2 deletions(-) create mode 100644 components/collapse/demo/accordion.md create mode 100644 components/collapse/demo/basic.md create mode 100644 style/components/collapse.less diff --git a/components/collapse/demo/accordion.md b/components/collapse/demo/accordion.md new file mode 100644 index 0000000000..1aa15540e4 --- /dev/null +++ b/components/collapse/demo/accordion.md @@ -0,0 +1,32 @@ +# 手风琴 + +- order: 1 + +手风琴,每次只打开一个tab。默认打开第一个 + +--- + +````jsx +var Collapse = antd.Collapse; +var Panel = Collapse.Panel; + +var text = ` + A dog is a type of domesticated animal. + Known for its loyalty and faithfulness, + it can be found as a welcome guest in many households across the world. +`; + +React.render( + + +

{text}

+
+ +

{text}

+
+ +

{text}

+
+
+, document.getElementById('components-collapse-demo-accordion')); +```` diff --git a/components/collapse/demo/basic.md b/components/collapse/demo/basic.md new file mode 100644 index 0000000000..c54a3b408a --- /dev/null +++ b/components/collapse/demo/basic.md @@ -0,0 +1,36 @@ +# 折叠面板 + +- order: 0 + +默认打开第二个面板。 + +--- + +````jsx +var Collapse = antd.Collapse; +var Panel = Collapse.Panel; + +function callback(key) { + console.log(key); +} + +var text = ` + A dog is a type of domesticated animal. + Known for its loyalty and faithfulness, + it can be found as a welcome guest in many households across the world. +`; + +React.render( + + +

{text}

+
+ +

{text}

+
+ +

{text}

+
+
+, document.getElementById('components-collapse-demo-basic')); +```` diff --git a/components/collapse/index.jsx b/components/collapse/index.jsx index e69de29bb2..44c6c472b4 100644 --- a/components/collapse/index.jsx +++ b/components/collapse/index.jsx @@ -0,0 +1,19 @@ +'use strict'; + +var Collapse = require('rc-collapse'); +var React = require('react'); +var prefixCls = 'ant-collapse'; + +class AntCollapse extends React.Component { + render() { + return ; + } +} + +AntCollapse.defaultProps = { + prefixCls: prefixCls +}; + +AntCollapse.Panel = Collapse.Panel; + +module.exports = AntCollapse; diff --git a/components/collapse/index.md b/components/collapse/index.md index 62f17a27c1..4be652d261 100644 --- a/components/collapse/index.md +++ b/components/collapse/index.md @@ -11,3 +11,21 @@ - 对复杂区域进行分组和隐藏,保持页面的整洁。 - `手风琴` 是一种特殊的折叠面板,只允许单个内容区域展开。 + +## API + +### Collapse + +| 参数 | 说明 | 类型 | 默认值 | +|------------------|----------------------------------------------|----------|---------------------------------| +| activeKey | 当前激活 tab 面板的 key| Array or String | 默认无,accordion模式下默认第一个元素| +| defaultActiveKey | 初始化选中面板的 key | String | 无 | +| onChange | 切换面板的回调 | Function | 无 | + + +### Collapse.Panel + +| 参数 | 说明 | 类型 | 默认值 | +|------|------------------|-------------------------|--------| +| key | 对应 activeKey | String | 无 | +| header | 面板头内容 | React.Element or String | 无 | diff --git a/index.js b/index.js index b469467007..e896593490 100644 --- a/index.js +++ b/index.js @@ -15,7 +15,8 @@ var antd = { confirm: require('./components/modal/confirm'), Steps: require('./components/steps'), InputNumber: require('./components/input-number'), - Switch: require('./components/switch') + Switch: require('./components/switch'), + Collapse: require('./components/Collapse') }; module.exports = antd; diff --git a/package.json b/package.json index 34a441759d..e6a859a3a2 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "gregorian-calendar-format": "~3.0.1", "object-assign": "~3.0.0", "rc-calendar": "~3.10.0", + "rc-collapse": "~1.2.0", "rc-dialog": "~4.4.0", "rc-dropdown": "~1.1.1", "rc-input-number": "~2.0.1", @@ -48,7 +49,6 @@ "webpack": "^1.10.1", "webpack-dev-middleware": "^1.2.0" }, - "scripts": { "babel": "babel components --out-dir lib", "build": "npm run clean && webpack && nico build", diff --git a/style/components/collapse.less b/style/components/collapse.less new file mode 100644 index 0000000000..7d9e392a48 --- /dev/null +++ b/style/components/collapse.less @@ -0,0 +1,74 @@ +@prefixCls: ant-collapse; +@borderStyle: 1px solid #d9d9d9; + +#arrow { + .common(){ + width: 0; + height: 0; + font-size: 0; + line-height: 0; + } + .right(@w, @h, @color) { + border-top: @w solid transparent; + border-bottom: @w solid transparent; + border-left: @h solid @color; + } + + .bottom(@w, @h, @color) { + border-left: @w solid transparent; + border-right: @w solid transparent; + border-top: @h solid @color; + } +} + +.@{prefixCls} { + background-color: #f3f5f7; + border-radius: 3px; + border-top: @borderStyle; + border-left: @borderStyle; + border-right: @borderStyle; + + &-content { + height: 0; + opacity: 0; + transition-property: all; + transition-duration: .3s; + transition-timing-function: ease-in; + overflow: hidden; + color: #999; + padding: 0 16px; + background-color: #fbfbfb; + > p, div { + margin-top: 10px; + margin-bottom: 10px; + } + } + + &-content-active { + opacity: 1; + height: auto; + border-bottom: @borderStyle; + } + + &-header { + height: 38px; + line-height: 38px; + text-indent: 16px; + color: #666; + border-bottom: @borderStyle; + &:before { + display: inline-block; + content: '\20'; + #arrow > .common(); + #arrow > .right(3px, 4px, #666); + vertical-align: middle; + margin-right: 8px; + } + } + + &-item-active { + .@{prefixCls}-header::before { + #arrow > .bottom(3px, 4px, #666); + } + } +} diff --git a/style/components/index.less b/style/components/index.less index 2b88bf6cae..71cb926142 100644 --- a/style/components/index.less +++ b/style/components/index.less @@ -16,3 +16,4 @@ @import "breadcrumb"; @import "inputNumber"; @import "typography"; +@import "collapse"; From 599ea35ee62d9ac4e14e1a367f6116c0fb375a86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=B0=E6=96=87?= Date: Sat, 11 Jul 2015 10:34:05 +0800 Subject: [PATCH 06/12] feat(collapse): add demo nest collapse --- components/collapse/demo/mix.md | 40 +++++++++++++++++++++++++++++++++ style/components/collapse.less | 4 ++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 components/collapse/demo/mix.md diff --git a/components/collapse/demo/mix.md b/components/collapse/demo/mix.md new file mode 100644 index 0000000000..45054ebb16 --- /dev/null +++ b/components/collapse/demo/mix.md @@ -0,0 +1,40 @@ +# 面板嵌套 + +- order: 2 + +手风琴嵌套折叠面板 + +--- + +````jsx +var Collapse = antd.Collapse; +var Panel = Collapse.Panel; + +function callback(key) { + console.log(key); +} + +var text = ` + A dog is a type of domesticated animal. + Known for its loyalty and faithfulness, + it can be found as a welcome guest in many households across the world. +`; + +React.render( + + + + +

{text}

+
+
+
+ +

{text}

+
+ +

{text}

+
+
+, document.getElementById('components-collapse-demo-mix')); +```` diff --git a/style/components/collapse.less b/style/components/collapse.less index 7d9e392a48..2736618ddb 100644 --- a/style/components/collapse.less +++ b/style/components/collapse.less @@ -32,13 +32,13 @@ height: 0; opacity: 0; transition-property: all; - transition-duration: .3s; + transition-duration: .2s; transition-timing-function: ease-in; overflow: hidden; color: #999; padding: 0 16px; background-color: #fbfbfb; - > p, div { + > p, > div { margin-top: 10px; margin-bottom: 10px; } From 41244d83def6283051cd547b5846627f095532bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=B0=E6=96=87?= Date: Sat, 11 Jul 2015 16:40:59 +0800 Subject: [PATCH 07/12] feat: add message component Conflicts: index.js style/components/index.less --- components/message/demo/error.md | 20 +++++++ components/message/demo/info.md | 20 +++++++ components/message/demo/success.md | 22 +++++++ components/message/index.jsx | 68 +++++++++++++++++++++ components/message/index.md | 1 + index.js | 3 +- package.json | 3 +- style/components/index.less | 1 + style/components/message.less | 96 ++++++++++++++++++++++++++++++ 9 files changed, 232 insertions(+), 2 deletions(-) create mode 100644 components/message/demo/error.md create mode 100644 components/message/demo/info.md create mode 100644 components/message/demo/success.md create mode 100644 style/components/message.less diff --git a/components/message/demo/error.md b/components/message/demo/error.md new file mode 100644 index 0000000000..26dd948dc1 --- /dev/null +++ b/components/message/demo/error.md @@ -0,0 +1,20 @@ +# 基本 + +- order: 1 + +全局提示 - 操作警告 + +--- + +````jsx + +var message = antd.message; +var error = function(){ + message.error('这是一条失败的提示这是一条失败的提示这是一条失败的提示'); +} + +React.render( + , document.getElementById('components-message-demo-error') +); + +```` \ No newline at end of file diff --git a/components/message/demo/info.md b/components/message/demo/info.md new file mode 100644 index 0000000000..6223fba2af --- /dev/null +++ b/components/message/demo/info.md @@ -0,0 +1,20 @@ +# 基本 + +- order: 2 + +全局提示 - 需求帮助 + +--- + +````jsx + +var message = antd.message; +var info = function(){ + message.info('这是一条普通的提示'); +} + +React.render( + , document.getElementById('components-message-demo-info') +); + +```` \ No newline at end of file diff --git a/components/message/demo/success.md b/components/message/demo/success.md new file mode 100644 index 0000000000..17b626cec9 --- /dev/null +++ b/components/message/demo/success.md @@ -0,0 +1,22 @@ + +# 基本 + +- order: 0 + +全局提示 - 操作成功提示 + +--- + +````jsx + +var message = antd.message; +var success = function(){ + message.success('这是一条成功的提示'); +} + +React.render( + , document.getElementById('components-message-demo-success') +); + +```` + diff --git a/components/message/index.jsx b/components/message/index.jsx index e69de29bb2..5695b31f99 100644 --- a/components/message/index.jsx +++ b/components/message/index.jsx @@ -0,0 +1,68 @@ +'use strict'; + +//import React from 'react'; +import Notification from 'rc-notification'; + +var message; + +var getMessageInstance = function(){ + message = Notification.newInstance({ + prefixCls: 'ant-message', + transitionName: 'move-up', + style: { + top: '16px' + } + }); + return message; +}; + + +module.exports = { + + info: function(m) { + if (!message) { + message = getMessageInstance(); + } + + message.notice({ + key: 'simpleMessage', + duration: 2.5, + style: { + left: '50%' + }, + content:
{m}
+ }); + }, + success: function(m) { + + if (!message) { + message = getMessageInstance(); + } + + message.notice({ + key: 'simpleMessage1', + transitionName: 'move-up', + duration: 2.5, + style: { + left: '50%' + }, + content:
{m}
+ }); + }, + error: function(m) { + + if (!message) { + message = getMessageInstance(); + } + + message.notice({ + key: 'simpleMessage2', + transitionName: 'move-up', + duration: 2.5, + style: { + left: '50%' + }, + content:
{m}
+ }); + } +}; diff --git a/components/message/index.md b/components/message/index.md index d97fc43b0c..144722a09b 100644 --- a/components/message/index.md +++ b/components/message/index.md @@ -2,6 +2,7 @@ - category: Components - chinese: 全局提示 +- order: 3 --- diff --git a/index.js b/index.js index e896593490..0ba737cd24 100644 --- a/index.js +++ b/index.js @@ -16,7 +16,8 @@ var antd = { Steps: require('./components/steps'), InputNumber: require('./components/input-number'), Switch: require('./components/switch'), - Collapse: require('./components/Collapse') + Collapse: require('./components/Collapse'), + message: require('./components/message') }; module.exports = antd; diff --git a/package.json b/package.json index e6a859a3a2..5b7feece11 100644 --- a/package.json +++ b/package.json @@ -27,7 +27,8 @@ "rc-steps": "~1.1.3", "rc-switch": "~1.2.0", "rc-tabs": "~5.2.0", - "rc-tooltip": "~2.4.0" + "rc-tooltip": "~2.4.0", + "rc-notification": "~1.0.1" }, "devDependencies": { "css-animation": "~1.0.3", diff --git a/style/components/index.less b/style/components/index.less index 71cb926142..c4782f3612 100644 --- a/style/components/index.less +++ b/style/components/index.less @@ -17,3 +17,4 @@ @import "inputNumber"; @import "typography"; @import "collapse"; +@import "message"; diff --git a/style/components/message.less b/style/components/message.less new file mode 100644 index 0000000000..5006920dbd --- /dev/null +++ b/style/components/message.less @@ -0,0 +1,96 @@ +@prefixMessageClass: ant-message; + +.@{prefixMessageClass} { + font-size: 12px; + position: fixed; + z-index: 1000; + width: 100%; + + &-notice { + + width: auto; + vertical-align: middle; + position: absolute; + } + + &-notice-content{ + position: relative; + right: 50%; + padding: 8px 16px; + border-radius: 6px; + border: 1px solid #e9e9e9;; + box-shadow: 0 0 4px #d9d9d9; + background: #fff; + display: block; + } + + &-custom-content{ + height: 12px; + position: relative; + top: -8px; + } + + &-success { + color: #87d068; + } + + &-error { + color: #ff6600; + } + + &-info { + color: #2db7f5; + } + + .anticon{ + width: 16px; + height: 16px; + font-size: 16px; + margin-right: 8px; + } + + .fade-effect() { + animation-duration: 0.3s; + animation-fill-mode: both; + animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); + } + + &-fade-enter { + opacity: 0; + .fade-effect(); + animation-play-state: paused; + } + + &-fade-leave { + .fade-effect(); + animation-play-state: paused; + } + + &-fade-enter&-fade-enter-active { + animation-name: rcNotificationFadeIn; + animation-play-state: running; + } + + &-fade-leave&-fade-leave-active { + animation-name: rcDialogFadeOut; + animation-play-state: running; + } + + @keyframes rcNotificationFadeIn { + 0% { + opacity: 0; + } + 100% { + opacity: 1; + } + } + + @keyframes rcDialogFadeOut { + 0% { + opacity: 1; + } + 100% { + opacity: 0; + } + } +} From 69c2a4c2771be94b42dfde9a216c7339c818c768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E5=AF=82?= Date: Sat, 11 Jul 2015 11:27:10 +0800 Subject: [PATCH 08/12] chore: adjust coding style, delete useless less, modify md files. --- components/message/demo/costomTime.md | 22 ++++++++++++++ components/message/demo/error.md | 2 +- components/message/demo/info.md | 6 ++-- components/message/index.jsx | 33 ++++++++++++-------- components/message/index.md | 2 +- style/components/message.less | 44 --------------------------- 6 files changed, 48 insertions(+), 61 deletions(-) create mode 100644 components/message/demo/costomTime.md diff --git a/components/message/demo/costomTime.md b/components/message/demo/costomTime.md new file mode 100644 index 0000000000..78aea1af84 --- /dev/null +++ b/components/message/demo/costomTime.md @@ -0,0 +1,22 @@ + +# 基本 + +- order: 4 + +全局提示 - 操作成功提示,并自定义时长10s,默认时长2.5s + +--- + +````jsx + +var message = antd.message; +var success = function(){ + message.success('这是一条成功的提示,并将于10秒后消失',10); +} + +React.render( + , document.getElementById('components-message-demo-costomtime') +); + +```` + diff --git a/components/message/demo/error.md b/components/message/demo/error.md index 26dd948dc1..3a8f1348c7 100644 --- a/components/message/demo/error.md +++ b/components/message/demo/error.md @@ -2,7 +2,7 @@ - order: 1 -全局提示 - 操作警告 +全局提示 - 操作失败 --- diff --git a/components/message/demo/info.md b/components/message/demo/info.md index 6223fba2af..429e467efd 100644 --- a/components/message/demo/info.md +++ b/components/message/demo/info.md @@ -2,7 +2,7 @@ - order: 2 -全局提示 - 需求帮助 +全局提示 - 提醒 --- @@ -10,11 +10,11 @@ var message = antd.message; var info = function(){ - message.info('这是一条普通的提示'); + message.info('这是一条普通的提醒'); } React.render( - , document.getElementById('components-message-demo-info') + , document.getElementById('components-message-demo-info') ); ```` \ No newline at end of file diff --git a/components/message/index.jsx b/components/message/index.jsx index 5695b31f99..39182d8ff7 100644 --- a/components/message/index.jsx +++ b/components/message/index.jsx @@ -19,50 +19,59 @@ var getMessageInstance = function(){ module.exports = { - info: function(m) { + info: function(m, t) { if (!message) { message = getMessageInstance(); } - + t = t || 2.5; message.notice({ key: 'simpleMessage', - duration: 2.5, + duration: t, style: { left: '50%' }, - content:
{m}
+ content:
+ + {m} +
}); }, - success: function(m) { + success: function(m, t) { if (!message) { message = getMessageInstance(); } - + t = t || 2.5; message.notice({ key: 'simpleMessage1', transitionName: 'move-up', - duration: 2.5, + duration: t, style: { left: '50%' }, - content:
{m}
+ content:
+ + {m} +
}); }, - error: function(m) { + error: function(m, t) { if (!message) { message = getMessageInstance(); } - + t = t || 2.5; message.notice({ key: 'simpleMessage2', transitionName: 'move-up', - duration: 2.5, + duration: t, style: { left: '50%' }, - content:
{m}
+ content:
+ + {m} +
}); } }; diff --git a/components/message/index.md b/components/message/index.md index 144722a09b..139834420c 100644 --- a/components/message/index.md +++ b/components/message/index.md @@ -2,7 +2,7 @@ - category: Components - chinese: 全局提示 -- order: 3 +- order: 4 --- diff --git a/style/components/message.less b/style/components/message.less index 5006920dbd..3419b56dba 100644 --- a/style/components/message.less +++ b/style/components/message.less @@ -49,48 +49,4 @@ margin-right: 8px; } - .fade-effect() { - animation-duration: 0.3s; - animation-fill-mode: both; - animation-timing-function: cubic-bezier(0.55, 0, 0.55, 0.2); - } - - &-fade-enter { - opacity: 0; - .fade-effect(); - animation-play-state: paused; - } - - &-fade-leave { - .fade-effect(); - animation-play-state: paused; - } - - &-fade-enter&-fade-enter-active { - animation-name: rcNotificationFadeIn; - animation-play-state: running; - } - - &-fade-leave&-fade-leave-active { - animation-name: rcDialogFadeOut; - animation-play-state: running; - } - - @keyframes rcNotificationFadeIn { - 0% { - opacity: 0; - } - 100% { - opacity: 1; - } - } - - @keyframes rcDialogFadeOut { - 0% { - opacity: 1; - } - 100% { - opacity: 0; - } - } } From 4095e3eccbd4244e7e50a8730ee4105236857095 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=84=E5=AF=82?= Date: Fri, 10 Jul 2015 22:59:50 +0800 Subject: [PATCH 09/12] feat: add message component --- components/message/demo/costomTime.md | 1 - components/message/demo/success.md | 1 - components/message/index.md | 1 + style/components/message.less | 1 - 4 files changed, 1 insertion(+), 3 deletions(-) diff --git a/components/message/demo/costomTime.md b/components/message/demo/costomTime.md index 78aea1af84..3bb76d9e08 100644 --- a/components/message/demo/costomTime.md +++ b/components/message/demo/costomTime.md @@ -1,4 +1,3 @@ - # 基本 - order: 4 diff --git a/components/message/demo/success.md b/components/message/demo/success.md index 17b626cec9..27423ec013 100644 --- a/components/message/demo/success.md +++ b/components/message/demo/success.md @@ -1,4 +1,3 @@ - # 基本 - order: 0 diff --git a/components/message/index.md b/components/message/index.md index 139834420c..503dc1b175 100644 --- a/components/message/index.md +++ b/components/message/index.md @@ -2,6 +2,7 @@ - category: Components - chinese: 全局提示 + - order: 4 --- diff --git a/style/components/message.less b/style/components/message.less index 3419b56dba..395c6f49bb 100644 --- a/style/components/message.less +++ b/style/components/message.less @@ -48,5 +48,4 @@ font-size: 16px; margin-right: 8px; } - } From 8ae46a9282f8cd3fb78f5b3bdb666c6ed8d80ff7 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 11 Jul 2015 18:00:58 +0800 Subject: [PATCH 10/12] improve message component --- components/message/demo/costomTime.md | 12 +++++------ components/message/demo/error.md | 14 ++++++------- components/message/demo/info.md | 14 ++++++------- components/message/demo/success.md | 13 +++++------- components/message/index.jsx | 29 +++++++++------------------ components/message/index.md | 14 ++++++++++++- style/components/message.less | 27 ++++++++++--------------- 7 files changed, 55 insertions(+), 68 deletions(-) diff --git a/components/message/demo/costomTime.md b/components/message/demo/costomTime.md index 3bb76d9e08..184cb3de0b 100644 --- a/components/message/demo/costomTime.md +++ b/components/message/demo/costomTime.md @@ -2,20 +2,18 @@ - order: 4 -全局提示 - 操作成功提示,并自定义时长10s,默认时长2.5s +全局提示 - 操作成功提示,并自定义时长`10s`,默认时长`2.5s`。 --- ````jsx var message = antd.message; -var success = function(){ +var success = function() { message.success('这是一条成功的提示,并将于10秒后消失',10); -} - -React.render( - , document.getElementById('components-message-demo-costomtime') -); +}; +React.render( +, document.getElementById('components-message-demo-duration')); ```` diff --git a/components/message/demo/error.md b/components/message/demo/error.md index 3a8f1348c7..f2dd7767c9 100644 --- a/components/message/demo/error.md +++ b/components/message/demo/error.md @@ -2,19 +2,17 @@ - order: 1 -全局提示 - 操作失败 +全局提示 - 操作失败反馈。 --- ````jsx var message = antd.message; -var error = function(){ +var error = function() { message.error('这是一条失败的提示这是一条失败的提示这是一条失败的提示'); -} +}; -React.render( - , document.getElementById('components-message-demo-error') -); - -```` \ No newline at end of file +React.render( +, document.getElementById('components-message-demo-error')); +```` diff --git a/components/message/demo/info.md b/components/message/demo/info.md index 429e467efd..fa315b77b1 100644 --- a/components/message/demo/info.md +++ b/components/message/demo/info.md @@ -2,19 +2,17 @@ - order: 2 -全局提示 - 提醒 +全局提示 - 提醒反馈。 --- ````jsx var message = antd.message; -var info = function(){ +var info = function() { message.info('这是一条普通的提醒'); -} +}; -React.render( - , document.getElementById('components-message-demo-info') -); - -```` \ No newline at end of file +React.render( +, document.getElementById('components-message-demo-info')); +```` diff --git a/components/message/demo/success.md b/components/message/demo/success.md index 27423ec013..4df02f5153 100644 --- a/components/message/demo/success.md +++ b/components/message/demo/success.md @@ -2,20 +2,17 @@ - order: 0 -全局提示 - 操作成功提示 +全局提示 - 操作成功提示。 --- ````jsx - var message = antd.message; -var success = function(){ +var success = function() { message.success('这是一条成功的提示'); -} - -React.render( - , document.getElementById('components-message-demo-success') -); +}; +React.render( +, document.getElementById('components-message-demo-success')); ```` diff --git a/components/message/index.jsx b/components/message/index.jsx index 39182d8ff7..b6cac73139 100644 --- a/components/message/index.jsx +++ b/components/message/index.jsx @@ -3,27 +3,22 @@ //import React from 'react'; import Notification from 'rc-notification'; -var message; +var defaultDuration = 2.5; var getMessageInstance = function(){ - message = Notification.newInstance({ + return Notification.newInstance({ prefixCls: 'ant-message', transitionName: 'move-up', style: { top: '16px' } }); - return message; }; - -module.exports = { - +export default { info: function(m, t) { - if (!message) { - message = getMessageInstance(); - } - t = t || 2.5; + var message = getMessageInstance(); + t = t || defaultDuration; message.notice({ key: 'simpleMessage', duration: t, @@ -37,11 +32,8 @@ module.exports = { }); }, success: function(m, t) { - - if (!message) { - message = getMessageInstance(); - } - t = t || 2.5; + var message = getMessageInstance(); + t = t || defaultDuration; message.notice({ key: 'simpleMessage1', transitionName: 'move-up', @@ -56,11 +48,8 @@ module.exports = { }); }, error: function(m, t) { - - if (!message) { - message = getMessageInstance(); - } - t = t || 2.5; + var message = getMessageInstance(); + t = t || defaultDuration; message.notice({ key: 'simpleMessage2', transitionName: 'move-up', diff --git a/components/message/index.md b/components/message/index.md index 503dc1b175..764ad3117d 100644 --- a/components/message/index.md +++ b/components/message/index.md @@ -2,7 +2,6 @@ - category: Components - chinese: 全局提示 - - order: 4 --- @@ -13,3 +12,16 @@ - 可提供成功、警告和错误等反馈信息。 - 顶部居中显示并自动消失,是一种不打断用户操作的轻量级提示方式。 + +## API + +- `message.success(content, duration)` +- `message.error(content, duration)` +- `message.info(content, duration)` + +组件提供了三个静态方法,参数如下: + +| 参数 | 说明 | 类型 | 默认值 | +|------------|----------------|----------------------------|--------------| +| content | 提示内容 | React.Element or String | 无 | +| duration | 自动关闭的延时 | number | 2.5 | diff --git a/style/components/message.less b/style/components/message.less index 395c6f49bb..89fd6bc6bc 100644 --- a/style/components/message.less +++ b/style/components/message.less @@ -7,45 +7,40 @@ width: 100%; &-notice { - width: auto; vertical-align: middle; position: absolute; } - &-notice-content{ + &-notice-content { position: relative; right: 50%; padding: 8px 16px; - border-radius: 6px; - border: 1px solid #e9e9e9;; - box-shadow: 0 0 4px #d9d9d9; + border-radius: @border-radius-base; + border: 1px solid #e9e9e9; + box-shadow: 0 0 4px rgba(0,0,0,0.16); background: #fff; display: block; } - &-custom-content{ - height: 12px; - position: relative; - top: -8px; + &-custom-content { } &-success { - color: #87d068; + color: @success-color; } &-error { - color: #ff6600; + color: @error-color; } &-info { - color: #2db7f5; + color: @primary-color; } - .anticon{ - width: 16px; - height: 16px; - font-size: 16px; + .anticon { margin-right: 8px; + position: relative; + top: -1px; } } From 5eb7ed9ff239d64da72ae4bcd42fefe7899a587f Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 11 Jul 2015 18:19:48 +0800 Subject: [PATCH 11/12] move message style to less file --- .../demo/{costomTime.md => duration.md} | 4 ++-- components/message/index.jsx | 18 +++++------------- components/message/index.md | 2 +- style/components/message.less | 5 +++-- 4 files changed, 11 insertions(+), 18 deletions(-) rename components/message/demo/{costomTime.md => duration.md} (92%) diff --git a/components/message/demo/costomTime.md b/components/message/demo/duration.md similarity index 92% rename from components/message/demo/costomTime.md rename to components/message/demo/duration.md index 184cb3de0b..b230a0bf41 100644 --- a/components/message/demo/costomTime.md +++ b/components/message/demo/duration.md @@ -2,7 +2,7 @@ - order: 4 -全局提示 - 操作成功提示,并自定义时长`10s`,默认时长`2.5s`。 +全局提示 - 操作成功提示,并自定义时长`10s`,默认时长`1.5s`。 --- @@ -10,7 +10,7 @@ var message = antd.message; var success = function() { - message.success('这是一条成功的提示,并将于10秒后消失',10); + message.success('这是一条成功的提示,并将于10秒后消失', 10); }; React.render( diff --git a/components/message/index.jsx b/components/message/index.jsx index b6cac73139..dbef951ba1 100644 --- a/components/message/index.jsx +++ b/components/message/index.jsx @@ -3,15 +3,13 @@ //import React from 'react'; import Notification from 'rc-notification'; -var defaultDuration = 2.5; +var defaultDuration = 1.5; var getMessageInstance = function(){ return Notification.newInstance({ prefixCls: 'ant-message', transitionName: 'move-up', - style: { - top: '16px' - } + style: {} // 覆盖原来的样式 }); }; @@ -22,9 +20,7 @@ export default { message.notice({ key: 'simpleMessage', duration: t, - style: { - left: '50%' - }, + style: {}, content:
{m} @@ -38,9 +34,7 @@ export default { key: 'simpleMessage1', transitionName: 'move-up', duration: t, - style: { - left: '50%' - }, + style: {}, content:
{m} @@ -54,9 +48,7 @@ export default { key: 'simpleMessage2', transitionName: 'move-up', duration: t, - style: { - left: '50%' - }, + style: {}, content:
{m} diff --git a/components/message/index.md b/components/message/index.md index 764ad3117d..7ada812017 100644 --- a/components/message/index.md +++ b/components/message/index.md @@ -24,4 +24,4 @@ | 参数 | 说明 | 类型 | 默认值 | |------------|----------------|----------------------------|--------------| | content | 提示内容 | React.Element or String | 无 | -| duration | 自动关闭的延时 | number | 2.5 | +| duration | 自动关闭的延时 | number | 1.5 | diff --git a/style/components/message.less b/style/components/message.less index 89fd6bc6bc..616dcd24c8 100644 --- a/style/components/message.less +++ b/style/components/message.less @@ -5,11 +5,13 @@ position: fixed; z-index: 1000; width: 100%; + top: 60px; &-notice { width: auto; vertical-align: middle; position: absolute; + left: 50%; } &-notice-content { @@ -40,7 +42,6 @@ .anticon { margin-right: 8px; - position: relative; - top: -1px; + font-size: 14px; } } From ce1d6705a40ba400f63f236c2ab292105f9591e4 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 11 Jul 2015 18:22:35 +0800 Subject: [PATCH 12/12] fix top --- style/components/message.less | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/style/components/message.less b/style/components/message.less index 616dcd24c8..be2bd0d651 100644 --- a/style/components/message.less +++ b/style/components/message.less @@ -5,7 +5,7 @@ position: fixed; z-index: 1000; width: 100%; - top: 60px; + top: 16px; &-notice { width: auto;