-
-
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
9 changed files
with
184 additions
and
195 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,87 @@ | ||
var React = require('react'); | ||
var Classable = require('../mixins/classable'); | ||
var StylePropable = require('../mixins/style-propable'); | ||
var CustomVariables = require('../styles/variables/custom-variables'); | ||
|
||
var LinkMenuItem = React.createClass({ | ||
|
||
mixins: [Classable], | ||
|
||
propTypes: { | ||
index: React.PropTypes.number.isRequired, | ||
payload: React.PropTypes.string.isRequired, | ||
text: React.PropTypes.string.isRequired, | ||
target: React.PropTypes.string, | ||
disabled: React.PropTypes.bool | ||
}, | ||
|
||
getDefaultProps: function() { | ||
return { | ||
disabled: false | ||
}; | ||
}, | ||
|
||
render: function() { | ||
var classes = this.getClasses('mui-menu-item', { | ||
'mui-is-disabled': this.props.disabled | ||
}); | ||
var onClickHandler = (this.props.disabled) ? this._stopLink : undefined; | ||
// Prevent context menu 'Open In New Tab/Window' | ||
var linkAttribute = (this.props.disabled) ? 'data-href' : 'href'; | ||
var link = {linkAttribute: this.props.payload}; | ||
|
||
return ( | ||
<a key={this.props.index} className={classes} {...link} target={this.props.target} onClick={onClickHandler}>{this.props.text}</a> | ||
); | ||
}, | ||
|
||
_stopLink: function(event) { | ||
event.preventDefault(); | ||
mixins: [StylePropable], | ||
|
||
propTypes: { | ||
index: React.PropTypes.number.isRequired, | ||
payload: React.PropTypes.string.isRequired, | ||
text: React.PropTypes.string.isRequired, | ||
target: React.PropTypes.string, | ||
disabled: React.PropTypes.bool, | ||
className: React.PropTypes.string, | ||
}, | ||
|
||
getDefaultProps: function() { | ||
return { | ||
disabled: false | ||
}; | ||
}, | ||
|
||
getInitialState: function() { | ||
return { | ||
hovered: false | ||
} | ||
}, | ||
|
||
/** Styles */ | ||
_main: function() { // Same as MenuItem. | ||
var style = this.mergeAndPrefix({ | ||
userSelect: 'none', | ||
cursor: 'pointer', | ||
display: 'block', | ||
lineHeight: CustomVariables.menuItemHeight + 'px', | ||
paddingLeft: CustomVariables.menuItemPadding, | ||
paddingRight: CustomVariables.menuItemPadding, | ||
}); | ||
|
||
if (this.state.hovered && !this.props.disabled) style.backgroundColor = CustomVariables.menuItemHoverColor; | ||
if (this.props.selected) style.color = CustomVariables.menuItemSelectedTextColor; | ||
|
||
if (this.props.disabled) { | ||
style.cursor = 'default'; | ||
style.color = CustomVariables.disabledColor; | ||
} | ||
|
||
return this.mergeAndPrefix(style); | ||
}, | ||
|
||
render: function() { | ||
var onClickHandler = (this.props.disabled) ? this._stopLink : undefined; | ||
// Prevent context menu 'Open In New Tab/Window' | ||
var linkAttribute = (this.props.disabled) ? 'data-href' : 'href'; | ||
var link = {linkAttribute: this.props.payload}; | ||
|
||
return ( | ||
<a | ||
key={this.props.index} | ||
target={this.props.target} | ||
style={this._main()} {...link} | ||
className={this.props.className} | ||
onClick={onClickHandler} | ||
onMouseOver={this._handleMouseOver} | ||
onMouseOut={this._handleMouseOut}> | ||
{this.props.text} | ||
</a> | ||
); | ||
}, | ||
|
||
_stopLink: function(event) { | ||
event.preventDefault(); | ||
}, | ||
|
||
_handleMouseOver: function(e) { | ||
this.setState({hovered: true}); | ||
if (!this.props.disabled && this.props.onMouseOver) this.props.onMouseOver(e); | ||
}, | ||
|
||
_handleMouseOut: function(e) { | ||
this.setState({hovered: false}); | ||
if (!this.props.disabled && this.props.onMouseOut) this.props.onMouseOut(e); | ||
} | ||
}); | ||
|
||
module.exports = LinkMenuItem; |
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 |
---|---|---|
@@ -1,18 +1,62 @@ | ||
var React = require('react'); | ||
var StylePropable = require('../mixins/style-propable'); | ||
var Typography = require('../styles/core/typography'); | ||
var CustomVariables = require('../styles/variables/custom-variables'); | ||
|
||
var SubheaderMenuItem = React.createClass({ | ||
|
||
propTypes: { | ||
index: React.PropTypes.number.isRequired, | ||
text: React.PropTypes.string.isRequired | ||
}, | ||
|
||
render: function() { | ||
return ( | ||
<div key={this.props.index} className="mui-subheader">{this.props.text}</div> | ||
); | ||
|
||
mixins: [StylePropable], | ||
|
||
propTypes: { | ||
index: React.PropTypes.number.isRequired, | ||
text: React.PropTypes.string.isRequired, | ||
firstChild: React.PropTypes.bool, | ||
className: React.PropTypes.string, | ||
}, | ||
|
||
/** Styles */ | ||
_main: function() { | ||
|
||
var gutterMini = CustomVariables.spacing.desktopGutterMini; | ||
var subheaderHeight = CustomVariables.spacing.desktopSubheaderHeight; | ||
|
||
var style = { | ||
fontSize: '13px', | ||
letterSpacing: 0, | ||
fontWeight: Typography.fontWeightMedium, | ||
color: Typography.textDarkBlack, | ||
margin: 0, | ||
height: subheaderHeight + gutterMini, | ||
lineHeight: subheaderHeight + 'px', | ||
color: CustomVariables.subheaderTextColor, | ||
borderTop: 'solid 1px ' + CustomVariables.subheaderBorderColor, | ||
paddingTop: gutterMini, | ||
marginTop: gutterMini, | ||
}; | ||
|
||
if (this.props.firstChild) { | ||
style = this.mergeAndPrefix(style, { | ||
height: subheaderHeight, | ||
borderTop: 'none', | ||
paddingTop: 0, | ||
marginTop: 0, | ||
}); | ||
} | ||
|
||
|
||
return this.mergeAndPrefix(style); | ||
}, | ||
|
||
render: function() { | ||
return ( | ||
<div | ||
key={this.props.index} | ||
style={this._main()} | ||
className={this.props.className}> | ||
{this.props.text} | ||
</div> | ||
); | ||
} | ||
|
||
}); | ||
|
||
module.exports = SubheaderMenuItem; |
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 |
---|---|---|
@@ -1,5 +1,4 @@ | ||
@import "date-picker/date-picker.less"; | ||
@import "left-nav.less"; | ||
@import "paper.less"; | ||
@import "subheader.less"; | ||
@import "toolbar.less"; |
Oops, something went wrong.