Skip to content

Commit 697eac6

Browse files
committed
Merge branch 'stretch' of https://github.com/oslabs-beta/ReacType into native
2 parents 3bd99f8 + 08fab24 commit 697eac6

File tree

5 files changed

+98
-49
lines changed

5 files changed

+98
-49
lines changed

README.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
2727

2828
* **Linux users**: run the application as a super user in order to read and write files.
2929

30-
![Image of ReacType Application](https://i.imgur.com/0wV7R1P.jpg)
30+
![Image of ReacType Application](https://i.imgur.com/OgcP9II.png)
3131

3232
### How to use
3333

@@ -37,16 +37,14 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
3737
- To render a component **_instance_** to the screen, first select the component, or _parent_, that the instance will be rendered within. This selected component will be represented in a new canvas view, with its own white box. Then press the plus button next to the component name. An instance, or _child_, representation will appear on the canvas.
3838
- To add draggable **HTML elements**, select the image icons on the lower left panel.
3939

40-
![Gif of adding](https://imgur.com/sZloD8o.gif)
40+
![Gif of adding](https://i.imgur.com/hdVTFcP.gif)
4141

4242
- The bottom panel allows the user to toggle between 4 different views: a **tree diagram of the application**, a **real-time preview of the exportable code**, a form to enter component props, and a form to add HTML attributes.
4343

44-
![Gif of code preview & tree](https://imgur.com/KZb2UTO.gif)
45-
4644
- **_Props_** can be added to each component within its tab on bottom panel. Enter in a _key-value pair_, select its data _type_ and press the bottom 'ADD PROP'.
4745
- **_HTML Element Attributes_** of class name and ID can be added to each HTML element after an HTML element has been rendered to the canvas.
4846

49-
![Gif of attr & props](https://imgur.com/JgCiBE9.gif)
47+
![Gif of attr & props](https://i.imgur.com/cmgOLLN.gif)
5048

5149
- To **_delete_** a _child_ or instance from the canvas, select the desired instance and either press the _delete_ key.
5250
- To **_delete_** a _component_, click the 'DELETE' button of the desired component in the left panel.

src/components/bottom/AddChildProps.tsx

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,30 +41,6 @@ class AddChildProps extends Component<ChildPropsTypes> {
4141
);
4242
});
4343

44-
// const arrayPropsAvailable = [];
45-
// // IIFE : so that it runs without needing to be invoked
46-
// (() => {
47-
// focusComponent.props.map(prop => {
48-
// // console.log('this is component Name from props array', prop.key);
49-
// arrayPropsAvailable.push(
50-
// <span>
51-
// <input
52-
// type='checkbox'
53-
// id={`${prop}checkbox-${prop.key}`}
54-
// name={`${prop}checkbox-${prop.key}`}
55-
// />
56-
// <label
57-
// className={`labelForPropsToAddToChild`}
58-
// for={`${prop}checkbox-${prop.key}`}
59-
// >
60-
// {prop.key}
61-
// </label>
62-
// </span>
63-
// );
64-
// });
65-
// })();
66-
// console.log('this is the array of props available', arrayPropsAvailable);
67-
6844
return (
6945
<div>
7046
<MaterialTable

src/reducers/__tests__/leftReducers.test.ts

Lines changed: 84 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ describe('Left reducers', () => {
1010
// redefine the default state before each reducer test
1111
beforeEach(() => {
1212
state = initialApplicationState;
13-
state.components.push(testComponent);
1413
});
1514

1615
// TEST CHANGE FOCUS COMPONENT: test component will add "look" for "test" after it's added
@@ -173,6 +172,7 @@ describe('Left reducers', () => {
173172
type: types.CHANGE_FOCUS_COMPONENT,
174173
payload: { title: 'TEST' }
175174
};
175+
state.components.push(testComponent);
176176
const newState = reducers.changeFocusComponent(state, action.payload);
177177
// expecting new payload of "title" to the payload we just created
178178
expect(newState.focusComponent.title).toEqual(action.payload.title);
@@ -193,22 +193,87 @@ describe('Left reducers', () => {
193193
});
194194

195195
// TEST DELETE CHILD: test child should be deleted from local state components array
196-
// describe('deleteChild reducer', () => {
197-
// it('should delete test component', () => {
198-
// // CHANGE FOCUS COMPONENT FIRST
199-
// // const action = {
200-
// // type: types.CHANGE_FOCUS_COMPONENT,
201-
// // payload: { title: 'TEST' }
202-
// // };
203-
// // const newState = reducers.changeFocusComponent(state, action.payload);
204-
// const prevState = cloneDeep(state);
205-
// console.log('this is prevState', prevState)
206-
// const newState = reducers.deleteChild(state, {});
207-
// // expecting new payload of "title" to the payload we just created
208-
// expect(prevState.focusComponent.childrenArray).not.toEqual(
209-
// newState.focusComponent.childrenArray
210-
// );
211-
// });
212-
});
196+
describe('deleteChild reducer', () => {
197+
it('should delete test component', () => {
198+
// grab initial copy of current state
199+
const prevState = cloneDeep(state);
200+
// push into it the test component
201+
prevState.focusComponent.childrenArray.push(testComponent);
202+
203+
//take new state and delete from it the testComponent
204+
const newState = reducers.deleteChild(state, {});
205+
206+
// expecting previous state not to equal new state after deletion of test component
207+
expect(prevState.focusComponent.childrenArray).not.toEqual(
208+
newState.focusComponent.childrenArray
209+
);
210+
});
211+
});
212+
// TEST ADD COMPONENT: adds component to the global state components array
213+
describe('addComponent reducer', () => {
214+
it('return the state as it was if an empty title', () => {
215+
const action = {
216+
type: types.ADD_COMPONENT,
217+
payload: { title: '' }
218+
};
219+
// grab initial copy of current state
220+
const prevState = cloneDeep(state);
221+
222+
//take new state and add testComponent
223+
const newState = reducers.addComponent(state, action.payload);
224+
// expecting previous state not to equal new state after deletion of test component
225+
expect(prevState.components[2]).toEqual(newState.components[2]);
226+
});
227+
228+
it('should add test component', () => {
229+
const action = {
230+
type: types.ADD_COMPONENT,
231+
payload: { title: 'TESTCOMPONENT' }
232+
};
233+
// grab initial copy of current state
234+
const prevState = cloneDeep(state);
213235

214-
// NEXT TEST
236+
//take new state and add testComponent
237+
const newState = reducers.addComponent(prevState, action.payload);
238+
239+
// expecting previous state not to equal new state after deletion of test component
240+
expect(prevState.components[2]).not.toEqual(newState.components[2]);
241+
});
242+
});
243+
// TEST ADD CHILD: adds child to the focus component's childrenArray
244+
describe('addChild reducer', () => {
245+
it('return focus component childrenarray with test react component', () => {
246+
const actionReact = {
247+
type: types.ADD_CHILD,
248+
payload: {
249+
title: 'TestREACTComponent',
250+
childType: 'COMP'
251+
}
252+
};
253+
254+
state = reducers.addComponent(state, { title: 'TestREACTComponent' });
255+
const newState = reducers.addChild(state, actionReact.payload);
256+
257+
expect(state.focusComponent.childrenArray).not.toEqual(
258+
newState.focusComponent.childrenArray
259+
);
260+
});
261+
262+
it('return focus component childrenarray with test HTML component', () => {
263+
const actionHTML = {
264+
type: types.ADD_CHILD,
265+
payload: {
266+
title: 'TestHTMLComponent',
267+
childType: 'HTML'
268+
}
269+
};
270+
271+
state = reducers.addComponent(state, { title: 'TestHTMLComponent' });
272+
const newState = reducers.addChild(state, actionHTML.payload);
273+
274+
expect(state.focusComponent.childrenArray).not.toEqual(
275+
newState.focusComponent.childrenArray
276+
);
277+
});
278+
});
279+
});

src/utils/componentRender.util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ const componentRender = (
179179
180180
/* Replace "any" with stricter types to reflect your usage*/
181181
interface Props {
182-
${props.map(prop => `${prop.key}: ${typeSwitcher(prop.type)};\n`)}
182+
${props.map(prop => `${prop.key}: ${typeSwitcher(prop.type)}\n`)}
183183
};
184184
185185
${

src/utils/htmlElements.util.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,16 @@ const HTMLelements: htmlElementsInt = {
9494
width: 50,
9595
height: 50,
9696
attributes: ['className', 'id', 'href']
97+
},
98+
HTML: {
99+
width: 50,
100+
height: 50,
101+
attributes: ['className', 'id']
102+
},
103+
NATIVE: {
104+
width: 50,
105+
height: 50,
106+
attributes: ['className', 'id']
97107
}
98108
};
99109

0 commit comments

Comments
 (0)