Skip to content

Commit 2933dae

Browse files
authored
Merge pull request #196 from open-source-labs/staging14
Merging Reactype 14.0 to master
2 parents 1b863bc + 75d2d64 commit 2933dae

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1344
-919
lines changed

CHANGE_LOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,41 @@
33
<h1 align="center">ReacType Change Log</h1>
44
</p>
55

6+
**Version 14.0.0 Changes**
7+
8+
Changes:<br>
9+
- Added functionality & improvements:
10+
- Event listeners:
11+
- Added ability to assign event listeners to elements in the bottom customization tab
12+
- Can name the function on the event or use the default name provided
13+
- Updates reflected in the code preview render
14+
- Live code preview: Bottom tool tabs code preview box updates immediately and automatically to reflect the latest changes in state
15+
- Converted the annotation button into a delete button on the canvas elements and reusable components
16+
- Code preview render: The formatting for generated code has been corrected for improved readability
17+
- Major UI changes:
18+
- Left panel:
19+
- Only display when mouse hovered over
20+
- When extended, floats in front of the canvas without affecting the main window formatting
21+
- Bottom panel
22+
- Retractable feature added
23+
- Has internal scroll ability in the tabs
24+
- Resized functionality is stable
25+
- Added indicator tabs to each signifying to the user their presence
26+
- Canvas container (upper left):
27+
- Changed the formatting to a center column with readable size and label orientation
28+
- Standardized the size of components and rate of growth when nesting
29+
- Tutorial:
30+
- Users can now reference tutorials in split-screen mode without the canvas being auto-cleared when going back and forth from the tutorial
31+
- Bug fixes:
32+
- Reusable component: The drag-and-drop feature for reusable components is now functioning smoothly and without bugs
33+
34+
Recommendations for Future Enhancements:<br>
35+
- Add function content in the current event listeners' function skeleton.
36+
- The code output formatting in generateCode.ts is currently difficult to read, and could be improved for better readability.
37+
- Currently, the project uses two sets of state management tools: useReducer/useContext and Redux. useReducer/useContext is used for handling the customization state, and Redux for managing the code preview, context manager, and dark mode reducer state. However, there seems to be some confusion around how to integrate these two tools effectively. For instance, both tools are used for managing the code preview state, and changing the useReducer/useContext state would replace the corresponding redux state. Need to clean up the logic and find a solution to solve this issue.
38+
- Some of the files structure is not accurate (e.g., customizationPanel.tsx is in the containers folder instead of the bottom folder), need to rearrange the file hierarchy.
39+
- Update packages and resolve package dependency issues.
40+
641
**Version 13.0.0 Changes**
742

843
New Functionality:<br>

README.md

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66

77
<!-- <p align="center">
88
<img width="1000" src="https://i.imgur.com/enAcYvB.png">
9-
</p>
10-
-->
9+
</p> -->
10+
1111
<div align="left">
12-
12+
1313
[![StarShield][stars]][stars-url]
1414
[![ContributorShield][contributors]][contributors-url]
1515
[![ForksShield][forks]][forks-url]
1616
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)
17-
![Version: 13.0.0](https://img.shields.io/badge/version-13.0.0-orange)
18-
17+
![Version: 14.0.0](https://img.shields.io/badge/version-14.0.0-orange)
18+
1919
</div>
2020
<!-- <p align="center">
2121
<img width="1000" src="https://i.imgur.com/FPizsat.png">
@@ -28,11 +28,10 @@
2828

2929

3030
<p align="center">
31-
<img width="1000" src="https://i.imgur.com/Tuyjd4e.png">
31+
<img width="1000" src="https://i.imgur.com/jR53ySV.png">
3232
</p>
3333

3434

35-
3635
**ReacType** is a rapid prototyping tool built on Electron that allows users _visualize_ their application architecture dynamically, employing a _drag-and-drop canvas display_ and an interactive, _real-time component code preview_ that can be exported as a **React** app for developers employing React component architecture alongside the comprehensive type-checking of **TypeScript**. In other words, **you can draw prototypes and export React / TypeScript code!**
3736

3837
Visit [reactype.io](https://reactype.io/) to learn more about the product.
@@ -41,7 +40,7 @@ Follow [@ReacType](https://twitter.com/reactype) on Twitter for important announ
4140

4241
### Documentation
4342

44-
If you want to read about using ReacType, the [User Manual](https://reactype-1.herokuapp.com/#/tutorial) is free and available online now.
43+
If you want to read about using ReacType, the [User Manual](https://reactype-1.herokuapp.com/#/tutorial) is free and available online now.
4544

4645
### Installing
4746

@@ -54,24 +53,37 @@ If you are given a warning that Apple could not scan the app. Please follow thes
5453
Download the latest [release](https://github.com/open-source-labs/ReacType/releases)
5554

5655

57-
## New with version 13.0.0
56+
## Changes with version 14.0.0
57+
58+
- **Added event listeners**: Users can now add event listeners to elements in the customization tab and view a list of added events. The list can be edited to remove events, and the live code preview will show the events being added and updated.
59+
- **Delete buttons added**: Delete buttons have been added to canvas components and elements for easier removal. Users can now delete elements or components directly by focusing on them and mouse-clicking the delete button.
60+
- **Live code preview and component tree update**: When users drag-and-drop components and elements, the live code preview and component tree are automatically updated to reflect the changes in real-time.
61+
- **Major UI enhancement**: The user interface has undergone a major change, including a sliding effect for the left and bottom panels to maximize user visibility. The styling has been unified and the display of the canvas hierarchy has been made more prominent for improved clarity.
62+
- **And more:** See [change log](https://github.com/open-source-labs/ReacType/blob/master/CHANGE_LOG.md) for more details on what was changed from the previous versions as well as plans for upcoming features!
5863

59-
- **Manage state locally**: Users can now manage state dynamically within nested components using React Hooks within the state manager tab.
60-
- **Add/delete props**: For a selected component, users can see a list of available props from the parent, add props, and delete props in case they are not required later on.
61-
- **State/props flow**: If state or props are deleted upstream, it will automatically update the state for its children components.
62-
- **Visualize state/props flow**: Within the display sub-tab of the state manager tab, users can visualize an interactive tree diagram depicting the state initialized in the current component and passed down props from the parent component.
63-
- **And more:** See [change log](https://github.com/open-source-labs/ReacType/blob/master/CHANGE_LOG.md) for more details on what was changed from the previous version as well as plans for upcoming features!
64+
## (_New_) File Structure
65+
66+
Here is the main file structure:
67+
<p align="center">
68+
<img width="1000" src="https://i.imgur.com/RdK8QzW.jpg">
69+
</p>
70+
Please refer to the link: https://excalidraw.com/#json=JKwzVD5qx6lsfiHW1_pQ9,XJ6uDoehVu-1bsx0SMlC6w for more details.
6471

6572

6673
## Run ReacType using CLI
6774

6875
- **Fork** and **Clone** Repository.
6976
- Open project directory
70-
- Install dependencies
77+
- Install dependencies.
7178

7279
```bash
7380
npm install
7481
```
82+
- If there is a dependency issue during installation, try switching to Node version v16.0.0 and then install. If the dependency issue still persists, try using the `--legacy-peer-deps` flag instead.
83+
84+
```bash
85+
npm install --legacy-peer-deps
86+
```
7587

7688
- To run the production build
7789

__tests__/__snapshots__/enzyme.test.tsx.snap

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,11 @@ exports[`Test the BottomTabs component Matches snapshot 1`] = `
644644
size="small"
645645
>
646646
<WithStyles(ForwardRef(Select))
647+
MenuProps={
648+
Object {
649+
"disablePortal": true,
650+
}
651+
}
647652
className="makeStyles-projectSelector-12"
648653
id="demo-simple-select"
649654
labelId="project-type-label"
@@ -684,7 +689,11 @@ exports[`Test the BottomTabs component Matches snapshot 1`] = `
684689
</WithStyles(ForwardRef(FormControl))>
685690
</div>
686691
</Styled(MuiBox)>
687-
<CreationPanel />
692+
<div
693+
className="tab-content"
694+
>
695+
<CreationPanel />
696+
</div>
688697
</div>
689698
`;
690699

@@ -694,6 +703,7 @@ exports[`Test the CanvasContainer component Matches snapshot 1`] = `
694703
Object {
695704
"backgroundColor": "lightgrey",
696705
"border": "2px Solid grey",
706+
"overflow": "auto",
697707
"width": "100%",
698708
}
699709
}

app/src/components/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ export const App = (): JSX.Element => {
8383
}, 15000);
8484
}
8585
}, [state]);
86+
// uncomment below to log state
87+
// console.log('STATE!!!!: ', state);
8688
return (
8789
<div className="app">
8890
<DndProvider backend={HTML5Backend}>

app/src/components/ContextAPIManager/ContextManager.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import DisplayContainer from './DisplayTab/DisplayContainer';
1313
const useStyles = makeStyles({
1414
contextContainer: {
1515
backgroundColor: 'white',
16-
height: '100%'
16+
height: 'fit-content'
1717
}
1818
});
1919

app/src/components/ContextAPIManager/CreateTab/components/AddContextForm.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ const AddContextForm = ({
2323
const handleClick = () => {
2424
if (contextInput === '' || contextInput === null) return;
2525
handleClickSelectContext();
26-
27-
//need to trigger the generate code functionality to update the code preview tab. Sending dummy data to trigger with a DELELTE ELEMENT dispatch method
28-
dispatch({
29-
type: 'DELETE ELEMENT',
30-
payload: 'FAKE_ID'
31-
});
3226
};
3327

3428
const onChange = (event, newValue) => {

app/src/components/StateManagement/CreateTab/components/StatePropsPanel.tsx

Lines changed: 43 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import {
44
styled,
55
Theme
66
} from "@material-ui/core/styles";
7-
import Button from "@material-ui/core/Button";
87
import {
98
FormControl,
109
FormHelperText,
1110
MenuItem,
1211
InputLabel,
1312
Select,
14-
TextField
13+
TextField,
14+
Button
1515
} from "@material-ui/core";
1616
import StateContext from "../../../../context/context";
1717
import TableStateProps from "./TableStateProps";
@@ -203,6 +203,7 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
203203
className={isThemeLight ? `${classes.selectEmpty} ${classes.rootUnderlineLight} ${classes.inputTextLight}` : `${classes.selectEmpty} ${classes.rootUnderlineDark} ${classes.inputTextDark}`}
204204
value={inputType}
205205
onChange={(event, index) => setInputType(index.props.value)}
206+
MenuProps={{ disablePortal: true }}
206207
style={ isThemeLight
207208
? {backgroundColor: '#eef0f1', color: '#000', border: '1px solid black', height: '28px', width: '200px'}
208209
: {backgroundColor: 'gray', color: '#fff', border: '1px solid white', height: '28px', width: '200px'}}
@@ -237,44 +238,47 @@ const StatePropsPanel = ({ isThemeLight, data}): JSX.Element => {
237238
Required
238239
</FormHelperText>
239240
</FormControl>
240-
<br></br>
241-
<MyButton
242-
type="submit"
243-
onClick={submitNewState}
244-
className={isThemeLight ? `${classes.addComponentButton} ${classes.lightThemeFontColor}` : `${classes.addComponentButton} ${classes.darkThemeFontColor}`}
241+
<br />
242+
<Button
243+
variant='contained'
244+
color='primary'
245+
type="submit"
246+
onClick={submitNewState}
247+
className={isThemeLight ? `${classes.addComponentButton} ${classes.lightThemeFontColor}` : `${classes.addComponentButton} ${classes.darkThemeFontColor}`}
245248
>
246249
Save
247-
</MyButton>
248-
<br></br>
250+
</Button>
251+
<br />
249252

250253
</FormControl>
251254
</div>
252-
<br></br>
253-
<div style={{display: 'flex', overflowX: 'scroll', width: '1700px'}}>
255+
<br />
256+
<div style={{display: 'flex', overflowX: 'scroll'}}>
254257
<div style={{display: 'flex', flexDirection: 'column'}}>
255-
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>
256-
Current Component State: {state.components[state.canvasFocus.componentId - 1].name}
257-
</h4>
258-
<TableStateProps rows1={rows1} setRows1={setRows1} canDeleteState = {true} selectHandler={handlerRowSelect} isThemeLight={isThemeLight} data={data}/>
258+
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>
259+
Current Component State: {state.components[state.canvasFocus.componentId - 1].name}
260+
</h4>
261+
<TableStateProps rows1={rows1} setRows1={setRows1} canDeleteState = {true} selectHandler={handlerRowSelect} isThemeLight={isThemeLight} data={data}/>
259262
</div>
260263

261264
<div style={{display: 'flex', flexDirection: 'column'}}>
262-
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>
263-
Available Props from Parent: {parentName ? parentName : 'No Parents'}
264-
</h4>
265-
<TableParentProps parentPassedInProps = {parentPassedInProps} parentComponent ={parentComponent} parentProps={parentProps} canDeleteState = {true} selectHandler={handlerRowSelect} isThemeLight={isThemeLight} data={data}/>
265+
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>
266+
Available Props from Parent: {parentName ? parentName : 'No Parents'}
267+
</h4>
268+
<TableParentProps parentPassedInProps = {parentPassedInProps} parentComponent ={parentComponent} parentProps={parentProps} canDeleteState = {true} selectHandler={handlerRowSelect} isThemeLight={isThemeLight} data={data}/>
266269
</div>
270+
267271
<div style={{display: 'flex', flexDirection: 'column', width: `${40}px`, color: 'black', justifyContent: 'center'}}>
268-
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor" class="bi bi-arrow-right-circle-fill" viewBox="0 0 16 16">
269-
<path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z"/>
270-
</svg>
271-
</div>
272+
<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" fill="currentColor" className="bi bi-arrow-right-circle-fill" viewBox="0 0 16 16">
273+
<path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0zM4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5H4.5z"/>
274+
</svg>
275+
</div>
272276

273277
<div style={{display: 'flex', flexDirection: 'column'}}>
274-
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>
275-
Passed in Props from Parent: {parentName ? parentName : 'No Parents'}
276-
</h4>
277-
<TablePassedInProps canDeleteState = {true} selectHandler={handlerRowSelect} isThemeLight={isThemeLight} data={data}/>
278+
<h4 className={isThemeLight ? classes.lightThemeFontColor : classes.darkThemeFontColor}>
279+
Passed in Props from Parent: {parentName ? parentName : 'No Parents'}
280+
</h4>
281+
<TablePassedInProps canDeleteState = {true} selectHandler={handlerRowSelect} isThemeLight={isThemeLight} data={data}/>
278282
</div>
279283
</div>
280284
</div>
@@ -368,7 +372,7 @@ const useStyles = makeStyles((theme: Theme) =>
368372
margin: "-20px 0px 5px 150px",
369373
borderStyle: "none",
370374
transition: "0.3s",
371-
borderRadius: "25px",
375+
// borderRadius: "25px",
372376
},
373377
rootToggle: {
374378
color: "#696969",
@@ -437,14 +441,15 @@ const useStyles = makeStyles((theme: Theme) =>
437441
}
438442
})
439443
);
440-
const MyButton = styled(Button)({
441-
background: "#0099E6",
442-
border: 0,
443-
borderRadius: 3,
444-
boxShadow: "0 0px 0px 2px #1a1a1a",
445-
color: "white",
446-
height: 24,
447-
width: 40,
448-
padding: "0 30px",
449-
});
444+
// change to Button to keep styling consistent
445+
// const MyButton = styled(Button)({
446+
// background: "#0099E6",
447+
// border: 0,
448+
// borderRadius: 3,
449+
// boxShadow: "0 0px 0px 2px #1a1a1a",
450+
// color: "white",
451+
// height: 24,
452+
// width: 40,
453+
// padding: "0 30px",
454+
// });
450455
export default StatePropsPanel;

app/src/components/StateManagement/StateManagement.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ import DisplayContainer from './DisplayTab/DisplayContainer';
1313
const useStyles = makeStyles({
1414
contextContainer: {
1515
backgroundColor: 'white',
16-
height: '100%'
16+
height: 'fit-content',
17+
width: 'fit-content',
18+
minWidth: '100%'
1719
}
1820
});
1921

app/src/components/bottom/BottomPanel.tsx

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,45 @@
1-
import React from 'react';
1+
import React, { RefObject, useEffect, useRef } from 'react';
22
import BottomTabs from './BottomTabs';
3-
import { Resizable } from 're-resizable';
43

54
const BottomPanel = (props): JSX.Element => {
5+
let y: number = 0;
6+
let h: number = 0;
7+
8+
const node = useRef() as React.MutableRefObject<HTMLDivElement>;
9+
10+
const mouseDownHandler = (e): void => {
11+
y = e.clientY;
12+
13+
const styles = window.getComputedStyle(node.current);
14+
h = parseInt(styles.height, 10);
15+
16+
document.addEventListener('mousemove', mouseMoveHandler);
17+
document.addEventListener('mouseup', mouseUpHandler);
18+
}
19+
20+
const mouseMoveHandler = function (e: MouseEvent): void {
21+
// How far the mouse has been moved
22+
const dy = y - e.clientY;
23+
24+
// Adjust the dimension of element
25+
node.current.style.height = `${h + dy}px`;
26+
};
27+
28+
const mouseUpHandler = function () {
29+
// Remove the handlers of `mousemove` and `mouseup`
30+
document.removeEventListener('mousemove', mouseMoveHandler);
31+
document.removeEventListener('mouseup', mouseUpHandler);
32+
};
33+
34+
useEffect(() => {
35+
node.current.style.height = '50vh';
36+
},[]);
37+
638
return (
7-
<Resizable
8-
enable={{
9-
top: true
10-
}}
11-
minHeight={'50%'}
12-
>
13-
<div className="bottom-panel" >
14-
<BottomTabs isThemeLight={props.isThemeLight}/>
15-
</div>
16-
</Resizable>
39+
<div className="bottom-panel" id='resize' ref={node}>
40+
<div id='resize-drag' onMouseDown={mouseDownHandler} tabIndex = {0} >......</div>
41+
<BottomTabs isThemeLight={props.isThemeLight}/>
42+
</div>
1743
);
1844
};
1945

0 commit comments

Comments
 (0)