-
Notifications
You must be signed in to change notification settings - Fork 16
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
New DS core components: Menu & MenuItem #870
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
76b049f
storybook org
vmilan c015132
initial components
vmilan 6193b58
polishing components
vmilan aee6ed1
polishing and bugfixing
vmilan f95ae6d
polishing and bugfixing
vmilan 1ec8513
polishing and bugfixing
vmilan b1e2b09
final tweaks
vmilan 8feb3e9
fixing types and dense styles
vmilan 9028924
Design QA fixes
vmilan 99ad59e
Design QA fixes
vmilan 3180e3c
Design QA passed
vmilan 1f97af6
adaptations to cloud-native
vmilan 86a0a98
adaptations to cloud-native
vmilan 4fb2489
new iconColor prop
vmilan 51bef07
fix MenuList component ref
vmilan adc31c9
bugfixing
vmilan 070d1cc
temporary styles for QA process
vmilan 9dcaee4
fix nested MenuList padding
vmilan f1b415f
Merge branch 'master' into feature/ds-menu-component
vmilan 1ac01a6
revert styles for QA testing
vmilan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,10 @@ | ||
import { MenuProps as MuiMenuProps } from '@mui/material'; | ||
|
||
export type MenuProps = MuiMenuProps & { | ||
extended?: boolean; | ||
width?: string; | ||
height?: string; | ||
}; | ||
|
||
declare const Menu: (props: MenuProps) => JSX.Element; | ||
export default Menu; |
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,38 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Menu as MuiMenu, styled } from '@mui/material'; | ||
|
||
const StyledMenu = styled(MuiMenu, { | ||
shouldForwardProp: (prop) => !['extended', 'width', 'height'].includes(prop) | ||
})(({ extended, width, height, theme }) => ({ | ||
...(extended && { | ||
'.MuiMenuItem-root': { | ||
minHeight: theme.spacing(6) | ||
} | ||
}), | ||
'.MuiMenu-paper': { | ||
...(width && { | ||
width: width, | ||
minWidth: width | ||
}), | ||
...(height && { | ||
maxHeight: height | ||
}) | ||
} | ||
})); | ||
|
||
const Menu = ({ extended, width, height, children, ...otherProps }) => { | ||
return ( | ||
<StyledMenu extended={extended} width={width} height={height} {...otherProps}> | ||
{children} | ||
</StyledMenu> | ||
); | ||
}; | ||
|
||
Menu.propTypes = { | ||
extended: PropTypes.bool, | ||
width: PropTypes.string, | ||
height: PropTypes.string | ||
}; | ||
|
||
export default Menu; |
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,11 @@ | ||
import { MenuItemProps as MuiMenuItemProps } from '@mui/material'; | ||
|
||
export type MenuItemProps = MuiMenuItemProps & { | ||
subtitle?: boolean; | ||
destructive?: boolean; | ||
extended?: boolean; | ||
iconColor?: 'primary' | 'default'; | ||
}; | ||
|
||
declare const MenuItem: (props: MenuItemProps) => JSX.Element; | ||
export default MenuItem; |
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,117 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { MenuItem as MuiMenuItem, styled } from '@mui/material'; | ||
|
||
const StyledMenuItem = styled(MuiMenuItem, { | ||
shouldForwardProp: (prop) => | ||
!['subtitle', 'destructive', 'extended', 'iconColor'].includes(prop) | ||
})(({ subtitle, destructive, extended, iconColor, theme }) => ({ | ||
...(subtitle && { | ||
pointerEvents: 'none', | ||
columnGap: 0, | ||
...theme.typography.caption, | ||
fontWeight: 500, | ||
color: theme.palette.text.secondary, | ||
|
||
'&.MuiMenuItem-root': { | ||
minHeight: theme.spacing(3), | ||
paddingTop: 0, | ||
paddingBottom: 0, | ||
|
||
'&:not(:first-of-type)': { | ||
minHeight: theme.spacing(5), | ||
marginTop: theme.spacing(1), | ||
paddingTop: theme.spacing(1), | ||
borderTop: `1px solid ${theme.palette.divider}` | ||
} | ||
} | ||
}), | ||
|
||
...(iconColor === 'primary' && { | ||
'.MuiListItemIcon-root svg path': { | ||
fill: theme.palette.text.primary | ||
}, | ||
'&.Mui-selected .MuiListItemIcon-root svg path': { | ||
fill: theme.palette.primary.main | ||
} | ||
}), | ||
...(destructive && { | ||
color: theme.palette.error.main, | ||
|
||
'.MuiTypography-root': { | ||
color: theme.palette.error.main | ||
}, | ||
'svg, & .MuiSvgIcon-root': { | ||
color: theme.palette.error.main | ||
}, | ||
'.MuiListItemIcon-root svg path': { | ||
fill: theme.palette.error.main | ||
}, | ||
'&.Mui-selected .MuiListItemIcon-root svg path': { | ||
fill: theme.palette.error.main | ||
}, | ||
|
||
'&:hover': { | ||
backgroundColor: theme.palette.error.relatedLight | ||
}, | ||
'&.Mui-selected': { | ||
color: theme.palette.error.main, | ||
|
||
'.MuiTypography-root': { | ||
color: theme.palette.error.main | ||
}, | ||
'svg, & .MuiSvgIcon-root': { | ||
color: theme.palette.error.main | ||
} | ||
}, | ||
|
||
'&.Mui-disabled': { | ||
color: theme.palette.text.disabled, | ||
|
||
'.MuiTypography-root': { | ||
color: theme.palette.text.disabled | ||
}, | ||
svg: { | ||
color: theme.palette.text.disabled | ||
} | ||
} | ||
}), | ||
...(extended && { | ||
'&.MuiMenuItem-root': { | ||
minHeight: theme.spacing(6) | ||
} | ||
}) | ||
})); | ||
|
||
const MenuItem = ({ | ||
subtitle, | ||
destructive, | ||
extended, | ||
children, | ||
iconColor, | ||
...otherProps | ||
}) => { | ||
return ( | ||
<StyledMenuItem | ||
subtitle={subtitle} | ||
destructive={destructive} | ||
extended={extended} | ||
iconColor={iconColor} | ||
{...otherProps} | ||
> | ||
{children} | ||
</StyledMenuItem> | ||
); | ||
}; | ||
|
||
MenuItem.defaultProps = { | ||
iconColor: 'primary' | ||
}; | ||
MenuItem.propTypes = { | ||
subtitle: PropTypes.bool, | ||
destructive: PropTypes.bool, | ||
extended: PropTypes.bool, | ||
iconColor: PropTypes.oneOf(['primary', 'default']) | ||
}; | ||
|
||
export default MenuItem; |
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,10 @@ | ||
import { MenuListProps as MuiMenuListProps } from '@mui/material'; | ||
|
||
export type MenuListProps = MuiMenuListProps & { | ||
extended?: boolean; | ||
width?: string; | ||
height?: string; | ||
}; | ||
|
||
declare const MenuList: (props: MenuListProps) => JSX.Element; | ||
export default MenuList; |
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,49 @@ | ||
import React, { forwardRef } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { MenuList as MuiMenuList, styled } from '@mui/material'; | ||
|
||
const StyledMenuList = styled(MuiMenuList, { | ||
shouldForwardProp: (prop) => !['extended', 'width', 'height'].includes(prop) | ||
})(({ extended, width, height, theme }) => ({ | ||
...(extended && { | ||
'.MuiMenuItem-root': { | ||
minHeight: theme.spacing(6) | ||
} | ||
}), | ||
'&.MuiList-root': { | ||
...(width && { | ||
width: width, | ||
minWidth: width | ||
}), | ||
...(height && { | ||
maxHeight: height | ||
}) | ||
} | ||
})); | ||
|
||
const MenuList = forwardRef( | ||
({ extended, width, height, children, ...otherProps }, ref) => { | ||
// forwardRef needed to be able to hold a reference, in this way it can be a child for some Mui components, like Tooltip | ||
// https://mui.com/material-ui/guides/composition/#caveat-with-refs | ||
|
||
return ( | ||
<StyledMenuList | ||
extended={extended} | ||
width={width} | ||
height={height} | ||
ref={ref} | ||
{...otherProps} | ||
> | ||
{children} | ||
</StyledMenuList> | ||
); | ||
} | ||
); | ||
|
||
MenuList.propTypes = { | ||
extended: PropTypes.bool, | ||
width: PropTypes.string, | ||
height: PropTypes.string | ||
}; | ||
|
||
export default MenuList; |
63 changes: 29 additions & 34 deletions
63
packages/react-ui/src/components/molecules/MultipleSelectField/Filters.js
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Looks (potentially) a bit risky for current use cases... isn't it?
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.
It applies only to multiple selection case, and we need it globally for this use case 👍