11import React from "react" ;
2- import { MenuItem as BlueprintMenuItem , MenuItemProps as BlueprintMenuItemProps } from "@blueprintjs/core" ;
2+ import {
3+ Classes as BlueprintClasses ,
4+ MenuItem as BlueprintMenuItem ,
5+ MenuItemProps as BlueprintMenuItemProps ,
6+ } from "@blueprintjs/core" ;
7+ import classNames from "classnames" ;
38
49import { openInNewTab } from "../../common/utils/openInNewTab" ;
510import { CLASSPREFIX as eccgui } from "../../configuration/constants" ;
@@ -11,10 +16,10 @@ import { TestIconProps } from "./../Icon/TestIcon";
1116
1217export interface MenuItemProps
1318 extends
14- Omit < BlueprintMenuItemProps , "icon" | "children" > ,
19+ Omit < BlueprintMenuItemProps , "icon" | "children" | "intent" > ,
1520 Omit < React . AnchorHTMLAttributes < HTMLAnchorElement > , "onClick" | "onFocus" | "target" | "children" > {
16- /*
17- * If set the icon is diplayed on the left side of the menu item.
21+ /**
22+ * If set the icon is displayed on the left side of the menu item.
1823 */
1924 icon ?: ValidIconName | string [ ] | React . ReactElement < TestIconProps > ;
2025 /**
@@ -25,6 +30,10 @@ export interface MenuItemProps
2530 * Tooltip, but only added to the label, not to the full menu item.
2631 */
2732 tooltip ?: string | React . JSX . Element ;
33+ /**
34+ * Visual intent color to apply to element.
35+ */
36+ intent ?: BlueprintMenuItemProps [ "intent" ] | "accent" ;
2837}
2938
3039/**
@@ -38,6 +47,7 @@ export const MenuItem = ({
3847 href,
3948 text,
4049 tooltip,
50+ intent,
4151 ...restProps
4252} : MenuItemProps ) => {
4353 return (
@@ -56,7 +66,10 @@ export const MenuItem = ({
5666 onClick = { ( e : React . MouseEvent < HTMLElement > ) =>
5767 openInNewTab ( e as React . MouseEvent < HTMLAnchorElement > , onClick , href )
5868 }
59- className = { `${ eccgui } -menu__item ` + className }
69+ className = { classNames ( `${ eccgui } -menu__item` , className , {
70+ // control blueprint intent classes to enhance it by new options
71+ [ `${ BlueprintClasses . getClassNamespace ( ) } -intent-${ intent } ` ] : intent ,
72+ } ) }
6073 icon = { icon ? typeof icon === "string" || Array . isArray ( icon ) ? < Icon name = { icon } /> : icon : false }
6174 >
6275 { children ?? null }
0 commit comments