-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
405 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
var React = require('react'); | ||
var mui = require('mui'); | ||
var ComponentDoc = require('../../component-doc.jsx'); | ||
var {Card, CardMedia, CardTitle, CardActions, CardText, CardHeader, FlatButton, Avatar} = mui; | ||
|
||
class CardPage extends React.Component { | ||
|
||
constructor(props) { | ||
super(props); | ||
|
||
this.code = ` | ||
<Card> | ||
<CardHeader | ||
title="Title" | ||
subtitle="Subtitle" | ||
avatar={<Avatar>A</Avatar>}/> | ||
<CardHeader | ||
title="Demo Url Based Avatar" | ||
subtitle="Subtitle" | ||
avatar="http://lorempixel.com/100/100/nature/"/> | ||
<CardMedia overlay={<CardTitle title="Title" subtitle="Subtitle"/>}> | ||
<img src="http://lorempixel.com/600/337/nature/"/> | ||
</CardMedia> | ||
<CardTitle title="Title" subtitle="Subtitle"/> | ||
<CardActions> | ||
<FlatButton label="Action1"/> | ||
<FlatButton label="Action2"/> | ||
</CardActions> | ||
<CardText> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. | ||
Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. | ||
Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. | ||
</CardText> | ||
</Card>`; | ||
|
||
this.desc = | ||
'A card is a piece of paper with unique related data that serves as an '+ | ||
'entry point to more detailed information. For example, a card could '+ | ||
'contain a photo, text, and a link about a single subject.'+ | ||
'\n\n'+ | ||
'Cards have a constant width and variable height. The maximum height is '+ | ||
'limited to the height of the available space on a platform, '+ | ||
'but it can temporarily expand (for example, to display a comment field). '+ | ||
'Cards do not flip over to reveal information on the back.'; | ||
|
||
|
||
this.componentInfo = []; | ||
} | ||
|
||
render() { | ||
return ( | ||
<ComponentDoc | ||
name="Card" | ||
code={this.code} | ||
desc={this.desc} | ||
componentInfo={this.componentInfo}> | ||
<Card> | ||
<CardHeader | ||
title="Title" | ||
subtitle="Subtitle" | ||
avatar={<Avatar>A</Avatar>}/> | ||
<CardHeader | ||
title="Demo Url Based Avatar" | ||
subtitle="Subtitle" | ||
avatar="http://lorempixel.com/100/100/nature/"/> | ||
<CardMedia overlay={<CardTitle title="Title" subtitle="Subtitle"/>}> | ||
<img src="http://lorempixel.com/600/337/nature/"/> | ||
</CardMedia> | ||
<CardTitle title="Title" subtitle="Subtitle"/> | ||
<CardActions> | ||
<FlatButton label="Action1"/> | ||
<FlatButton label="Action2"/> | ||
</CardActions> | ||
<CardText> | ||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. | ||
Donec mattis pretium massa. Aliquam erat volutpat. Nulla facilisi. | ||
Donec vulputate interdum sollicitudin. Nunc lacinia auctor quam sed pellentesque. | ||
Aliquam dui mauris, mattis quis lacus id, pellentesque lobortis odio. | ||
</CardText> | ||
</Card> | ||
</ComponentDoc> | ||
); | ||
} | ||
|
||
} | ||
|
||
module.exports = CardPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var React = require('react'); | ||
var Styles = require('../styles'); | ||
|
||
var CardActions = React.createClass({ | ||
getStyles: function () { | ||
return { | ||
root: { | ||
padding: 8 | ||
} | ||
} | ||
}, | ||
render: function () { | ||
var styles = this.getStyles(); | ||
|
||
var children = React.Children.map(this.props.children, function (child) { | ||
return React.cloneElement(child, { | ||
style: {marginRight: 8} | ||
}); | ||
}); | ||
|
||
return ( | ||
<div style={styles.root}> | ||
{children} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = CardActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
var React = require('react'); | ||
var Styles = require('../styles'); | ||
var Avatar = require('../avatar'); | ||
|
||
var CardHeader = React.createClass({ | ||
propTypes: { | ||
avatar: React.PropTypes.string, | ||
title: React.PropTypes.string, | ||
titleColor: React.PropTypes.string, | ||
subtitle: React.PropTypes.string, | ||
subtitleColor: React.PropTypes.string | ||
}, | ||
getDefaultProps: function () { | ||
return { | ||
titleColor: Styles.Colors.darkBlack, | ||
subtitleColor: Styles.Colors.lightBlack | ||
}; | ||
}, | ||
getStyles: function () { | ||
return { | ||
root: { | ||
height: 72, | ||
padding: 16, | ||
fontWeight: Styles.Typography.fontWeightMedium, | ||
boxSizing: 'border-box' | ||
}, | ||
text: { | ||
display: 'inline-block', | ||
verticalAlign: 'top' | ||
}, | ||
avatar: { | ||
marginRight:16 | ||
}, | ||
title: { | ||
color: this.props.titleColor, | ||
display: 'block', | ||
fontSize: 15 | ||
}, | ||
subtitle: { | ||
color: this.props.subtitleColor, | ||
display: 'block', | ||
fontSize: 14 | ||
} | ||
} | ||
}, | ||
render: function () { | ||
var styles = this.getStyles(); | ||
var avatar = this.props.avatar; | ||
|
||
if (React.isValidElement(this.props.avatar)) | ||
avatar = React.cloneElement(avatar, {style:styles.avatar}) | ||
else | ||
avatar = <Avatar src={this.props.avatar} style={styles.avatar}/> | ||
|
||
|
||
|
||
return ( | ||
<div style={styles.root}> | ||
{avatar} | ||
<div style={styles.text}> | ||
<span style={styles.title}>{this.props.title}</span> | ||
<span style={styles.subtitle}>{this.props.subtitle}</span> | ||
</div> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = CardHeader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
var React = require('react'); | ||
var Styles = require('../styles'); | ||
|
||
var CardMedia = React.createClass({ | ||
propTypes: { | ||
overlay: React.PropTypes.node | ||
}, | ||
getStyles: function () { | ||
return { | ||
root: { | ||
position: 'relative' | ||
}, | ||
overlayContainer: { | ||
position: 'absolute', | ||
top: 0, | ||
bottom: 0, | ||
right: 0, | ||
left: 0 | ||
}, | ||
overlay: { | ||
height: '100%', | ||
position: 'relative' | ||
}, | ||
overlayContent: { | ||
position: 'absolute', | ||
bottom: 0, | ||
right: 0, | ||
left: 0, | ||
paddingTop: 8, | ||
background: Styles.Colors.lightBlack | ||
} | ||
}; | ||
}, | ||
render: function () { | ||
var styles = this.getStyles(); | ||
|
||
var children = React.Children.map(this.props.children, function (child) { | ||
return React.cloneElement(child, { | ||
style: { | ||
verticalAlign: 'top', | ||
maxWidth: '100%', | ||
minWidth: '100%' | ||
} | ||
}); | ||
}); | ||
|
||
var overlayChildren = React.Children.map(this.props.overlay, function (child) { | ||
if (child.type.displayName === 'CardHeader' || child.type.displayName === 'CardTitle' | ||
) { | ||
return React.cloneElement(child, { | ||
titleColor: Styles.Colors.darkWhite, | ||
subtitleColor: Styles.Colors.lightWhite | ||
}); | ||
} else if (child.type.displayName === 'CardText') { | ||
return React.cloneElement(child, { | ||
color: Styles.Colors.darkWhite | ||
}); | ||
} else { | ||
return child; | ||
} | ||
}); | ||
|
||
return ( | ||
<div style={styles.root}> | ||
<div style={styles.media}> | ||
{children} | ||
</div> | ||
{(this.props.overlay) ? | ||
<div style={styles.overlayContainer}> | ||
<div style={styles.overlay}> | ||
<div style={styles.overlayContent}> | ||
{overlayChildren} | ||
</div> | ||
</div> | ||
</div> : ''} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = CardMedia; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
var React = require('react'); | ||
var Styles = require('../styles'); | ||
|
||
var CardText = React.createClass({ | ||
propTypes: { | ||
color: React.PropTypes.string | ||
}, | ||
getDefaultProps: function () { | ||
return { | ||
color: Styles.Colors.ck | ||
} | ||
}, | ||
getStyles: function () { | ||
return { | ||
root: { | ||
padding: 16, | ||
fontSize: '14px', | ||
color: this.props.color | ||
} | ||
} | ||
}, | ||
render: function () { | ||
var styles = this.getStyles(); | ||
|
||
return ( | ||
<div style={styles.root}> | ||
{this.props.children} | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = CardText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
var React = require('react'); | ||
var Styles = require('../styles'); | ||
|
||
var CardTitle = React.createClass({ | ||
propTypes: { | ||
title: React.PropTypes.string, | ||
titleColor: React.PropTypes.string, | ||
subtitle: React.PropTypes.string, | ||
subtitleColor: React.PropTypes.string | ||
}, | ||
getDefaultProps: function () { | ||
return { | ||
titleColor: Styles.Colors.darkBlack, | ||
subtitleColor: Styles.Colors.lightBlack | ||
}; | ||
}, | ||
getStyles: function () { | ||
return { | ||
root: { | ||
padding: 16 | ||
}, | ||
title: { | ||
fontSize: 24, | ||
color: this.props.titleColor, | ||
display: 'block', | ||
lineHeight: '36px' | ||
}, | ||
subtitle: { | ||
fontSize: 14, | ||
color: this.props.subtitleColor, | ||
display: 'block' | ||
} | ||
} | ||
}, | ||
render: function () { | ||
var styles = this.getStyles(); | ||
|
||
return ( | ||
<div style={styles.root}> | ||
<span style={styles.title}>{this.props.title}</span> | ||
<span style={styles.subtitle}>{this.props.subtitle}</span> | ||
</div> | ||
); | ||
} | ||
}); | ||
|
||
module.exports = CardTitle; |
Oops, something went wrong.