Merge branch '1.x-stable'

pull/2795/head
Benjy Cui 9 years ago
commit e6280a7ea6

@ -9,11 +9,22 @@ timeline: true
---
## 1.10.0
`2016-08-20`
- Affix 和 BackTop 新增 `target` 属性,支持指定滚动容器。[#2718](https://github.com/ant-design/ant-design/issues/2718)
- 文档页面加上编辑按钮,方便社区贡献。[#2325](https://github.com/ant-design/ant-design/issues/2325)
- 升级 rc-cascader 依赖,修复一个 `loadData` 属性和表单结合使用的问题。[#2767](https://github.com/ant-design/ant-design/issues/2767)
- 修复 `editable-card` 类型的 Tabs 没有关闭图标的问题。[#2747](https://github.com/ant-design/ant-design/issues/2747)
- Menu 修正默认 `z-index`。[#2762](https://github.com/ant-design/ant-design/issues/2762)
- 修正 Select 组件在 IE 下的一些样式问题。[#2741](https://github.com/ant-design/ant-design/issues/2741)
## 1.9.1
`2016-08-16`
- 修复 Tabs 的 `type="editable-card"` 模式activeKey 错误的问题。[#2725](https://github.com/ant-design/ant-design/issues/2725)
- 修复 `editable-card` 类型的 Tabs 设置 `activeKey` 无效的问题。[#2725](https://github.com/ant-design/ant-design/issues/2725)
- 修复一个 Table 的样式兼容性问题。[#2723](https://github.com/ant-design/ant-design/issues/2723)
- 更新 axure 部件库。[#2714](https://github.com/ant-design/ant-design/issues/2714)

@ -0,0 +1,29 @@
---
order: 4
title: 参考对象
---
`target` 设置 `Affix` 需要监听其滚动事件的元素,默认为 `window`
````jsx
import { Affix, Button } from 'antd';
const Demo = () => {
return (
<div style={{ height: 100, overflow: 'hidden' }}>
<div style={{ height: '100%', overflowY: 'scroll' }} id="affix-target">
<div style={{ height: 300, backgroundImage: 'url(https://zos.alipayobjects.com/rmsportal/RmjwQiJorKyobvI.jpg)' }}>
<br />
<br />
<br />
<Affix target={() => document.getElementById('affix-target')} offsetTop={20}>
<Button type="primary">固定在容器顶部</Button>
</Affix>
</div>
</div>
</div>
);
};
ReactDOM.render(<Demo />, mountNode);
````

@ -6,32 +6,42 @@ import warning from 'warning';
import assign from 'object-assign';
import shallowequal from 'shallowequal';
function getScroll(w, top?: boolean) {
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];
}
function getScroll(target, top) {
const prop = top ? 'pageYOffset' : 'pageXOffset';
const method = top ? 'scrollTop' : 'scrollLeft';
const isWindow = target === window;
let ret = isWindow ? target[prop] : target[method];
// ie6,7,8 standard mode
if (isWindow && typeof ret !== 'number') {
ret = window.document.documentElement[method];
}
return ret;
}
function getOffset(element) {
const rect = element.getBoundingClientRect();
const body = document.body;
const clientTop = element.clientTop || body.clientTop || 0;
const clientLeft = element.clientLeft || body.clientLeft || 0;
const scrollTop = getScroll(window, true);
const scrollLeft = getScroll(window);
function getTargetRect(target) {
return target !== window ?
target.getBoundingClientRect() :
{ top: 0, left: 0, bottom: 0 };
}
function getOffset(element, target) {
const elemRect = element.getBoundingClientRect();
const targetRect = getTargetRect(target);
const scrollTop = getScroll(target, true);
const scrollLeft = getScroll(target, false);
const docElem = window.document.body;
const clientTop = docElem.clientTop || 0;
const clientLeft = docElem.clientLeft || 0;
return {
top: rect.top + scrollTop - clientTop,
left: rect.left + scrollLeft - clientLeft,
top: elemRect.top - targetRect.top +
scrollTop - clientTop,
left: elemRect.left - targetRect.left +
scrollLeft - clientLeft,
};
}
@ -51,9 +61,13 @@ export default class Affix extends React.Component<AffixProps, any> {
static propTypes = {
offsetTop: React.PropTypes.number,
offsetBottom: React.PropTypes.number,
};
target: React.PropTypes.func,
}
static defaultProps = {
target() {
return window;
},
onChange() {},
};
@ -73,8 +87,10 @@ export default class Affix extends React.Component<AffixProps, any> {
}
setAffixStyle(e, affixStyle) {
const { onChange, target } = this.props;
const originalAffixStyle = this.state.affixStyle;
if (e.type === 'scroll' && originalAffixStyle && affixStyle) {
const isWindow = target() === window;
if (e.type === 'scroll' && originalAffixStyle && affixStyle && isWindow) {
return;
}
if (shallowequal(affixStyle, originalAffixStyle)) {
@ -84,7 +100,7 @@ export default class Affix extends React.Component<AffixProps, any> {
const affixed = !!this.state.affixStyle;
if ((affixStyle && !originalAffixStyle) ||
(!affixStyle && originalAffixStyle)) {
this.props.onChange(affixed);
onChange(affixed);
}
});
}
@ -100,24 +116,24 @@ export default class Affix extends React.Component<AffixProps, any> {
this.setState({ placeholderStyle });
}
handleScroll = (e) => {
let { offsetTop, offsetBottom, offset } = this.props;
updatePosition = (e) => {
let { offsetTop, offsetBottom, offset, target } = this.props;
const targetNode = target();
// Backwards support
offsetTop = offsetTop || offset;
const scrollTop = getScroll(window, true);
const affixNode = ReactDOM.findDOMNode(this) as HTMLElement;
const fixedNode = ReactDOM.findDOMNode(this.refs.fixedNode) as HTMLElement;
const elemOffset = getOffset(affixNode);
const scrollTop = getScroll(targetNode, true);
const elemOffset = getOffset(ReactDOM.findDOMNode(this), targetNode);
const elemSize = {
width: fixedNode.offsetWidth,
height: fixedNode.offsetHeight,
width: this.refs.fixedNode.offsetWidth,
height: this.refs.fixedNode.offsetHeight,
};
const offsetMode = {
top: null as boolean,
bottom: null as boolean,
};
// Default to `offsetTop=0`.
if (typeof offsetTop !== 'number' && typeof offsetBottom !== 'number') {
offsetMode.top = true;
offsetTop = 0;
@ -126,26 +142,31 @@ export default class Affix extends React.Component<AffixProps, any> {
offsetMode.bottom = typeof offsetBottom === 'number';
}
const targetRect = getTargetRect(targetNode);
const targetInnerHeight = targetNode.innerHeight || targetNode.clientHeight;
if (scrollTop > elemOffset.top - offsetTop && offsetMode.top) {
// Fixed Top
this.setAffixStyle(e, {
position: 'fixed',
top: offsetTop,
left: elemOffset.left,
width: affixNode.offsetWidth,
top: targetRect.top + offsetTop,
left: targetRect.left + elemOffset.left,
width: ReactDOM.findDOMNode(this).offsetWidth,
});
this.setPlaceholderStyle(e, {
width: affixNode.offsetWidth,
height: affixNode.offsetHeight,
});
} else if (scrollTop < elemOffset.top + elemSize.height + offsetBottom - window.innerHeight &&
offsetMode.bottom) {
} else if (
scrollTop < elemOffset.top + elemSize.height + offsetBottom - targetInnerHeight &&
offsetMode.bottom
) {
// Fixed Bottom
const targetBottomOffet = targetNode === window ? 0 : (window.innerHeight - targetRect.bottom);
this.setAffixStyle(e, {
position: 'fixed',
bottom: offsetBottom,
left: elemOffset.left,
width: affixNode.offsetWidth,
bottom: targetBottomOffet + offsetBottom,
left: targetRect.left + elemOffset.left,
width: ReactDOM.findDOMNode(this).offsetWidth,
});
this.setPlaceholderStyle(e, {
width: affixNode.offsetWidth,
@ -159,19 +180,39 @@ export default class Affix extends React.Component<AffixProps, any> {
componentDidMount() {
warning(!('offset' in this.props), '`offset` prop of Affix is deprecated, use `offsetTop` instead.');
this.scrollEvent = addEventListener(window, 'scroll', this.handleScroll);
this.resizeEvent = addEventListener(window, 'resize', this.handleScroll);
const target = this.props.target;
this.setTargetEventListeners(target);
}
componentWillUnmount() {
if (this.scrollEvent) {
this.scrollEvent.remove();
}
if (this.resizeEvent) {
this.resizeEvent.remove();
componentWillReceiveProps(nextProps) {
if (this.props.target !== nextProps.target) {
this.clearScrollEventListeners();
this.setTargetEventListeners(nextProps.target);
// Mock Event object.
this.updatePosition({});
}
}
componentWillUnmount() {
this.clearScrollEventListeners();
}
setTargetEventListeners(getTarget) {
const target = getTarget();
this.scrollEvent = addEventListener(target, 'scroll', this.updatePosition);
this.resizeEvent = addEventListener(target, 'resize', this.updatePosition);
}
clearScrollEventListeners() {
['scrollEvent', 'resizeEvent'].forEach((name) => {
if (this[name]) {
this[name].remove();
}
});
}
render() {
const className = classNames({
'ant-affix': this.state.affixStyle,
@ -180,6 +221,7 @@ export default class Affix extends React.Component<AffixProps, any> {
const props = assign({}, this.props);
delete props.offsetTop;
delete props.offsetBottom;
delete props.target;
return (
<div {...props} style={this.state.placeholderStyle}>

@ -20,4 +20,5 @@ english: Affix
|-------------|----------------|--------------------|--------------|
| offsetTop | 距离窗口顶部达到指定偏移量后触发 | Number | |
| offsetBottom | 距离窗口底部达到指定偏移量后触发 | Number | |
| target | 设置 `Affix` 需要监听其滚动事件的元素,值为一个返回对应 DOM 元素的函数 | Function | () => window |
| onChange | 固定状态改变时触发的回调函数 | Function(affixed) | 无 |

@ -5,18 +5,21 @@ import addEventListener from 'rc-util/lib/Dom/addEventListener';
import classNames from 'classnames';
import omit from 'object.omit';
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];
}
function getScroll(target, top) {
if (typeof window === 'undefined') {
return 0;
}
const prop = top ? 'pageYOffset' : 'pageXOffset';
const method = top ? 'scrollTop' : 'scrollLeft';
const isWindow = target === window;
let ret = isWindow ? target[prop] : target[method];
// ie6,7,8 standard mode
if (isWindow && typeof ret !== 'number') {
ret = window.document.documentElement[method];
}
return ret;
}
@ -27,10 +30,20 @@ interface BackTopProps {
className?: string;
}
export default class BackTop extends React.Component {
static propTypes = {
visibilityHeight: React.PropTypes.number,
target: React.PropTypes.func,
}
export default class BackTop extends React.Component<BackTopProps, any> {
static defaultProps = {
onClick() {},
visibilityHeight: 400,
target() {
return window;
},
prefixCls: 'ant-back-top',
};
@ -38,9 +51,9 @@ export default class BackTop extends React.Component<BackTopProps, any> {
constructor(props) {
super(props);
const scrollTop = getScroll(window, true);
const scrollTop = getScroll(props.target(), true);
this.state = {
visible: scrollTop > this.props.visibilityHeight,
visible: scrollTop > props.visibilityHeight,
};
}
@ -53,19 +66,25 @@ export default class BackTop extends React.Component<BackTopProps, any> {
}
setScrollTop(value) {
document.body.scrollTop = value;
document.documentElement.scrollTop = value;
const targetNode = this.props.target();
if (targetNode === window) {
document.body.scrollTop = value;
document.documentElement.scrollTop = value;
} else {
targetNode.scrollTop = value;
}
}
handleScroll = () => {
const scrollTop = getScroll(window, true);
const { visibilityHeight, target } = this.props;
const scrollTop = getScroll(target(), true);
this.setState({
visible: scrollTop > this.props.visibilityHeight,
visible: scrollTop > visibilityHeight,
});
}
componentDidMount() {
this.scrollEvent = addEventListener(window, 'scroll', this.handleScroll);
this.scrollEvent = addEventListener(this.props.target(), 'scroll', this.handleScroll);
}
componentWillUnmount() {

@ -7,11 +7,11 @@ title:
## zh-CN
通过 `locale` 配置时区、语言等, 默认支持 `en_US``zh_CN`。
通过 `locale` 配置时区、语言等, 默认支持 `en_US``zh_CN`。不同版本带有不同的时区配置,如果所在时区与默认配置不同,需要自行设置。上面的 demo 就是在东八区使用 en_US 版本的例子。
## en-US
Use locale to set the properties like time zone, language and etc. en_US, zh_CN are supported by default.
Use locale to set the properties like time zone, language and etc. `en_US`, `zh_CN` are supported by default. There are different time zone configuration in different versions, you must set it by yourself if your time zone does not match the default setting. The example above is to show how to use the `en_US` version at GMT+8 time zone.
````jsx
@ -19,7 +19,7 @@ import { DatePicker } from 'antd';
import enUS from 'antd/lib/date-picker/locale/en_US';
const customLocale = {
timezoneOffset: 0 * 60,
timezoneOffset: 8 * 60,
firstDayOfWeek: 0,
minimalDaysInFirstWeek: 1,
};

@ -31,9 +31,9 @@ english: Dropdown
| 参数 | 说明 | 类型 | 默认值 |
|-------------|------------------|--------------------|--------------|
| type | 按钮类型,和 [Button](/components/button) 一致 | String | 'default' |
| onClick | 点击左侧按钮的回调,和 [Button](/components/button) 一致 | Function | - |
| type | 按钮类型,和 [Button](/components/button/) 一致 | String | 'default' |
| onClick | 点击左侧按钮的回调,和 [Button](/components/button/) 一致 | Function | - |
| trigger | 触发下拉的行为 | ['click'] or ['hover'] | ['hover'] |
| overlay | 菜单 | [Menu](/components/menu) | - |
| overlay | 菜单 | [Menu](/components/menu/) | - |
| visible | 菜单是否显示 | Boolean | - |
| onVisibleChange | 菜单显示状态改变时调用,参数为 { visible } | Function | - |

@ -1,6 +1,6 @@
---
category: Components
chinese: 布局
chinese: 栅格
type: Basic
cols: 1
english: Layout

@ -7,7 +7,7 @@ title:
## zh-CN
此处列出 Ant Design 中需要国际化支持的组件,你可以在演示里切换语言。
此处列出 Ant Design 中需要国际化支持的组件,你可以在演示里切换语言。涉及时间的组件请注意时区设置 [DatePicker](/components/date-picker/#components-date-picker-demo-locale)。
## en-US
@ -32,6 +32,12 @@ const columns = [{
dataIndex: 'age',
}];
const customLocale = {
timezoneOffset: 8 * 60,
firstDayOfWeek: 1,
minimalDaysInFirstWeek: 1,
};
const Page = React.createClass({
getInitialState() {
return {
@ -112,6 +118,10 @@ const App = React.createClass({
this.setState({ locale: e.target.value });
},
render() {
const locale = { ...this.state.locale };
if (locale.DatePicker) {
locale.DatePicker = { ...locale.DatePicker, ...customLocale };
}
return (
<div>
<div className="change-locale">
@ -121,7 +131,7 @@ const App = React.createClass({
<Radio.Button key="cn">中文</Radio.Button>
</Radio.Group>
</div>
<LocaleProvider locale={this.state.locale}><Page /></LocaleProvider>
<LocaleProvider locale={locale}><Page /></LocaleProvider>
</div>
);
},

@ -89,6 +89,12 @@
}
}
&-horizontal,
&-inline,
&-vertical {
z-index: auto;
}
&-inline,
&-vertical {
border-right: 1px solid @border-color-split;

@ -152,16 +152,16 @@
}
&-lg {
.ant-select-selection--single {
.@{select-prefix-cls}-selection--single {
height: 32px;
.ant-select-selection__rendered {
.@{select-prefix-cls}-selection__rendered {
line-height: 30px;
}
}
.ant-select-selection--multiple {
.@{select-prefix-cls}-selection--multiple {
min-height: 32px;
.ant-select-selection__rendered {
.@{select-prefix-cls}-selection__rendered {
li {
height: 24px;
line-height: 24px;
@ -171,18 +171,18 @@
}
&-sm {
.ant-select-selection {
.@{select-prefix-cls}-selection {
border-radius: @border-radius-sm;
}
.ant-select-selection--single {
.@{select-prefix-cls}-selection--single {
height: 22px;
.ant-select-selection__rendered {
.@{select-prefix-cls}-selection__rendered {
line-height: 20px;
}
}
.ant-select-selection--multiple {
.@{select-prefix-cls}-selection--multiple {
min-height: 22px;
.ant-select-selection__rendered {
.@{select-prefix-cls}-selection__rendered {
li {
height: 14px;
line-height: 14px;
@ -223,14 +223,17 @@
&-search--inline {
float: left;
width: 100%;
height: 100%;
.@{select-prefix-cls}-search__field__wrap {
width: 100%;
height: 100%;
}
.@{select-prefix-cls}-search__field {
border: 0;
font-size: 100%;
height: 100%;
background: transparent;
outline: 0;
border-radius: @border-radius-base;
@ -361,6 +364,9 @@
position: absolute;
left: 0;
right: 0;
> ul {
height: 100%;
}
}
}
}

@ -73,19 +73,19 @@ export default class Tabs extends React.Component<TabsProps, any> {
animation = null;
}
// only card type tabs can be added and closed
let childrenWithCross;
if (type === 'editable-card') {
children = Array.isArray(children) ? children : [children];
children = (children as Array<any>).map((child, index) => {
if (Array.isArray(child)) {
return child;
}
return cloneElement(child, {
tab: <div>
{child.props.tab}
<Icon type="cross" onClick={(e) => this.removeTab(child.key, e) } />
</div>,
childrenWithCross = [];
React.Children.forEach(children, (child, index) => {
childrenWithCross.push(cloneElement(child, {
tab: (
<div>
{child.props.tab}
<Icon type="cross" onClick={(e) => this.removeTab(child.key, e)} />
</div>
),
key: child.key || index,
});
}));
});
// Add new tab handler
if (!hideAdd) {
@ -110,8 +110,8 @@ export default class Tabs extends React.Component<TabsProps, any> {
tabBarExtraContent={tabBarExtraContent}
onChange={this.handleChange}
animation={animation}
>
{children}
>
{childrenWithCross || children}
</RcTabs>
);
}

@ -10,17 +10,10 @@ english: Download
<a target="_blank" href="https://github.com/ant-design/ant-design/releases/download/resource/AntD_Library_V2.01.rplib" class="resource-card">
<img src="https://os.alipayobjects.com/rmsportal/cnmjGfbBWUZPFiO.png">
<span class="resource-card-content">
<span class="resource-card-title">Axure Components v2.0.1</span>
<span class="resource-card-title">Ant Design Library v2.0.1</span>
<span class="resource-card-description">一套强大的 Ant Design 的 Axure 部件库</span>
</span>
</a>
<a target="_blank" href="https://github.com/ant-design/ant-design/releases/download/resource/AntD_Box_v1.3.rp" class="resource-card">
<img src="https://os.alipayobjects.com/rmsportal/UuYRXxndGMKdaiE.png">
<span class="resource-card-content">
<span class="resource-card-title">Axure Box v1.3</span>
<span class="resource-card-description">强大的 Ant Design 组件拼装方式</span>
</span>
</a>
<a target="_blank" href="http://ux.ant.design" class="resource-card">
<img src="https://os.alipayobjects.com/rmsportal/yfTqrQuSKcqBDLY.png">
<span class="resource-card-content">

@ -1,8 +1,8 @@
{
"name": "antd",
"version": "1.9.1",
"version": "1.10.0",
"title": "Ant Design",
"description": "一个 UI 设计语言",
"description": "An enterprise-class UI design language and React-based implementation",
"homepage": "http://ant.design/",
"keywords": [
"ant",
@ -43,7 +43,7 @@
"object.omit": "^2.0.0",
"rc-animate": "~2.3.0",
"rc-calendar": "~6.0.2",
"rc-cascader": "~0.9.11",
"rc-cascader": "~0.10.1",
"rc-checkbox": "~1.4.0",
"rc-collapse": "~1.6.4",
"rc-dialog": "~6.2.1",

@ -44,21 +44,29 @@
box-shadow: 0 0 4px rgba(45, 183, 245, 0.5);
}
.code-box:hover .code-box-meta,
.code-box:target .code-box-meta {
background: #fbfbfb;
}
.code-box {
.code-box-title a,
.code-box-title a:hover {
color: #666;
font-size: 14px;
font-weight: 500;
}
.code-box:hover .code-box-title,
.code-box:target .code-box-title {
background: #fbfbfb;
box-shadow: 0 -1.2px 0 #e9e9e9;
}
a.edit-button {
position: absolute;
right: -16px;
top: 7px;
font-size: 12px;
transform: scale(0.9);
background: #fff;
padding-right: 6px;
opacity: 0;
transition: opacity .3s;
}
.code-box .code-box-title a,
.code-box .code-box-title a:hover {
color: #666;
font-size: 14px;
&:hover a.edit-button {
opacity: 1;
}
}
.code-box .code-box-demo {
@ -73,7 +81,7 @@
.code-box-meta.markdown {
position: relative;
padding: 16px;
padding: 17px 16px 15px 20px;
border-radius: 0 0 6px 6px;
transition: background-color 0.4s ease;
width: 100%;
@ -97,26 +105,13 @@ section.code-box-meta p {
.code-box-title {
position: absolute;
top: -14px;
padding: 1px 1.1em;
padding: 1px 8px;
margin-left: -8px;
color: #777;
border-radius: 6px;
border-top-left-radius: 0;
background: #fff;
transition: all 0.4s ease;
}
.code-box-title:before {
font-family: anticon;
content: "\e658";
font-size: 16px;
vertical-align: middle;
line-height: 22px;
position: relative;
margin-right: 8px;
top: -2px;
color: #ccc;
-webkit-transform: rotate(-45deg);
transform: rotate(-45deg);
display: inline-block;
transition: background-color 0.4s ease;
}
.code-box-meta > p {
@ -135,7 +130,7 @@ section.code-box-meta p {
.code-box .collapse {
position: absolute;
right: 16px;
bottom: 16px;
bottom: 17px;
cursor: pointer;
width: 18px;
height: 18px;
@ -143,9 +138,8 @@ section.code-box-meta p {
line-height: 18px;
opacity: 0.5;
text-align: center;
-webkit-transform: rotate(90deg);
transform: rotate(90deg);
transition: all 0.3s ease;
transition: all 0.3s;
color: #999;
background: #fff;
user-select: none;
@ -153,7 +147,6 @@ section.code-box-meta p {
}
.code-box.expand .collapse {
-webkit-transform: rotate(-90deg);
transform: rotate(-90deg);
}

@ -169,6 +169,26 @@
cursor: not-allowed;
}
.markdown a.edit-button {
line-height: 12px;
display: inline-block;
margin-left: 10px;
height: 12px;
i {
color: #999;
&:hover {
color: #2db7f5;
}
}
.anticon {
display: block;
font-size: 14px;
}
}
.markdown h1:hover .anchor,
.markdown h2:hover .anchor,
.markdown h3:hover .anchor,

@ -118,15 +118,31 @@
position: relative;
text-align: center;
}
}
.image-modal-single.slick-slider {
padding-bottom: 0;
}
.ant-carousel {
.slick-slider {
padding-bottom: 24px;
img {
display: inline;
max-width: 100%;
}
}
.slick-dots {
text-align: left;
bottom: -10px;
li {
margin: 0;
}
}
}
.ant-carousel .slick-slider img {
display: inline;
max-width: 100%;
.image-modal-single.slick-slider {
padding-bottom: 0;
}
.image-modal-single .slick-dots {
display: none!important;
}
}
.transition-video-player {

@ -8,7 +8,7 @@
<link rel="icon" href="https://t.alipayobjects.com/images/T1QUBfXo4fXXXXXXXX.png" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="{{ root }}index.css"/>
<!--[if lte IE 10]>
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,es5-shim/4.5.7/es5-shim.min.js,es5-shim/4.5.7/es5-sham.min.js,html5shiv/3.7.2/html5shiv.min.js,media-match/2.0.2/media.match.min.js"></script>
<script src="https://as.alipayobjects.com/g/component/??console-polyfill/0.2.2/index.js,media-match/2.0.2/media.match.min.js"></script>
<![endif]-->
</head>
<body>
@ -45,6 +45,12 @@
/* eslint-enable */
}
</script>
<script>
if (!window.Intl) {
document.writeln('<script src="https://as.alipayobjects.com/g/component/intl/1.0.1/Intl.js">' + '<' + '/script>');
document.writeln('<script src="https://as.alipayobjects.com/g/component/intl/1.0.1/locale-data/jsonp/en.js">' + '<' + '/script>');
}
</script>
<script src="{{ root }}common.js"></script>
<script src="{{ root }}index.js"></script>
</body>

@ -2,6 +2,7 @@ import React, { Children, cloneElement } from 'react';
import DocumentTitle from 'react-document-title';
import { getChildren } from 'jsonml.js/lib/utils';
import { Timeline } from 'antd';
import EditButton from './EditButton';
import * as utils from '../utils';
export default class Article extends React.Component {
@ -54,7 +55,7 @@ export default class Article extends React.Component {
const content = props.content;
const { meta, description } = content;
const { title, subtitle, chinese, english } = meta;
const { title, subtitle, chinese, english, filename } = meta;
return (
<DocumentTitle title={`${title || chinese || english} - Ant Design`}>
@ -65,6 +66,7 @@ export default class Article extends React.Component {
(!subtitle && !chinese) ? null :
<span className="subtitle">{subtitle || chinese}</span>
}
<EditButton title="在 Github 上编辑此页!" filename={filename} />
</h1>
{
!description ? null :

@ -4,6 +4,7 @@ import classNames from 'classnames';
import { Row, Col, Icon, Affix } from 'antd';
import { getChildren } from 'jsonml.js/lib/utils';
import Demo from './Demo';
import EditButton from './EditButton';
export default class ComponentDoc extends React.Component {
static contextTypes = {
@ -71,7 +72,7 @@ export default class ComponentDoc extends React.Component {
);
});
const { title, subtitle, chinese, english } = meta;
const { title, subtitle, chinese, english, filename } = meta;
return (
<DocumentTitle title={`${subtitle || chinese || ''} ${title || english} - Ant Design`}>
<article>
@ -87,6 +88,7 @@ export default class ComponentDoc extends React.Component {
(!subtitle && !chinese) ? null :
<span className="subtitle">{subtitle || chinese}</span>
}
<EditButton title="在 Github 上编辑此页!" filename={filename} />
</h1>
{
props.utils.toReactComponent(

@ -1,6 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import classNames from 'classnames';
import EditButton from './EditButton';
export default class Demo extends React.Component {
static contextTypes = {
@ -74,6 +75,7 @@ export default class Demo extends React.Component {
<a href={`#${meta.id}`}>
{localizedTitle}
</a>
<EditButton title="在 Github 上编辑此示例!" filename={meta.filename} />
</div>
{introChildren}
<span className="collapse anticon anticon-circle-o-right"

@ -0,0 +1,14 @@
import React from 'react';
import { Tooltip, Icon } from 'antd';
const branchUrl = 'https://github.com/ant-design/ant-design/blob/1.x-stable/';
export default function EditButton({ title, filename }) {
return (
<Tooltip title={title}>
<a className="edit-button" href={`${branchUrl}${filename}`}>
<Icon type="edit" />
</a>
</Tooltip>
);
}

@ -75,6 +75,9 @@ export default class Footer extends React.Component {
<div>
<a target="_blank" href="http://ant-tool.github.io">ant-tool</a> - 开发工具
</div>
<div>
<a target="_blank" href="https://github.com/dvajs/dva">dva</a> - 应用框架
</div>
</li>
<li>
<h2>相关站点</h2>
@ -85,7 +88,12 @@ export default class Footer extends React.Component {
<div><a href="http://ux.ant.design">Ant UX</a> - 页面逻辑素材</div>
</li>
<li>
<h2>联系我们</h2>
<h2>社区</h2>
<div>
<a target="_blank" href="http://ant.design/changelog">
更新记录
</a>
</div>
<div>
<a target="_blank" href="https://github.com/ant-design/ant-design/issues">
反馈和建议

@ -116,6 +116,7 @@ export default class Header extends React.Component {
'home-nav-white': !this.state.isFirstFrame,
});
const searchPlaceholder = this.context.intl.locale === 'zh-CN' ? '搜索组件...' : 'Search...';
return (
<header id="header" className={headerClassName}>
<Row>
@ -136,7 +137,7 @@ export default class Header extends React.Component {
<div id="search-box">
<Select combobox
dropdownClassName="component-select"
placeholder="搜索组件..."
placeholder={searchPlaceholder}
value={undefined}
optionFilterProp="data-label"
optionLabelProp="data-label"

@ -12,27 +12,6 @@ window.react = React;
window['react-dom'] = ReactDOM;
window.antd = require('antd');
// Polyfill
const areIntlLocalesSupported = require('intl-locales-supported');
const localesMyAppSupports = ['zh-CN', 'en-US'];
if (global.Intl) {
// Determine if the built-in `Intl` has the locale data we need.
if (!areIntlLocalesSupported(localesMyAppSupports)) {
// `Intl` exists, but it doesn't have the data we need, so load the
// polyfill and patch the constructors we need with the polyfill's.
/* eslint-disable global-require */
const IntlPolyfill = require('intl');
/* eslint-enable global-require */
Intl.NumberFormat = IntlPolyfill.NumberFormat;
Intl.DateTimeFormat = IntlPolyfill.DateTimeFormat;
}
} else {
// No `Intl`, so use and load the polyfill.
/* eslint-disable global-require */
global.Intl = require('intl');
/* eslint-enable global-require */
}
const isZhCN = (typeof localStorage !== 'undefined' && localStorage.getItem('locale') !== 'en-US');
// (typeof localStorage !== 'undefined' && localStorage.getItem('locale') === 'zh-CN') ||
// (navigator.language === 'zh-CN');

Loading…
Cancel
Save