Skip to content

Commit db2bc20

Browse files
merging with styling changes from christian
2 parents 321e4d3 + 4532d07 commit db2bc20

File tree

11 files changed

+183
-244
lines changed

11 files changed

+183
-244
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
# ReacType
22

3-
**ReacType** is a prototyping tool for developers employing **React** component architecture while utilizing the comprehensive type checking of **TypeScript**.
43

5-
**ReacType** allows the user to _visualize_ their application architecture dynamically, employing a _canvas display_, an _application tree_, and a _component code preview_. The user can create components and load _instances_ of these components, as well as nested HTML elements, onto the canvas. These visual representations quickly reveal parent-child relationships between components and the embedded instances, with component views that can be toggled between and draggable representations that resized on the canvas itself. This architecture can then be _exported_ as TypeScript application files to be used as a starter template for any repository.
4+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/team-reactype/ReacType/pulls)
5+
![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)
66

7-
Download for [MacOS](), [Windows](), [Linux]().
7+
**ReacType** is a visual prototyping tool for developers employing **React** component architecture alongside the comprehensive type checking of **TypeScript**.
8+
9+
**ReacType** allows the user to _visualize_ their application architecture dynamically, employing a _canvas display_, an _application tree_, and a _component code preview_. The user can create components and load _instances_ of these components, as well as nested HTML elements, onto the canvas. This architecture can then be _exported_ as TypeScript application files to be used as a starter template for any repository.
10+
11+
Download for [MacOS](), [Windows](), [Linux]().
812

913
### How to use
1014

1115
- Open the application to start a new project. It will open in the root App component, with its name listed in the left panel and the component represented by the white box on the canvas.
12-
- To add a new component, type its name in the upper right panel, in the field '**Add class component**', and press the plus button.
16+
- To add a new component, type its name in the upper left panel, in the field '**Add class component**', and press enter.
1317
- 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.
1418
- To add draggable HTML elements, select the image icons on the lower left panel.
15-
- The bottom panel allows the user to toggle between 4 different views: a tree diagram of the application, a preview of the code, a form to enter component props, and a form to add HTML attributes.
19+
- The bottom panel allows the user to toggle between 4 different views: a tree diagram of the application, a preview of the exportable code, a form to enter component props, and a form to add HTML attributes.
1620
- **_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'.
1721
- **_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.
1822
- To **_delete_** a _child_ or instance from the canvas, select the desired instance and either press the _delete_ key or click the 'DELETE CHILD' button.
@@ -22,7 +26,7 @@ Download for [MacOS](), [Windows](), [Linux]().
2226
### To Export Files
2327

2428
- Once finished setting up the application template, press the green 'EXPORT PROJECT' button at the bottom of the left panel and choose between two options to export your files:
25-
1. Export the component files into a src folder. This option will allow a developer to add these files to an existing project.
29+
1. Export the component files into a components folder. This option will allow a developer to add these files to an existing project.
2630
1. Export a new project with TypeScript config files and the component files. This option will allow a developer to immediately begin a new project.
2731

2832
#### Authors
@@ -67,4 +71,4 @@ yarn run electron
6771

6872
## License
6973

70-
This project is licensed under the MIT License - see the [LICENSE.md]() file for details.
74+
This project is licensed under the MIT License - see the [LICENSE.md](https://github.com/team-reactype/ReacType/blob/development/LICENSE.md) file for details.

main.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,6 @@ function openFile() {
3333
mainWindow.webContents.send('new-file', file);
3434
}
3535

36-
// export files
37-
function exportComponents() {
38-
console.log('hi from exportComponents');
39-
}
40-
4136
// Choose directory
4237
ipcMain.on('choose_app_dir', (event) => {
4338
const directory = dialog.showOpenDialog(mainWindow, {
@@ -66,7 +61,7 @@ const createWindow = () => {
6661
width,
6762
height,
6863
webPreferences: {
69-
zoomFactor: 0.8,
64+
zoomFactor: 0.9,
7065
'node-Integration': false,
7166
},
7267
show: false,

src/components/GrandchildRectangle.jsx

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { Rect, Group } from 'react-konva';
33
// import findComponentById from '../utils/findComponentById.ts';
44

55
class GrandchildRectangle extends Component {
6+
state = {
7+
imageHeight: 0,
8+
imageWidth: 0,
9+
};
10+
611
getComponentColor(componentId) {
712
// const color = findComponentById(componentId, this.props.components).color;
813
const color = this.props.components.find(comp => comp.id === componentId).color;
@@ -14,11 +19,12 @@ class GrandchildRectangle extends Component {
1419
}
1520

1621
setImage = imageSource => {
17-
//console.log("IMAGE SOURCE", imageSource);
22+
// console.log("IMAGE SOURCE", imageSource);
1823
if (!imageSource) return;
1924
const image = new window.Image();
2025
image.src = imageSource;
2126
if (!image.height) return null;
27+
this.setState({ imageHeight: image.height, imageWidth: image.width });
2228
return image;
2329
};
2430

@@ -57,11 +63,15 @@ class GrandchildRectangle extends Component {
5763
height={height}
5864
stroke={childType === 'COMP' ? this.getComponentColor(childComponentId) : '#000000'}
5965
fillPatternImage={imageSource ? this.setImage(imageSource) : null}
66+
fillPatternScaleX={0.1}
67+
fillPatternScaleY={0.1}
6068
// fill={color}
6169
// opacity={0.8}
62-
strokeWidth={4}
70+
strokeWidth={10}
6371
strokeScaleEnabled={false}
6472
draggable={false}
73+
// centerScaling={true}
74+
// enabledAnchors={['top-left', 'top-right', 'bottom-left', 'bottom-right']}
6575
/>
6676
{childType === 'COMP' &&
6777
components

src/components/HtmlAttr.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const styles = theme => ({
2626
input: {
2727
color: '#fff',
2828
opacity: '0.7',
29-
marginBottom: '15px',
29+
marginBottom: '17px',
3030
},
3131
});
3232

@@ -46,7 +46,6 @@ class HtmlAttr extends Component {
4646
}, {});
4747

4848
handleSave = attr => {
49-
console.log(attr, this.state[attr]);
5049
this.props.updateHtmlAttr({ attr, value: this.state[attr] });
5150
this.setState({
5251
[attr]: '',

src/components/KonvaStage.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class KonvaStage extends Component<PropsInt, StateInt> {
3737
constructor(props) {
3838
super(props);
3939
this.state = {
40-
stageWidth: 1500,
40+
stageWidth: 1800,
4141
stageHeight: 1500,
4242
blockSnapSize: 10,
4343
grid: [],
@@ -74,13 +74,13 @@ class KonvaStage extends Component<PropsInt, StateInt> {
7474
// here we should add listener for "container" resize
7575
// take a look here https://developers.google.com/web/updates/2016/10/resizeobserver
7676
// for simplicity I will just listen window resize
77-
// window.addEventListener('resize', this.checkSize);
77+
window.addEventListener('resize', this.checkSize);
7878
this.container.addEventListener('keydown', this.handleKeyDown);
7979
this.createGrid();
8080
}
8181

8282
componentWillUnmount() {
83-
// window.removeEventListener('resize', this.checkSize);
83+
window.removeEventListener('resize', this.checkSize);
8484
this.container.removeEventListener('keydown', this.handleKeyDown);
8585
}
8686

0 commit comments

Comments
 (0)