Skip to content

Commit cc29ba4

Browse files
committed
made paths visible on canvas for react router links and routes
Co-Authored-By Chris Tang [email protected]
1 parent fb032d3 commit cc29ba4

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

app/src/components/main/Canvas.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function Canvas() {
2525
function onClickHandler(event) {
2626
event.stopPropagation();
2727
// note: a null value for the child id means that we are focusing on the top-level component rather than any child
28-
console.log(state.canvasFocus);
28+
console.log(state.canvasFocus);
2929
changeFocus(state.canvasFocus.componentId, null);
3030
};
3131

@@ -51,7 +51,6 @@ function Canvas() {
5151
}
5252
// if item dropped is going to be a new instance (i.e. it came from the left panel), then create a new child component
5353
if (item.newInstance) {
54-
console.log('Canvas first dispatch')
5554
dispatch({
5655
type: 'ADD CHILD',
5756
payload: {

app/src/components/main/DirectChildComponent.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import { ItemTypes } from '../../constants/ItemTypes';
99
import StateContext from '../../context/context';
1010
import { combineStyles } from '../../helperFunctions/combineStyles';
1111
import globalDefaultStyle from '../../public/styles/globalDefaultStyles';
12-
import renderChildren from '../../helperFunctions/renderChildren'
1312

14-
function DirectChildComponent({ childId, type, typeId, style }: ChildElement) {
13+
function DirectChildComponent({ childId, type, typeId, style, name }: ChildElement) {
1514
const [state, dispatch] = useContext(StateContext);
1615

1716
// find the top-level component corresponding to this instance of the component
@@ -64,13 +63,17 @@ function DirectChildComponent({ childId, type, typeId, style }: ChildElement) {
6463
interactiveStyle
6564
);
6665

67-
return (
66+
67+
// Renders name and not children of subcomponents to clean up Canvas view when dragging components
68+
// into the main canvas. To render html elements on canvas, import and invoke renderChildren
69+
return (
6870
<div
6971
onClick={onClickHandler}
7072
style={combinedStyle}
7173
ref={drag}
7274
>
73-
{renderChildren(referencedComponent.children)}
75+
<strong>{name}</strong>
76+
{` (${childId})`}
7477
</div>
7578
);
7679
}

app/src/components/main/DirectChildHTMLNestable.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ function DirectChildHTMLNestable({
2020
children,
2121
name,
2222
annotations,
23+
attributes
2324
}: ChildElement) {
2425
const [state, dispatch] = useContext(StateContext);
2526
const ref = useRef(null);
@@ -143,6 +144,7 @@ const snapShotFunc = () => {
143144
<div onClick={onClickHandler} style={combinedStyle} ref={ref} id={`canv${childId}`}>
144145
<strong>{HTMLType.placeHolderShort}</strong>
145146
{` ( ${childId} )`}
147+
<strong style={{ color: "#0099E6" }}>{attributes && attributes.compLink ? ` ${attributes.compLink}` : ''}</strong>
146148
{routeButton}
147149
<Annotation
148150
id={childId}

app/src/helperFunctions/renderChildren.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const renderChildren = (children: ChildElement[]) => {
5858
key={'DirChildHTMLNest' + childId.toString() + name}
5959
name={name}
6060
annotations={annotations}
61+
attributes={attributes}
6162
/>
6263
);
6364
}

0 commit comments

Comments
 (0)