-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
[Menu][DropDownMenu][SelectField] Add menuItemStyle and menuItemSelectedStyle properties #5389
Changes from 7 commits
3d22893
954b4f8
bd8df1a
44f0ab5
42ba90f
1137e01
4c4a606
fded0da
5454eaf
39325b3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,10 @@ class Menu extends Component { | |
* height. | ||
*/ | ||
maxHeight: PropTypes.number, | ||
/** | ||
* Override the inline-styles of menu items. | ||
*/ | ||
menuItemStyle: PropTypes.object, | ||
/** | ||
* If true, `value` must be an array and the menu will support | ||
* multiple selections. | ||
|
@@ -111,7 +115,7 @@ class Menu extends Component { | |
onItemTouchTap: PropTypes.func, | ||
/** @ignore */ | ||
onKeyDown: PropTypes.func, | ||
/** | ||
/** | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space typo |
||
* Override the inline-styles of selected menu items. | ||
*/ | ||
selectedMenuItemStyle: PropTypes.object, | ||
|
@@ -233,6 +237,7 @@ class Menu extends Component { | |
cloneMenuItem(child, childIndex, styles, index) { | ||
const { | ||
desktop, | ||
menuItemStyle, | ||
selectedMenuItemStyle, | ||
} = this.props; | ||
|
||
|
@@ -243,7 +248,7 @@ class Menu extends Component { | |
selectedChildrenStyles = Object.assign(styles.selectedMenuItem, selectedMenuItemStyle); | ||
} | ||
|
||
const mergedChildrenStyles = Object.assign({}, child.props.style, selectedChildrenStyles); | ||
const mergedChildrenStyles = Object.assign({}, child.props.style, menuItemStyle, selectedChildrenStyles); | ||
|
||
const isFocused = childIndex === this.state.focusIndex; | ||
let focusState = 'none'; | ||
|
@@ -475,6 +480,7 @@ class Menu extends Component { | |
onItemTouchTap, // eslint-disable-line no-unused-vars | ||
onEscKeyDown, // eslint-disable-line no-unused-vars | ||
selectedMenuItemStyle, // eslint-disable-line no-unused-vars | ||
menuItemStyle, // eslint-disable-line no-unused-vars | ||
style, | ||
value, // eslint-disable-line no-unused-vars | ||
valueLink, // eslint-disable-line no-unused-vars | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,17 +17,27 @@ function getStyles(props, context, state) { | |
|
||
const {open} = state; | ||
|
||
const {position} = props; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like change on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh no, sry. |
||
const positionProperties = {}; | ||
let transitionOperator = ''; | ||
if (position === 'top') { | ||
positionProperties.top = 0; | ||
transitionOperator = '-'; | ||
} else { | ||
positionProperties.bottom = 0; | ||
} | ||
|
||
const styles = { | ||
root: { | ||
position: 'fixed', | ||
...positionProperties, | ||
left: '50%', | ||
display: 'flex', | ||
bottom: 0, | ||
zIndex: zIndex.snackbar, | ||
visibility: open ? 'visible' : 'hidden', | ||
transform: open ? | ||
'translate(-50%, 0)' : | ||
`translate(-50%, ${desktopSubheaderHeight}px)`, | ||
`translate(-50%, ${transitionOperator}${desktopSubheaderHeight}px)`, | ||
transition: `${transitions.easeOut('400ms', 'transform')}, ${ | ||
transitions.easeOut('400ms', 'visibility')}`, | ||
}, | ||
|
@@ -92,12 +102,20 @@ class Snackbar extends Component { | |
* Controls whether the `Snackbar` is opened or not. | ||
*/ | ||
open: PropTypes.bool.isRequired, | ||
/** | ||
* Defines if the Snackbar is positioned on bottom or on top of the page | ||
*/ | ||
position: PropTypes.oneOf(['top', 'bottom']), | ||
/** | ||
* Override the inline-styles of the root element. | ||
*/ | ||
style: PropTypes.object, | ||
}; | ||
|
||
static defaultProps = { | ||
position: 'top', | ||
}; | ||
|
||
static contextTypes = { | ||
muiTheme: PropTypes.object.isRequired, | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rather keep that name to not introduce breaking changes.