Skip to content

Commit

Permalink
criado um arquivo para cada componente de plugin da ide
Browse files Browse the repository at this point in the history
  • Loading branch information
Piemontez committed Apr 30, 2024
1 parent 14f30fc commit f724ddd
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/plugins/custom/NewComponentAction.tsx
@@ -0,0 +1,47 @@
import { MenuActionProps } from '../../ide/types/menu';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { createRef } from 'react';
import EditComponenteModal from './EditComponenteModal';
import { useCustomComponentStore } from '../../ide/contexts/CustomComponentStore';
import { useNodeStore } from '../../core/contexts/NodeStore';
import { Button } from 'react-bootstrap';
import { useShallow } from 'zustand/react/shallow';
import { customTabName } from './tabname';

const editCompRef = createRef<EditComponenteModal>();

const ListComponents = () => {
const customComponents = useCustomComponentStore(useShallow((state) => state.customComponents));

return (
<>
{customComponents.map((custom, idx) => (
<Button
key={idx}
size="sm"
variant="transparent"
onDragStart={(event: any) => useNodeStore.getState().onDragStartCustom(event, custom)}
onClick={() => editCompRef.current?.handleEdit(custom)}
draggable
>
{custom.title}
</Button>
))}
</>
);
};

export const NewComponentAction: MenuActionProps = {
tabTitle: customTabName,
name: 'new',
title: (
<>
<span onClick={() => editCompRef.current?.handleNew()}>
<FontAwesomeIcon icon={'plus'} /> Create Custom
</span>

<ListComponents />
</>
),
headerExtraElement: <EditComponenteModal key="custom" ref={editCompRef} />,
};
1 change: 1 addition & 0 deletions src/plugins/custom/tabname.tsx
@@ -0,0 +1 @@
export const customTabName = ['Custom Components'];

0 comments on commit f724ddd

Please sign in to comment.