Skip to content

Commit 2c4658e

Browse files
Merged with Main
2 parents 360666a + 0b62141 commit 2c4658e

File tree

10 files changed

+148
-227
lines changed

10 files changed

+148
-227
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"extends": ["plugin:react/recommended", "airbnb-base"],
2+
"extends": ["plugin:react/recommended", "plugin:@typescript-eslint/recommended", "airbnb-base"],
33
"parserOptions": {
44
"ecmaFeatures": {
55
"jsx": true

app/src/components/bottom/CodePreview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ const CodePreview: React.FC<{
3434
useEffect(() => {
3535
setDivHeight(height);
3636
}, [height])
37-
// console.log(currentComponent.code);
3837
return (
3938
<div
4039
ref={wrapper}

app/src/components/login/SignIn.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
7070
const FBAPPID = process.env.REACT_APP_FB_APP_ID;
7171

7272
// this useEffect will check for cookies and set an item in localstorage for github Oauth session validation
73-
useEffect(() => {
73+
74+
// Caret start
75+
// Commented because window api is broken. Work in progress
76+
/* useEffect(() => {
7477
const githubCookie = setInterval(() => {
7578
window.api.setCookie();
7679
window.api.getCookie(cookie => {
@@ -85,7 +88,8 @@ const SignIn: React.FC<LoginInt & RouteComponentProps> = props => {
8588
}
8689
});
8790
}, 2000);
88-
}, []);
91+
}, []);*/
92+
// Caret end
8993

9094
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
9195
let inputVal = e.target.value;

app/src/components/main/Annotation.tsx

Lines changed: 34 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,23 @@ function Annotation({
1313
}: Annotations) {
1414
const [state, dispatch] = useContext(StateContext);
1515
const [annotation, setAnnotations] = useState(annotations);
16-
const ref = useRef(null);
1716
// React hook setting the annotation button modal open/close state
1817
const [open, setOpen] = React.useState(false);
18+
const ref = useRef(null);
19+
// focusIndex and childrenArray are used to find the array of all elements on the canvas
1920
const focusIndex = state.canvasFocus.componentId - 1;
2021
const childrenArray = state.components[focusIndex].children;
21-
22+
2223
// For showing the modal
23-
const handleOpen = () => {
24+
const handleOpen = (id) => {
2425
setOpen(true);
2526
};
26-
27-
// For closing the modal
28-
const handleClose = (event) => {
29-
const annoId = Number(event.target.ownerDocument.activeElement.lastChild.id);
30-
const childEle = handleFindAnno(childrenArray, annoId);
31-
// console.log('annoId', annoId);
32-
// console.log('childrenArray????', childrenArray);
33-
// console.log('childElement we are saving state to', childEle);
34-
// console.log('annotation being saved to state', annotation);
35-
if (childEle && annotation !== annotations) {
36-
// console.log('annotation saved to state!!!!!!!!')
27+
28+
// For closing the modal and setting the global annotation value to the hook value
29+
const handleClose = (id) => {
30+
const childEle = handleFindAnno(childrenArray, id);
31+
if (childEle) {
32+
// set global annotation value for this component to it's hook value
3733
childEle.annotations = annotation;
3834
}
3935
setOpen(false);
@@ -42,40 +38,37 @@ function Annotation({
4238
/**
4339
* Handles when text exists in the textarea of the modal.
4440
* If text exists/does not exist, corresponding button changes colors.
45-
*/
41+
* Sets hook value to what is contained in the textarea
42+
*/
4643
const handleAnnoChange = (event) => {
4744
const { value } = event.target;
48-
setAnnotations(value);
4945
if (value === '' || value === undefined) {
5046
ref.current.style.background = '#3ec1ac';
5147
} else {
5248
ref.current.style.background = '#cc99ff';
5349
}
50+
if (value != annotation) {
51+
setAnnotations(value);
52+
}
5453
}
5554

5655
/**
5756
* This handler will find the specific anno for the corresponding component on the canvas in the childrenArray -
5857
* where the canvas components are placed
5958
*/
6059
const handleFindAnno = (array, id) => {
61-
let refElement = '';
6260
for (let i = 0; i < array.length; i++) {
6361
const currentElement = array[i];
6462
if (currentElement.childId === id) {
6563
return currentElement;
66-
}
67-
else if (currentElement.children.length > 0) {
68-
refElement = handleFindAnno(currentElement.children, id);
69-
if (refElement !== '') return refElement;
70-
}
71-
}
72-
return refElement;
73-
};
74-
75-
const annoRefresh = (array) => {
76-
for (const element of array) {
77-
if (element.hasOwnProperty(annotations)) {
78-
console.log('Somthing here', ref);
64+
// finds nested element if nested within canvas
65+
} else if (currentElement.children.length > 0) {
66+
// temp is to prevent a return of empty string since canvas element should always exist and allows the
67+
// recursion to continue
68+
const temp = handleFindAnno(currentElement.children, id)
69+
if (temp != '') {
70+
return temp;
71+
}
7972
}
8073
if (element.children.length > 0) return annoRefresh(element.children);
8174
}
@@ -85,9 +78,13 @@ function Annotation({
8578
* This useEffect allows the annotations to remain persistent when changing between root level components on the right panel
8679
*/
8780
useEffect(() => {
88-
annoRefresh(childrenArray);
89-
}, [state.canvasFocus]);
90-
81+
const event = {
82+
target: { value: annotation },
83+
id: id,
84+
}
85+
handleAnnoChange(event);
86+
}, [])
87+
9188
const body = (
9289
<div className='annotate-position'>
9390
<span className='annotate-textarea-header'>Notes for: {name} ( {id} )</span>
@@ -96,9 +93,9 @@ function Annotation({
9693
)
9794

9895
return (
99-
<div style={{padding: '1px', float: 'right'}}>
100-
<button className='annotate-button-empty' id={"btn" + id} onClick={() => handleOpen()} ref={ref}>Notes</button>
101-
<Modal
96+
<div style={{ padding: '1px', float: 'right' }}>
97+
<button className='annotate-button-empty' id={"btn" + id} onClick={() => handleOpen(id)} ref={ref}>Notes</button>
98+
<Modal
10299
open={open}
103100
onClose={handleClose}
104101
keepMounted={true}
@@ -110,4 +107,4 @@ function Annotation({
110107
}
111108

112109
export default Annotation;
113-
// Caret End
110+
// Caret End

app/src/components/main/DemoRender.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const DemoRender = (props): JSX.Element => {
2121
const componentsToRender = [];
2222
for (const element of array) {
2323
if (element.name !== 'separator') {
24-
// console.log('detail from children array', element);
24+
// console.log('detail from children array', element);
2525
const elementType = element.name;
2626
const childId = element.childId;
2727
const elementStyle = element.style;
@@ -45,7 +45,7 @@ const DemoRender = (props): JSX.Element => {
4545
useEffect(() => {
4646
const focusIndex = state.canvasFocus.componentId - 1;
4747
const childrenArray = state.components[focusIndex].children;
48-
console.log('Refrenced Children in State!!!', childrenArray);
48+
//console.log('Refrenced Children in State!!!', childrenArray);
4949
const renderedComponents = componentBuilder(childrenArray);
5050
setComponents(renderedComponents);
5151
}, [state.components, state.canvasFocus]);

app/src/components/main/renderDemo.css

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
.form {
1919
position: relative;
2020
z-index: 1;
21-
background: #FFFFFF;
21+
background: #000000;
2222
max-width: 360px;
2323
margin: 0 auto 100px;
2424
padding: 45px;
@@ -181,9 +181,10 @@
181181
}
182182

183183

184-
/*
185184

186185

186+
/*
187+
187188
List Example
188189
<ul>
189190
<li><span>home</span></li>

0 commit comments

Comments
 (0)