Menu item disabled UI fixed (#484)
This commit is contained in:
parent
8a0966d1f7
commit
cb2e85785f
|
|
@ -11,25 +11,33 @@ type MenuItemProps = CommonComponentProps & {
|
||||||
onSelect?: () => void;
|
onSelect?: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const ItemRow = styled.div`
|
const ItemRow = styled.div<{ disabled?: boolean }>`
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: ${props => props.theme.spaces[4]}px
|
padding: ${props => props.theme.spaces[4]}px
|
||||||
${props => props.theme.spaces[6]}px;
|
${props => props.theme.spaces[6]}px;
|
||||||
|
|
||||||
&:hover {
|
${props =>
|
||||||
cursor: pointer;
|
!props.disabled
|
||||||
background-color: ${props => props.theme.colors.blackShades[4]};
|
? `
|
||||||
.${Classes.TEXT} {
|
&:hover {
|
||||||
color: ${props => props.theme.colors.blackShades[9]};
|
cursor: pointer;
|
||||||
}
|
background-color: ${props.theme.colors.blackShades[4]};
|
||||||
.${Classes.ICON} {
|
.${Classes.TEXT} {
|
||||||
path {
|
color: ${props.theme.colors.blackShades[9]};
|
||||||
fill: ${props => props.theme.colors.blackShades[9]};
|
|
||||||
}
|
}
|
||||||
|
.${Classes.ICON} {
|
||||||
|
path {
|
||||||
|
fill: ${props.theme.colors.blackShades[9]};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`
|
||||||
|
: `
|
||||||
|
&:hover {
|
||||||
|
cursor: not-allowed;
|
||||||
}
|
}
|
||||||
}
|
`}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const IconContainer = styled.div`
|
const IconContainer = styled.div`
|
||||||
|
|
@ -43,7 +51,7 @@ const IconContainer = styled.div`
|
||||||
|
|
||||||
function MenuItem(props: MenuItemProps) {
|
function MenuItem(props: MenuItemProps) {
|
||||||
return (
|
return (
|
||||||
<ItemRow onClick={props.onSelect}>
|
<ItemRow onClick={props.onSelect} disabled={props.disabled}>
|
||||||
<IconContainer>
|
<IconContainer>
|
||||||
{props.icon ? <Icon name={props.icon} size={IconSize.LARGE} /> : null}
|
{props.icon ? <Icon name={props.icon} size={IconSize.LARGE} /> : null}
|
||||||
{props.text ? (
|
{props.text ? (
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ export const MenuStory = () => {
|
||||||
icon={select("First Icon", IconCollection, undefined)}
|
icon={select("First Icon", IconCollection, undefined)}
|
||||||
onSelect={action("clicked-first-option")}
|
onSelect={action("clicked-first-option")}
|
||||||
label={<span>W</span>}
|
label={<span>W</span>}
|
||||||
|
disabled={boolean("First option disabled", false)}
|
||||||
/>
|
/>
|
||||||
{boolean("First menu item divider", false) ? <MenuDivider /> : null}
|
{boolean("First menu item divider", false) ? <MenuDivider /> : null}
|
||||||
<MenuItem
|
<MenuItem
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user