Skip to content

Commit 2bf9b7d

Browse files
authored
fix: icon support to customize (#256)
1 parent 92b7321 commit 2bf9b7d

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

src/components/menu/menuItem.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface IMenuItemProps extends HTMLElementProps {
1313
/**
1414
* The name of icon
1515
*/
16-
icon?: string;
16+
icon?: React.ReactNode;
1717
type?: 'divider';
1818
/**
1919
* Item Name

src/components/menu/subMenu.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export interface ISubMenuProps extends IMenuItemProps {
3333
* The event of show subMenu, default value is 'hover'
3434
*/
3535
trigger?: TriggerEvent;
36-
icon?: string;
36+
icon?: React.ReactNode;
3737
data?: ISubMenuProps[];
3838
mode?: MenuMode;
3939
}
@@ -84,7 +84,11 @@ export function SubMenu(props: React.PropsWithChildren<ISubMenuProps>) {
8484
{...custom}
8585
>
8686
<a className={menuContentClassName}>
87-
<Icon className={checkClassName} type={icon || ''} />
87+
{typeof icon === 'string' ? (
88+
<Icon className={checkClassName} type={icon || ''} />
89+
) : (
90+
icon
91+
)}
8892
<span className={labelClassName}>
8993
{render ? render(props) : name}
9094
</span>

src/services/workbench/explorer/explorerService.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export class ExplorerService
204204
const nextMenu = headerToolBar?.contextMenu?.concat() || [];
205205
const currentMenu = nextMenu.find(searchById(id));
206206
if (currentMenu) {
207-
currentMenu.icon = this.toggleIcon(currentMenu.icon);
207+
currentMenu.icon = this.toggleIcon(currentMenu.icon as string);
208208
const next = {
209209
...headerToolBar,
210210
contextMenu: nextMenu,

src/workbench/editor/action.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@ function EditorAction(props: IEditorActionProps & IEditorController) {
8989
title={action.name?.toString()}
9090
>
9191
{action.icon ? (
92-
<Icon type={action.icon} />
92+
typeof action.icon === 'string' ? (
93+
<Icon type={action.icon} />
94+
) : (
95+
action.icon
96+
)
9397
) : (
9498
action.name
9599
)}

0 commit comments

Comments
 (0)