diff --git a/CHANGELOG.md b/CHANGELOG.md index a329de7e7d..082062b184 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,27 @@ timeline: true --- +## 1.6.0 + +`2016-06-24` + +- 新增置顶组件 [BackTop](/components/back-top)。 +- 全新的 [Spin](/components/spin) 样式。 +- 给 `Modal.xxx` 系列方法添加了 `{ destory }` 的访问值,方便事后销毁。[#2110](https://github.com/ant-design/ant-design/issues/2110) +- Table 的 `rowKey` 属性支持直接使用字符串。[#2058](https://github.com/ant-design/ant-design/issues/2058) +- Table 增加 `column.filterDropdown` 属性用于自定义渲染筛选菜单的浮层。[#1736](https://github.com/ant-design/ant-design/issues/1736) +- 修复 Tooltip、Popover、Popconfirm 设置 `onVisibleChange` 后失效的问题。[#2134](https://github.com/ant-design/ant-design/issues/2134) +- 修复在 IE8 下 Checkbox 的勾样式变形的问题。[#2148](https://github.com/ant-design/ant-design/issues/2148) +- 优化 Checkbox、Radio 失效状态的文字颜色。[#2114](https://github.com/ant-design/ant-design/issues/2114) +- 优化 Checkbox、Radio 的默认边距过于拥挤的问题。[#2137](https://github.com/ant-design/ant-design/issues/2137) +- 优化 Pagination 在暗色背景下的样式。[#2126](https://github.com/ant-design/ant-design/issues/2126) +- 修复 Table 固定列时内容无法换行和高度对齐的问题,同时修复了一个 Chrome 下的表格内容错位问题。[#2130](https://github.com/ant-design/ant-design/issues/2130) +- 修复一个 Table 的 `rowSelection` 设为 null 时可能导致报错的问题。[#2127](https://github.com/ant-design/ant-design/issues/2127) +- 修复在 IE8 下点击 Table 选择框报错的问题。[#2154](https://github.com/ant-design/ant-design/issues/2154) +- 小幅优化了 Transfer 的渲染性能。[#2112](https://github.com/ant-design/ant-design/issues/2112) +- 将 DatePicker 的清除按钮从面板上移到外部输入框,解决用户容易误解为关闭的问题。[#1708](https://github.com/ant-design/ant-design/issues/1708) +- Upload 的 `onPreview` 现在没有 `file.url` 时也能生效。[#2163](https://github.com/ant-design/ant-design/issues/2163) + ## 1.5.1 `2016-06-21` @@ -44,6 +65,8 @@ timeline: true `2016-06-12` +此版本之后你可能会遇到 [#2030](https://github.com/ant-design/ant-design/issues/2030),请使用 `react@15+` 或 `npm@3+`。 + - `Input[type="textarea"]` 支持自动调整高度。 [#](http://ant.design/components/input#components-input-demo-autosize-textarea) - `Breadcrumb` - `nameRender` 新增 `route` 和 `params` 参数。 [#1999](https://github.com/ant-design/ant-design/issues/1999) diff --git a/components/back-top/demo/basic.md b/components/back-top/demo/basic.md new file mode 100644 index 0000000000..d213ef2dc8 --- /dev/null +++ b/components/back-top/demo/basic.md @@ -0,0 +1,17 @@ +--- +order: 0 +title: 基本 +--- + +最简单的用法。 + +````jsx +import { BackTop } from 'antd'; + +ReactDOM.render( +
+ + 向下滚动后,见右下角灰色按钮 +
+, mountNode); +```` diff --git a/components/back-top/demo/custom.md b/components/back-top/demo/custom.md new file mode 100644 index 0000000000..88cc67b1f2 --- /dev/null +++ b/components/back-top/demo/custom.md @@ -0,0 +1,30 @@ +--- +order: 1 +title: 自定义样式 +--- + +可以自定义置顶按钮的样式,限制宽高:`40px * 40px`。 + +````jsx +import { BackTop } from 'antd'; + +const style = { + height: 40, + width: 40, + lineHeight: '40px', + borderRadius: 4, + backgroundColor: '#57c5f7', + color: '#fff', + textAlign: 'center', + fontSize: 20, +}; + +ReactDOM.render( +
+ +
UP
+
+ 向下滚动后,见右下角蓝色按钮 +
+, mountNode); +```` diff --git a/components/back-top/index.jsx b/components/back-top/index.jsx new file mode 100644 index 0000000000..7450b7b66c --- /dev/null +++ b/components/back-top/index.jsx @@ -0,0 +1,109 @@ +import React from 'react'; +import Animate from 'rc-animate'; +import Icon from '../icon'; +import addEventListener from 'rc-util/lib/Dom/addEventListener'; +import classNames from 'classnames'; + +function getScroll(w, top) { + let ret = w[`page${top ? 'Y' : 'X'}Offset`]; + const method = `scroll${top ? 'Top' : 'Left'}`; + if (typeof ret !== 'number') { + const d = w.document; + // ie6,7,8 standard mode + ret = d.documentElement[method]; + if (typeof ret !== 'number') { + // quirks mode + ret = d.body[method]; + } + } + return ret; +} + +export default class BackTop extends React.Component { + + static propTypes = { + visibilityHeight: React.PropTypes.number, + } + + static defaultProps = { + onClick() {}, + visibilityHeight: 400, + prefixCls: 'ant-back-top', + } + + constructor(props) { + super(props); + const scrollTop = getScroll(window, true); + this.state = { + visible: scrollTop > this.props.visibilityHeight, + }; + } + + scrollToTop = (e) => { + if (e) e.preventDefault(); + this.setScrollTop(0); + this.props.onClick(e); + } + + setScrollTop(value) { + document.body.scrollTop = value; + document.documentElement.scrollTop = value; + } + + handleScroll = () => { + const scrollTop = getScroll(window, true); + this.setState({ + visible: scrollTop > this.props.visibilityHeight, + }); + } + + animationEnd = () => { + const scrollTop = getScroll(window, true); + this.setState({ + visible: scrollTop > this.props.visibilityHeight, + }); + } + + componentDidMount() { + this.scrollEvent = addEventListener(window, 'scroll', this.handleScroll); + } + + componentWillUnmount() { + if (this.scrollEvent) { + this.scrollEvent.remove(); + } + } + + render() { + const { prefixCls, className, children, ...restProps } = this.props; + const classString = classNames({ + [prefixCls]: true, + [className]: !!className, + }); + + const defaultElement = ( +
+ +
+ ); + + const style = { + display: this.state.visible ? 'block' : 'none', + }; + + return ( + +
+
+ {children || defaultElement} +
+
+
+ ); + } +} diff --git a/components/back-top/index.md b/components/back-top/index.md new file mode 100644 index 0000000000..c6b2740794 --- /dev/null +++ b/components/back-top/index.md @@ -0,0 +1,23 @@ +--- +category: Components +chinese: 置顶 +type: Other +english: BackTop +--- + +使用置顶组件可以方便地回到页面顶部。 + +## 何时使用 + +- 当页面内容区域比较长时; +- 当用户需要频繁返回顶部查看相关内容时。 + +## API + +> 有默认样式,距离底部 `50px`,可覆盖。 +> 自定义样式宽高不大于 40px * 40px。 + +| 参数 | 说明 | 类型 | 默认值 | +|-------------|----------------|--------------------|--------------| +| visibilityHeight | 滚动高度达到此参数值才出现 `BackTop` | Number | 400 | +| onClick | 点击按钮的回调函数 | Function | - | diff --git a/components/back-top/style/index.js b/components/back-top/style/index.js new file mode 100644 index 0000000000..3a3ab0de59 --- /dev/null +++ b/components/back-top/style/index.js @@ -0,0 +1,2 @@ +import '../../style/index.less'; +import './index.less'; diff --git a/components/back-top/style/index.less b/components/back-top/style/index.less new file mode 100644 index 0000000000..c96e94552d --- /dev/null +++ b/components/back-top/style/index.less @@ -0,0 +1,33 @@ +@import "../../style/themes/default"; + +@backtop-prefix-cls: ant-back-top; + +.@{backtop-prefix-cls} { + z-index: @zindex-back-top; + position: fixed; + right: 100px; + bottom: 50px; + height: 40px; + width: 40px; + cursor: pointer; + + &-content { + height: 40px; + width: 40px; + border-radius: 20px; + background-color: rgba(64, 64, 64, 0.4); + color: #fff; + text-align: center; + transition: all .3s @ease-in-out; + + &:hover { + background-color: rgba(64, 64, 64, 0.6); + transition: all .3s @ease-in-out; + } + } + + &-icon { + font-size: 20px; + margin-top: 10px; + } +} diff --git a/components/style/themes/default.less b/components/style/themes/default.less index f3dcb3a30d..01be373723 100644 --- a/components/style/themes/default.less +++ b/components/style/themes/default.less @@ -119,6 +119,7 @@ // z-index list @zindex-affix : 10; +@zindex-back-top : 10; @zindex-modal-mask : 1000; @zindex-modal : 1000; @zindex-notification : 1010; diff --git a/components/upload/uploadList.tsx b/components/upload/uploadList.tsx index 54131b09c3..6f9b358d4b 100644 --- a/components/upload/uploadList.tsx +++ b/components/upload/uploadList.tsx @@ -100,23 +100,31 @@ export default class UploadList extends React.Component { file.url ? ( this.handlePreview(file, e)} - href={file.url} target="_blank" + href={file.url} + target="_blank" className={`${prefixCls}-list-item-name`} + onClick={e => this.handlePreview(file, e)} > {file.name} - ) : {file.name} + ) : ( + this.handlePreview(file, e)} + > + {file.name} + + ) } { this.props.listType === 'picture-card' && file.status !== 'uploading' ? ( this.handlePreview(file, e)} href={file.url} target="_blank" style={{ pointerEvents: file.url ? '' : 'none' }} + onClick={e => this.handlePreview(file, e)} > diff --git a/docs/react/install.en-US.md b/docs/react/install.en-US.md index 615ee6627c..cf56c325f3 100644 --- a/docs/react/install.en-US.md +++ b/docs/react/install.en-US.md @@ -18,6 +18,9 @@ Stable version: $ npm install antd --save ``` +You can Subscribe to this feed for new version notification: https://github.com/ant-design/ant-design/releases.atom + + Beta version: [![](https://cnpmjs.org/badge/v/antd.svg?&tag=beta&subject=npm)](https://www.npmjs.org/package/antd) diff --git a/docs/react/install.zh-CN.md b/docs/react/install.zh-CN.md index 7268dbe3ed..0ecc24744a 100644 --- a/docs/react/install.zh-CN.md +++ b/docs/react/install.zh-CN.md @@ -17,6 +17,8 @@ title: 安装 $ npm install antd --save ``` +你可以订阅:https://github.com/ant-design/ant-design/releases.atom 来获得稳定版发布的通知。 + 开发版本: [![](https://cnpmjs.org/badge/v/antd.svg?&tag=beta&subject=npm)](https://www.npmjs.org/package/antd) diff --git a/package.json b/package.json index b2f7a67bfe..c219c40ab3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "antd", - "version": "1.5.1", + "version": "1.6.0", "title": "Ant Design", "description": "一个 UI 设计语言", "homepage": "http://ant.design/", diff --git a/site/theme/template/Content/MainContent.jsx b/site/theme/template/Content/MainContent.jsx index cbe7899651..f54d4ce64c 100644 --- a/site/theme/template/Content/MainContent.jsx +++ b/site/theme/template/Content/MainContent.jsx @@ -14,6 +14,7 @@ export default class MainContent extends React.Component { componentDidMount() { if (!location.hash) { + document.body.scrollTop = 0; document.documentElement.scrollTop = 0; } else { location.hash = location.hash; diff --git a/tests/index.test.js b/tests/index.test.js index d6235906af..898be2913d 100644 --- a/tests/index.test.js +++ b/tests/index.test.js @@ -77,6 +77,7 @@ describe('antd dist files', function() { expect('TreeSelect' in antd).toBeTruthy(); expect('Upload' in antd).toBeTruthy(); expect('Validation' in antd).toBeTruthy(); + expect('BackTop' in antd).toBeTruthy(); }); // https://github.com/ant-design/ant-design/issues/1970