Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
criado um arquivo para cada componente de plugin da ide
- Loading branch information
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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} />, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const customTabName = ['Custom Components']; |