From 8dad4d26c09d8c3cc155cb684273b5e81a1d23c0 Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 21 Nov 2015 15:29:33 +0800 Subject: [PATCH] Make header and close x isolate --- assets/index/Dialog.less | 5 +++-- src/Dialog.jsx | 15 +++++++++------ tests/index.spec.js | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/assets/index/Dialog.less b/assets/index/Dialog.less index 62dfa4f4..11783342 100644 --- a/assets/index/Dialog.less +++ b/assets/index/Dialog.less @@ -28,9 +28,10 @@ &-close { cursor: pointer; outline: none; - margin-top: -2px; - float: right; font-size: 21px; + position: absolute; + right: 20px; + top: 12px; font-weight: 700; line-height: 1; color: #000; diff --git a/src/Dialog.jsx b/src/Dialog.jsx index 4d1cafca..29daa61a 100644 --- a/src/Dialog.jsx +++ b/src/Dialog.jsx @@ -151,17 +151,19 @@ const Dialog = React.createClass({ } let header; - if (props.title || props.closable) { + if (props.title) { header = (
- {closable ? - ( - - ) : - null}
{props.title}
); } + let closer; + if (closable) { + closer = ( + + ); + } + const style = assign({}, props.style, dest); const dialogProps = { className: [props.prefixCls, props.className].join(' '), @@ -175,6 +177,7 @@ const Dialog = React.createClass({ const dialogElement = (
+ {closer} {header}
{props.children}
{footer} diff --git a/tests/index.spec.js b/tests/index.spec.js index 613608d2..133e72ec 100644 --- a/tests/index.spec.js +++ b/tests/index.spec.js @@ -85,7 +85,7 @@ describe('dialog', function () { }); setTimeout(done, 10); }, function (done) { - var btn = $('.rc-dialog-header a')[0]; + var btn = $('.rc-dialog-close')[0]; Simulate.click(btn); setTimeout(done, 10); }, function (done) {