Skip to content

Commit

Permalink
[+] upgrade React 15.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
minwe committed Jul 4, 2016
1 parent 5c6fe2b commit 1f3ae5a
Show file tree
Hide file tree
Showing 29 changed files with 233 additions and 64 deletions.
20 changes: 16 additions & 4 deletions js/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,22 +78,32 @@ const Accordion = React.createClass({
},

render() {
let {
className,
inset,
...props
} = this.props;
let classSet = this.getClassSet();

classSet[this.prefixClass('inset')] = this.props.inset;
delete props.classPrefix;
delete props.activeKey;
delete props.defaultActiveKey;
delete props.onAction;

classSet[this.prefixClass('inset')] = inset;

return (
<section
{...this.props}
className={classNames(classSet, this.props.className)}
{...props}
className={classNames(classSet, className)}
>
{this.renderItems()}
</section>
);
}
});

Accordion.Item = React.createClass({
const AccordionItem = React.createClass({
mixins: [ClassNameMixin, CollapseMixin],

propTypes: {
Expand Down Expand Up @@ -165,4 +175,6 @@ Accordion.Item = React.createClass({
}
});

Accordion.Item = AccordionItem;

export default Accordion;
5 changes: 5 additions & 0 deletions js/Badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ const Badge = React.createClass({
href,
...props
} = this.props;

delete props.classPrefix;
delete props.amStyle;
delete props.rounded;

Component = href ? 'a' : Component;

return (
Expand Down
15 changes: 13 additions & 2 deletions js/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ const Button = React.createClass({
};
},

removeUnknownProp(props) {
delete props.classPrefix;
delete props.amStyle;
delete props.amSize;
delete props.hollow;
delete props.block;
delete props.active;

return props;
},

renderAnchor(classes) {
let {
href,
Expand All @@ -43,7 +54,7 @@ const Button = React.createClass({

return (
<Component
{...props}
{...this.removeUnknownProp(props)}
href={href}
className={classes}
role="button"
Expand All @@ -63,7 +74,7 @@ const Button = React.createClass({

return (
<Component
{...props}
{...this.removeUnknownProp(props)}
className={classes}
>
{children}
Expand Down
2 changes: 2 additions & 0 deletions js/ButtonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ const ButtonGroup = React.createClass({
...props
} = this.props;

delete props.classPrefix;

classSet[this.prefixClass('stacked')] = stacked;
classSet[this.prefixClass('justify')] = justify;

Expand Down
14 changes: 10 additions & 4 deletions js/ButtonToolbar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React, {
cloneElement,
PropTypes,
} from 'react';
import classNames from 'classnames';
Expand All @@ -22,13 +21,20 @@ const ButtonToolbar = React.createClass({

render() {
let classSet = this.getClassSet();
let {
className,
children,
...props
} = this.props;

delete props.classPrefix;

return (
<div
{...this.props}
className={classNames(this.props.className, classSet)}
{...props}
className={classNames(className, classSet)}
>
{this.props.children}
{children}
</div>
);
}
Expand Down
10 changes: 8 additions & 2 deletions js/Card.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ const Card = React.createClass({
...props
} = this.props;

delete props.classPrefix;

return (
<div
{...props}
Expand All @@ -68,7 +70,7 @@ const Card = React.createClass({
}
});

Card.Child = React.createClass({
const CardChild = React.createClass({
mixins: [ClassNameMixin],

propTypes: {
Expand All @@ -85,7 +87,7 @@ Card.Child = React.createClass({
},

render() {
const {
let {
role,
className,
cover,
Expand All @@ -103,6 +105,8 @@ Card.Child = React.createClass({
}
}

delete props.classPrefix;

return (
<div
{...props}
Expand All @@ -116,4 +120,6 @@ Card.Child = React.createClass({
}
});

Card.Child = CardChild;

export default Card;
4 changes: 3 additions & 1 deletion js/Col.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,17 @@ const Col = React.createClass({

render() {
let {
component: Component,
cols,
offset,
shrink,
component: Component,
className,
...props,
} = this.props;
let classSet = this.getClassSet();

delete props.classPrefix;

if (cols) {
classSet[this.prefixClass(cols)] = true;
}
Expand Down
2 changes: 2 additions & 0 deletions js/Container.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ let Container = React.createClass({
} = this.props;
let classSet = this.getClassSet();

delete props.classPrefix;

// As view transition container
if (transition) {
return (
Expand Down
8 changes: 8 additions & 0 deletions js/Field.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,14 @@ const Field = React.createClass({
...commonProps,
};

delete assignedProps.classPrefix;
delete assignedProps.containerClassName;
delete assignedProps.label;
delete assignedProps.btnBefore;
delete assignedProps.btnAfter;
delete assignedProps.labelBefore;
delete assignedProps.labelAfter;

switch (this.props.type) {
case 'select':
field = (
Expand Down
4 changes: 3 additions & 1 deletion js/Grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,17 @@ const Grid = React.createClass({
let classSet = this.getClassSet();
let {
component: Component,
className,
collapse,
bordered,
className,
avg,
align,
wrap,
...props
} = this.props;

delete props.classPrefix;

// .g-collapse
classSet[this.prefixClass('collapse')] = collapse;

Expand Down
6 changes: 4 additions & 2 deletions js/Group.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ let Group = React.createClass({
let {
component: Component,
className,
header,
footer,
noPadded,
...props,
} = this.props;
let classSet = this.getClassSet();

delete props.classPrefix;
delete props.header;
delete props.footer;

classSet[this.prefixClass('no-padded')] = noPadded;

let bodyClasses = {
Expand Down
3 changes: 3 additions & 0 deletions js/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ const Icon = React.createClass({
name,
...props
} = this.props;

delete props.classPrefix;

Component = props.href ? 'a' : Component;

// icon-[iconName]
Expand Down
12 changes: 9 additions & 3 deletions js/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,11 @@ const List = React.createClass({
...props
} = this.props;

delete props.classPrefix;

classSet[this.prefixClass('inset')] = inset;

// TODO: 使用 ul 可能不是太好的选择,再一些需要定义 component 的场合缺乏灵活性
// TODO: 使用 ul 可能不是太好的选择,在一些需要定义 component 的场合缺乏灵活性
return (
<ul
{...props}
Expand Down Expand Up @@ -163,17 +165,21 @@ List.Item = React.createClass({
let {
className,
role,
title,
subTitle,
href,
after,
media,
children,
linkComponent,
linked,
nested,
...props
} = this.props;

delete props.classPrefix;
delete props.title;
delete props.after;
delete props.linkProps;

let itemChildren = [
this.renderAddon('media'),
this.renderMain(),
Expand Down
4 changes: 4 additions & 0 deletions js/Loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const Loader = React.createClass({
...props,
} = this.props;

delete props.classPrefix;
delete props.amStyle;
delete props.rounded;

return (
<Component
{...props}
Expand Down
18 changes: 16 additions & 2 deletions js/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ const Modal = createClass({
this.props.onClosed();
},

removeUnknownProp(props) {
delete props.isOpen;
delete props.onDismiss;
delete props.onOpen;
delete props.onClosed;
delete props.onAction;
delete props.classPrefix;
delete props.confirmText;
delete props.cancelText;
delete props.closeBtn;

return props;
},

renderActions(classSet) {
classSet[this.props.classPrefix] = false;

Expand Down Expand Up @@ -201,7 +215,7 @@ const Modal = createClass({

return (
<div
{...props}
{...this.removeUnknownProp(props)}
className={classNames(className, classSet, this.setClassNS('popup'))}
key="modalPopup"
ref="modal"
Expand Down Expand Up @@ -401,7 +415,7 @@ const Modal = createClass({

modal = (
<div
{...props}
{...this.removeUnknownProp(props)}
style={style}
ref="modalContainer"
className={classNames(classSet, className)}
Expand Down
17 changes: 16 additions & 1 deletion js/NavBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const NavBar = React.createClass({

propTypes: {
classPrefix: PropTypes.string,
amStyle: PropTypes.oneOf([
'primary',
'secondary',
'success',
'warning',
'alert',
'dark',
]),
title: PropTypes.node,
leftNav: PropTypes.array,
rightNav: PropTypes.array,
Expand Down Expand Up @@ -143,11 +151,18 @@ const NavBar = React.createClass({
render() {
let classSet = this.getClassSet();
let {
title,
className,
...props
} = this.props;

delete props.title;
delete props.classPrefix;
delete props.leftNav;
delete props.rightNav;
delete props.amStyle;
delete props.onAction;
delete props.titleOnLeft;

return (
<header
{...props}
Expand Down
6 changes: 6 additions & 0 deletions js/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ const Notification = React.createClass({
...props
} = this.props;

delete props.classPrefix;
delete props.amStyle;
delete props.static;
delete props.closeBtn;
delete props.onDismiss;

classSet[this.prefixClass('animated')] = animated;

let notificationBar = visible ? (
Expand Down
Loading

0 comments on commit 1f3ae5a

Please sign in to comment.