Skip to content

Commit 4cd722b

Browse files
committed
modularized headerbutton for tooltips
1 parent 7e054d7 commit 4cd722b

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

app/src/components/left/HeaderButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const HeaderButton = (props) => {
2828
id={id}
2929
onClick={handleClickPopover}
3030
>
31-
{'Create Modules'}
31+
{'Module Editor'}
3232
<Popover
3333
id={id}
3434
open={open}
@@ -44,9 +44,9 @@ const HeaderButton = (props) => {
4444
}}
4545
>
4646
<div className={classes.popover}>
47-
<div>
47+
{/* <div>
4848
<HelpIcon id={id} size="small" />
49-
</div>
49+
</div> */}
5050
<div>
5151
Add modules to create a canvas for grouping your components.
5252
</div>

app/src/components/left/ModulePanel.tsx

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,24 @@ import AddCircleIcon from '@mui/icons-material/AddCircle';
55
import ComponentDrag from './ComponentDrag';
66
import ComponentPanel from '../right/ComponentPanel';
77
import { RootState } from '../../redux/store';
8-
import { useSelector } from 'react-redux';
8+
import { useSelector, useDispatch } from 'react-redux';
99
import ComponentsContainer from './ComponentsContainer';
1010
import CreatePanel from './CreatePanel';
1111
import HeaderButton from './HeaderButton';
12+
import HTMLItem from './HtmlItem';
13+
import Grid from '@mui/material/Grid';
14+
import HTMLTypes from './redux/HTMLTypes';
1215

1316
interface ModulePanelProps {
1417
isThemeLight: boolean;
1518
}
16-
const ModulePanel: React.FC<ModulePanelProps> = ({
17-
isThemeLight
18-
}: ModulePanelProps) => {
19+
const ModulePanel: React.FC<ModulePanelProps> = ({ isThemeLight }) => {
1920
const state = useSelector((store: RootState) => store.appState);
21+
const contextParam = useSelector((store: RootState) => store.contextSlice);
22+
const roomCode = useSelector((store: RootState) => store.roomSlice.roomCode);
2023
const [isCreatingModule, setIsCreatingModule] = useState(false);
2124
const [isEditingModule, setIsEditingModule] = useState(false);
25+
const dispatch = useDispatch();
2226

2327
const customComponents = state.components.filter(
2428
(comp) => !state.rootComponents.includes(comp.id)
@@ -32,6 +36,20 @@ const ModulePanel: React.FC<ModulePanelProps> = ({
3236
setIsEditingModule(!isEditingModule);
3337
};
3438

39+
const handleDelete = (id: number): void => {
40+
dispatch(deleteElement({ id: id, contextParam: contextParam }));
41+
if (roomCode) {
42+
emitEvent('deleteElementAction', roomCode, {
43+
id,
44+
contextParam
45+
});
46+
}
47+
};
48+
49+
const htmlTypesToRender = state.HTMLTypes.filter(
50+
(type) => type.name !== 'separator'
51+
);
52+
3553
return (
3654
<div className="modulePanelContainer">
3755
{isEditingModule ? (
@@ -49,6 +67,26 @@ const ModulePanel: React.FC<ModulePanelProps> = ({
4967
setIsCreatingModule={setIsCreatingModule}
5068
isThemeLight={false}
5169
/>
70+
<Grid container justifyContent="space-around" columnSpacing={2}>
71+
{htmlTypesToRender.map((option) => {
72+
if (
73+
(option.name === 'Switch' ||
74+
option.name === 'LinkTo' ||
75+
option.name === 'Route') &&
76+
state.projectType === 'Classic React'
77+
) {
78+
return (
79+
<HTMLItem
80+
name={option.name}
81+
key={`html-${option.name}`}
82+
id={option.id}
83+
icon={option.icon}
84+
handleDelete={handleDelete}
85+
/>
86+
);
87+
}
88+
})}
89+
</Grid>
5290
<ComponentDrag
5391
isVisible={true}
5492
isThemeLight={false}

0 commit comments

Comments
 (0)