Add icons to context menu
Summary: So pretty Reviewed By: lblasa Differential Revision: D47210293 fbshipit-source-id: 592dde396d43e4af30e38cab6a198e2153cfbf30
This commit is contained in:
committed by
Facebook GitHub Bot
parent
993413c5f2
commit
33ebe05126
@@ -41,6 +41,12 @@ import {
|
|||||||
BigGrepContextMenuItems,
|
BigGrepContextMenuItems,
|
||||||
IDEContextMenuItems,
|
IDEContextMenuItems,
|
||||||
} from './fb-stubs/IDEContextMenu';
|
} from './fb-stubs/IDEContextMenu';
|
||||||
|
import {
|
||||||
|
CopyOutlined,
|
||||||
|
FullscreenExitOutlined,
|
||||||
|
FullscreenOutlined,
|
||||||
|
SnippetsOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
|
||||||
const {Text} = Typography;
|
const {Text} = Typography;
|
||||||
|
|
||||||
@@ -492,8 +498,9 @@ const ContextMenu: React.FC<{
|
|||||||
if (hoveredNode) {
|
if (hoveredNode) {
|
||||||
copyItems.push(
|
copyItems.push(
|
||||||
<UIDebuggerMenuItem
|
<UIDebuggerMenuItem
|
||||||
key={'Copy Element name'}
|
key="Copy Element name"
|
||||||
text={'Copy Element name'}
|
text="Copy Element name"
|
||||||
|
icon={<CopyOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
tracker.track('context-menu-name-copied', {name: hoveredNode.name});
|
tracker.track('context-menu-name-copied', {name: hoveredNode.name});
|
||||||
getFlipperLib().writeTextToClipboard(hoveredNode.name);
|
getFlipperLib().writeTextToClipboard(hoveredNode.name);
|
||||||
@@ -506,6 +513,7 @@ const ContextMenu: React.FC<{
|
|||||||
<UIDebuggerMenuItem
|
<UIDebuggerMenuItem
|
||||||
key={key}
|
key={key}
|
||||||
text={`Copy ${key}`}
|
text={`Copy ${key}`}
|
||||||
|
icon={<SnippetsOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
tracker.track('context-menu-copied', {
|
tracker.track('context-menu-copied', {
|
||||||
name: hoveredNode.name,
|
name: hoveredNode.name,
|
||||||
@@ -526,7 +534,8 @@ const ContextMenu: React.FC<{
|
|||||||
hoveredNode.bounds.width !== 0 && (
|
hoveredNode.bounds.width !== 0 && (
|
||||||
<UIDebuggerMenuItem
|
<UIDebuggerMenuItem
|
||||||
key="focus"
|
key="focus"
|
||||||
text={`Focus ${hoveredNode.name}`}
|
text={`Focus element`}
|
||||||
|
icon={<FullscreenExitOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onFocusNode(hoveredNodeId);
|
onFocusNode(hoveredNodeId);
|
||||||
}}
|
}}
|
||||||
@@ -537,6 +546,7 @@ const ContextMenu: React.FC<{
|
|||||||
<UIDebuggerMenuItem
|
<UIDebuggerMenuItem
|
||||||
key="remove-focus"
|
key="remove-focus"
|
||||||
text="Remove focus"
|
text="Remove focus"
|
||||||
|
icon={<FullscreenOutlined />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
onFocusNode(undefined);
|
onFocusNode(undefined);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import {Menu} from 'antd';
|
import {Menu} from 'antd';
|
||||||
import {usePlugin, useValue} from 'flipper-plugin';
|
import {usePlugin, useValue, Layout} from 'flipper-plugin';
|
||||||
import {plugin} from '../../index';
|
import {plugin} from '../../index';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
@@ -20,8 +20,9 @@ import React from 'react';
|
|||||||
*/
|
*/
|
||||||
export const UIDebuggerMenuItem: React.FC<{
|
export const UIDebuggerMenuItem: React.FC<{
|
||||||
text: string;
|
text: string;
|
||||||
|
icon?: React.ReactNode;
|
||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}> = ({text, onClick}) => {
|
}> = ({text, onClick, icon}) => {
|
||||||
const instance = usePlugin(plugin);
|
const instance = usePlugin(plugin);
|
||||||
|
|
||||||
const isMenuOpen = useValue(instance.uiState.isContextMenuOpen);
|
const isMenuOpen = useValue(instance.uiState.isContextMenuOpen);
|
||||||
@@ -39,7 +40,10 @@ export const UIDebuggerMenuItem: React.FC<{
|
|||||||
onClick();
|
onClick();
|
||||||
instance.uiState.isContextMenuOpen.set(false);
|
instance.uiState.isContextMenuOpen.set(false);
|
||||||
}}>
|
}}>
|
||||||
{text}
|
<Layout.Horizontal center gap="small">
|
||||||
|
{icon}
|
||||||
|
{text}
|
||||||
|
</Layout.Horizontal>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user