Skip to content

Commit 7b365e7

Browse files
authored
Merge pull request #14 from oslabs-beta/jon-canvasRemove
Fix delete button for canvas components and nested components
2 parents f308b91 + 0f4b093 commit 7b365e7

File tree

5 files changed

+18
-5
lines changed

5 files changed

+18
-5
lines changed

app/src/components/main/DeleteButton.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ import { useDispatch, useSelector } from 'react-redux';
44
import { deleteChild } from '../../redux/reducers/slice/appStateSlice';
55
import { RootState } from '../../redux/store';
66
import { emitEvent } from '../../helperFunctions/socket';
7+
import { Delete } from '@mui/icons-material';
78

8-
function DeleteButton({ id, name }: DeleteButtons) {
9+
function DeleteButton({ id, name, onClickHandler }: DeleteButtons) {
910
const contextParam = useSelector((store: RootState) => store.contextSlice);
1011

1112
const roomCode = useSelector((store: RootState) => store.roomSlice.roomCode);
@@ -33,10 +34,11 @@ function DeleteButton({ id, name }: DeleteButtons) {
3334
id={'btn' + id}
3435
onClick={(event) => {
3536
event.stopPropagation();
37+
onClickHandler(event);
3638
deleteHTMLtype(id);
3739
}}
3840
>
39-
x
41+
<Delete className="deleteIcon" />
4042
</button>
4143
</div>
4244
);

app/src/components/main/DirectChildHTML.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ function DirectChildHTML({ childId, name, type, typeId, style }: ChildElement) {
8080
<DeleteButton
8181
id={childId}
8282
name={name[0].toLowerCase() + name.slice(1)}
83+
onClickHandler={onClickHandler}
8384
/>
8485
</span>
8586
</div>

app/src/components/main/DirectChildHTMLNestable.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,11 @@ function DirectChildHTMLNestable({
225225
{attributes && attributes.compLink ? ` ${attributes.compLink}` : ''}
226226
</strong>
227227
{routeButton}
228-
<DeleteButton id={childId} name={name} />
228+
<DeleteButton
229+
id={childId}
230+
name={name}
231+
onClickHandler={onClickHandler}
232+
/>
229233
</span>
230234
{renderChildren(children)}
231235
</div>

app/src/interfaces/Interfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export interface LoginInt {
116116
export interface DeleteButtons {
117117
id: number;
118118
name: string;
119+
onClickHandler: (event: any) => void;
119120
}
120121
export interface StatePropsPanelProps {
121122
selectHandler: (table: any) => void;

app/src/public/styles/style.css

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,14 @@ CANVAS WINDOW
727727
0px 2px 2px 0px rgb(0 0 0 / 14%), 0px 1px 5px 0px rgb(0 0 0 / 12%);
728728
}
729729

730-
.delete-button-empty:hover {
730+
.deleteIcon {
731+
font-size: 18px;
732+
color: #4a4a4a;
733+
cursor: pointer;
734+
}
735+
736+
.deleteIcon:hover {
731737
color: white;
732-
background-color: rgba(0, 100, 0, 0.4);
733738
}
734739

735740
.componentContainer {

0 commit comments

Comments
 (0)