Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Card] Fix unknown props warnings #4675

Merged
merged 1 commit into from
Jul 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/Card/CardActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,18 @@ class CardActions extends Component {
};

render() {
const {
actAsExpander, // eslint-disable-line no-unused-vars
children,
expandable, // eslint-disable-line no-unused-vars
style,
...other,
} = this.props;

const {prepareStyles} = this.context.muiTheme;
const styles = getStyles(this.props, this.context);

const children = React.Children.map(this.props.children, (child) => {
const styledChildren = React.Children.map(children, (child) => {
if (React.isValidElement(child)) {
return React.cloneElement(child, {
style: Object.assign({}, styles.action, child.props.style),
Expand All @@ -53,8 +61,8 @@ class CardActions extends Component {
});

return (
<div {...this.props} style={prepareStyles(Object.assign(styles.root, this.props.style))}>
{children}
<div {...other} style={prepareStyles(Object.assign(styles.root, style))}>
{styledChildren}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/Card/CardHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ class CardHeader extends Component {
actAsExpander, // eslint-disable-line no-unused-vars
avatar: avatarProp,
children,
expandable, // eslint-disable-line no-unused-vars
showExpandableButton, // eslint-disable-line no-unused-vars
style,
subtitle,
Expand Down
32 changes: 20 additions & 12 deletions src/Card/CardMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,28 +82,36 @@ class CardMedia extends Component {

render() {
const {
actAsExpander, // eslint-disable-line no-unused-vars
children,
expandable, // eslint-disable-line no-unused-vars
mediaStyle,
overlay,
overlayContainerStyle,
overlayContentStyle,
overlayStyle,
style,
...other,
} = this.props;

const {prepareStyles} = this.context.muiTheme;
const styles = getStyles(this.props, this.context);
const rootStyle = Object.assign(styles.root, this.props.style);
const mediaStyle = Object.assign(styles.media, this.props.mediaStyle);
const overlayContainerStyle = Object.assign(styles.overlayContainer, this.props.overlayContainerStyle);
const overlayContentStyle = Object.assign(styles.overlayContent, this.props.overlayContentStyle);
const overlayStyle = Object.assign(styles.overlay, this.props.overlayStyle);
const rootStyle = Object.assign(styles.root, style);
const extendedMediaStyle = Object.assign(styles.media, mediaStyle);
const extendedOverlayContainerStyle = Object.assign(styles.overlayContainer, overlayContainerStyle);
const extendedOverlayContentStyle = Object.assign(styles.overlayContent, overlayContentStyle);
const extendedOverlayStyle = Object.assign(styles.overlay, overlayStyle);
const titleColor = this.context.muiTheme.cardMedia.titleColor;
const subtitleColor = this.context.muiTheme.cardMedia.subtitleColor;
const color = this.context.muiTheme.cardMedia.color;

const children = React.Children.map(this.props.children, (child) => {
const styledChildren = React.Children.map(children, (child) => {
return React.cloneElement(child, {
style: prepareStyles(Object.assign({}, styles.mediaChild, child.props.style)),
});
});

const overlayChildren = React.Children.map(this.props.overlay, (child) => {
const overlayChildren = React.Children.map(overlay, (child) => {
if (child.type.muiName === 'CardHeader' || child.type.muiName === 'CardTitle') {
return React.cloneElement(child, {
titleColor: titleColor,
Expand All @@ -120,13 +128,13 @@ class CardMedia extends Component {

return (
<div {...other} style={prepareStyles(rootStyle)}>
<div style={prepareStyles(mediaStyle)}>
{children}
<div style={prepareStyles(extendedMediaStyle)}>
{styledChildren}
</div>
{overlay ?
<div style={prepareStyles(overlayContainerStyle)}>
<div style={prepareStyles(overlayStyle)}>
<div style={prepareStyles(overlayContentStyle)}>
<div style={prepareStyles(extendedOverlayContainerStyle)}>
<div style={prepareStyles(extendedOverlayStyle)}>
<div style={prepareStyles(extendedOverlayContentStyle)}>
{overlayChildren}
</div>
</div>
Expand Down
15 changes: 12 additions & 3 deletions src/Card/CardText.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,22 @@ class CardText extends Component {
};

render() {
const {
actAsExpander, // eslint-disable-line no-unused-vars
children,
color, // eslint-disable-line no-unused-vars
expandable, // eslint-disable-line no-unused-vars
style,
...other,
} = this.props;

const {prepareStyles} = this.context.muiTheme;
const styles = getStyles(this.props, this.context);
const rootStyle = Object.assign(styles.root, this.props.style);
const rootStyle = Object.assign(styles.root, style);

return (
<div {...this.props} style={prepareStyles(rootStyle)}>
{this.props.children}
<div {...other} style={prepareStyles(rootStyle)}>
{children}
</div>
);
}
Expand Down
25 changes: 16 additions & 9 deletions src/Card/CardTitle.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,29 +77,36 @@ class CardTitle extends Component {
};

render() {
const {prepareStyles} = this.context.muiTheme;
const styles = getStyles(this.props, this.context);
const rootStyle = Object.assign({}, styles.root, this.props.style);
const titleStyle = Object.assign({}, styles.title, this.props.titleStyle);
const subtitleStyle = Object.assign({}, styles.subtitle, this.props.subtitleStyle);

const {
actAsExpander, // eslint-disable-line no-unused-vars
children,
expandable, // eslint-disable-line no-unused-vars
showExpandableButton, // eslint-disable-line no-unused-vars
style,
subtitle,
subtitleColor, // eslint-disable-line no-unused-vars
subtitleStyle,
title,
titleColor, // eslint-disable-line no-unused-vars
titleStyle,
...other,
} = this.props;

const {prepareStyles} = this.context.muiTheme;
const styles = getStyles(this.props, this.context);
const rootStyle = Object.assign({}, styles.root, style);
const extendedTitleStyle = Object.assign({}, styles.title, titleStyle);
const extendedSubtitleStyle = Object.assign({}, styles.subtitle, subtitleStyle);

return (
<div {...other} style={prepareStyles(rootStyle)}>
<span style={prepareStyles(titleStyle)}>
<span style={prepareStyles(extendedTitleStyle)}>
{title}
</span>
<span style={prepareStyles(subtitleStyle)}>
<span style={prepareStyles(extendedSubtitleStyle)}>
{subtitle}
</span>
{this.props.children}
{children}
</div>
);
}
Expand Down
1 change: 1 addition & 0 deletions src/FloatingActionButton/FloatingActionButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ class FloatingActionButton extends Component {

render() {
const {
backgroundColor, // eslint-disable-line no-unused-vars
className,
disabled,
mini,
Expand Down