Browse Source

site: update code style

pull/1301/head
Benjy Cui 9 years ago
parent
commit
1fbfb67744
  1. 13
      site/component/Article/ImagePreview.jsx
  2. 4
      site/component/ComponentDoc/index.jsx
  3. 4
      site/component/Demo/index.jsx
  4. 12
      site/component/Header/index.jsx

13
site/component/Article/ImagePreview.jsx

@ -42,13 +42,16 @@ export default class ImagePreview extends React.Component {
leftVisible: false, leftVisible: false,
rightVisible: false, rightVisible: false,
}; };
this.handleLeftClick = this.handleClick.bind(this, 'left');
this.handleRightClick = this.handleClick.bind(this, 'right');
} }
handleClick(side) { handleClick(side) {
this.setState({ [`${side}Visible`]: true }); this.setState({ [`${side}Visible`]: true });
} }
handleCancel() { handleCancel = () => {
this.setState({ this.setState({
leftVisible: false, leftVisible: false,
rightVisible: false, rightVisible: false,
@ -102,8 +105,8 @@ export default class ImagePreview extends React.Component {
cover={imagesList[0]} cover={imagesList[0]}
coverMeta={imgsMeta[0]} coverMeta={imgsMeta[0]}
imgs={imagesList} imgs={imagesList}
onClick={this.handleClick.bind(this, 'left')} onClick={this.handleLeftClick}
onCancel={this.handleCancel.bind(this)} onCancel={this.handleCancel}
/> />
{ {
comparable ? comparable ?
@ -113,8 +116,8 @@ export default class ImagePreview extends React.Component {
cover={imagesList[1]} cover={imagesList[1]}
coverMeta={imgsMeta[1]} coverMeta={imgsMeta[1]}
imgs={imagesList} imgs={imagesList}
onClick={this.handleClick.bind(this, 'right')} onClick={this.handleRightClick}
onCancel={this.handleCancel.bind(this)} onCancel={this.handleCancel}
/> : null /> : null
} }
</div> </div>

4
site/component/ComponentDoc/index.jsx

@ -23,7 +23,7 @@ export default class ComponentDoc extends React.Component {
utils.setTitle(`${chinese} ${english} - Ant Design`); utils.setTitle(`${chinese} ${english} - Ant Design`);
} }
handleExpandToggle() { handleExpandToggle = () => {
this.setState({ this.setState({
expandAll: !this.state.expandAll, expandAll: !this.state.expandAll,
}); });
@ -85,7 +85,7 @@ export default class ComponentDoc extends React.Component {
<h2> <h2>
代码演示 代码演示
<Icon type="appstore" className={expandTriggerClass} <Icon type="appstore" className={expandTriggerClass}
title="展开全部代码" onClick={this.handleExpandToggle.bind(this)} /> title="展开全部代码" onClick={this.handleExpandToggle} />
</h2> </h2>
</section> </section>
<Row> <Row>

4
site/component/Demo/index.jsx

@ -20,7 +20,7 @@ export default class Demo extends React.Component {
}); });
} }
handleCodeExapnd() { handleCodeExapnd = () => {
this.setState({ codeExpand: !this.state.codeExpand }); this.setState({ codeExpand: !this.state.codeExpand });
} }
@ -57,7 +57,7 @@ export default class Demo extends React.Component {
</div> </div>
{ introChildren } { introChildren }
<span className="collapse anticon anticon-circle-o-right" <span className="collapse anticon anticon-circle-o-right"
onClick={this.handleCodeExapnd.bind(this)} onClick={this.handleCodeExapnd}
unselectable="none" /> unselectable="none" />
</section> </section>
<section className={`highlight-wrapper ${codeExpand ? 'highlight-wrapper-expand' : ''}`} <section className={`highlight-wrapper ${codeExpand ? 'highlight-wrapper-expand' : ''}`}

12
site/component/Header/index.jsx

@ -34,7 +34,7 @@ export default class Header extends React.Component {
}); });
} }
handleMenuIconClick(e) { handleMenuIconClick = (e) => {
e.stopPropagation(); e.stopPropagation();
e.nativeEvent.stopImmediatePropagation(); e.nativeEvent.stopImmediatePropagation();
this.setState({ this.setState({
@ -42,11 +42,11 @@ export default class Header extends React.Component {
}); });
} }
handleSearch(value) { handleSearch = (value) => {
this.context.router.push({ pathname: value }); this.context.router.push({ pathname: value });
} }
handleSelectFilter(value, option) { handleSelectFilter = (value, option) => {
return option.props['data-label'].indexOf(value.toLowerCase()) > -1; return option.props['data-label'].indexOf(value.toLowerCase()) > -1;
} }
@ -79,7 +79,7 @@ export default class Header extends React.Component {
<Col lg={4} md={6} sm={7} xs={24}> <Col lg={4} md={6} sm={7} xs={24}>
<Icon <Icon
className="nav-phone-icon" className="nav-phone-icon"
onClick={this.handleMenuIconClick.bind(this)} onClick={this.handleMenuIconClick}
type="menu" /> type="menu" />
<Link to="/" id="logo"> <Link to="/" id="logo">
<img src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg" /> <img src="https://t.alipayobjects.com/images/rmsweb/T1B9hfXcdvXXXXXXXX.svg" />
@ -94,8 +94,8 @@ export default class Header extends React.Component {
searchPlaceholder="搜索组件..." searchPlaceholder="搜索组件..."
optionLabelProp="nothing" optionLabelProp="nothing"
optionFilterProp="data-label" optionFilterProp="data-label"
filterOption={this.handleSelectFilter.bind(this)} filterOption={this.handleSelectFilter}
onSelect={this.handleSearch.bind(this)}> onSelect={this.handleSearch}>
{options} {options}
</Select> </Select>
</div> </div>

Loading…
Cancel
Save