Skip to content

Commit ea74fd1

Browse files
committed
merging with styling changes from christian
2 parents ce1b380 + 0d91c7a commit ea74fd1

File tree

11 files changed

+410
-341
lines changed

11 files changed

+410
-341
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: 78 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
const {
2-
app,
3-
BrowserWindow,
4-
Menu,
5-
shell,
6-
dialog,
7-
ipcMain
8-
} = require("electron");
2+
app, BrowserWindow, Menu, shell, dialog, ipcMain,
3+
} = require('electron');
94

105
// Uncomment below for hot reloading during development
11-
require("electron-reload")(__dirname);
6+
require('electron-reload')(__dirname);
127

138
// const isDev = true;
14-
const isDev =
15-
process.env.NODE_ENV === "development" || process.env.NODE_ENV === "test";
9+
const isDev = process.env.NODE_ENV === 'development' || process.env.NODE_ENV === 'test';
1610

1711
// Keep a global reference of the window object, if you don't, the window will
1812
// be closed automatically when the JavaScript object is garbage collected.
@@ -22,81 +16,76 @@ let mainWindow;
2216
function openFile() {
2317
// Opens file dialog looking for markdown
2418
const files = dialog.showOpenDialog(mainWindow, {
25-
properties: ["openFile"],
19+
properties: ['openFile'],
2620
filters: [
2721
{
28-
name: "Images",
29-
extensions: ["jpeg", "jpg", "png", "gif", "pdf"]
30-
}
31-
]
22+
name: 'Images',
23+
extensions: ['jpeg', 'jpg', 'png', 'gif', 'pdf'],
24+
},
25+
],
3226
});
3327

3428
// if no files
3529
if (!files) return;
3630
const file = files[0];
3731

3832
// Send fileContent to renderer
39-
mainWindow.webContents.send("new-file", file);
40-
}
41-
42-
// export files
43-
function exportComponents() {
44-
console.log("hi from exportComponents");
33+
mainWindow.webContents.send('new-file', file);
4534
}
4635

4736
// Choose directory
48-
ipcMain.on("choose_app_dir", event => {
37+
ipcMain.on('choose_app_dir', (event) => {
4938
const directory = dialog.showOpenDialog(mainWindow, {
50-
properties: ["openDirectory"],
51-
buttonLabel: "Export"
39+
properties: ['openDirectory'],
40+
buttonLabel: 'Export',
5241
});
5342

5443
if (!directory) return;
55-
event.sender.send("app_dir_selected", directory[0]);
44+
event.sender.send('app_dir_selected', directory[0]);
5645
});
5746

58-
ipcMain.on("view_app_dir", (event, appDir) => {
47+
ipcMain.on('view_app_dir', (event, appDir) => {
5948
shell.openItem(appDir);
6049
});
6150

6251
// Update file
63-
ipcMain.on("update-file", () => {
52+
ipcMain.on('update-file', () => {
6453
openFile();
6554
});
6655

6756
const createWindow = () => {
6857
// Create the browser window.
6958
// eslint-disable-next-line
70-
const { width, height } = require("electron").screen.getPrimaryDisplay().size;
59+
const { width, height } = require('electron').screen.getPrimaryDisplay().size;
7160
mainWindow = new BrowserWindow({
7261
width,
7362
height,
7463
webPreferences: {
7564
zoomFactor: 0.9,
76-
"node-Integration": false
65+
'node-Integration': false,
7766
},
78-
show: false
67+
show: false,
7968
});
8069

8170
// and load the index.html of the app.
8271
mainWindow.loadURL(`file://${__dirname}/build/index.html`);
8372
// load page once window is loaded
84-
mainWindow.once("ready-to-show", () => {
73+
mainWindow.once('ready-to-show', () => {
8574
mainWindow.show();
8675
});
8776

8877
const template = [
8978
{
90-
label: "File",
79+
label: 'File',
9180
submenu: [
9281
{
93-
label: "Open File",
94-
accelerator: process.platform === "darwin" ? "Cmd+O" : "Ctrl+Shift+O",
82+
label: 'Open File',
83+
accelerator: process.platform === 'darwin' ? 'Cmd+O' : 'Ctrl+Shift+O',
9584
click() {
9685
openFile();
97-
}
98-
}
99-
]
86+
},
87+
},
88+
],
10089
},
10190
// {
10291
// label: 'Edit',
@@ -113,90 +102,89 @@ const createWindow = () => {
113102
// ],
114103
// },
115104
{
116-
label: "View",
105+
label: 'View',
117106
submenu: [
118-
{ role: "reload" },
119-
{ role: "forcereload" },
120-
{ type: "separator" },
121-
{ role: "resetzoom" },
122-
{ role: "zoomin" },
123-
{ role: "zoomout" },
124-
{ type: "separator" },
125-
{ role: "togglefullscreen" }
126-
]
107+
{ role: 'reload' },
108+
{ role: 'forcereload' },
109+
{ type: 'separator' },
110+
{ role: 'resetzoom' },
111+
{ role: 'zoomin' },
112+
{ role: 'zoomout' },
113+
{ type: 'separator' },
114+
{ role: 'togglefullscreen' },
115+
],
127116
},
128117
{
129-
role: "window",
130-
submenu: [{ role: "minimize" }, { role: "close" }]
118+
role: 'window',
119+
submenu: [{ role: 'minimize' }, { role: 'close' }],
131120
},
132121
{
133-
role: "help",
122+
role: 'help',
134123
submenu: [
135124
{
136-
label: "Learn More",
125+
label: 'Learn More',
137126
click() {
138-
shell.openExternal("https://electronjs.org");
139-
}
140-
}
141-
]
127+
shell.openExternal('https://electronjs.org');
128+
},
129+
},
130+
],
142131
},
143132
{
144-
label: "Developer",
133+
label: 'Developer',
145134
submenu: [
146135
{
147-
label: "Toggle Developer Tools",
148-
accelerator:
149-
process.platform === "darwin" ? "Alt+Command+I" : "Ctrl+Shift+I",
136+
label: 'Toggle Developer Tools',
137+
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
150138
click() {
151139
mainWindow.webContents.toggleDevTools();
152-
}
153-
}
154-
]
155-
}
140+
},
141+
},
142+
],
143+
},
156144
];
157145

158-
if (process.platform === "darwin") {
146+
if (process.platform === 'darwin') {
159147
template.unshift({
160148
label: app.getName(),
161149
submenu: [
162-
{ role: "about" },
163-
{ type: "separator" },
164-
{ role: "services", submenu: [] },
165-
{ type: "separator" },
166-
{ role: "hide" },
167-
{ role: "hideothers" },
168-
{ role: "unhide" },
169-
{ type: "separator" },
170-
{ role: "quit" }
171-
]
150+
{ role: 'about' },
151+
{ type: 'separator' },
152+
{ role: 'services', submenu: [] },
153+
{ type: 'separator' },
154+
{ role: 'hide' },
155+
{ role: 'hideothers' },
156+
{ role: 'unhide' },
157+
{ type: 'separator' },
158+
{ role: 'quit' },
159+
],
172160
});
173161

174162
// Edit menu
175163
template[2].submenu.push(
176164
{
177-
type: "separator"
165+
type: 'separator',
178166
},
179167
{
180-
label: "Speech",
181-
submenu: [{ role: "startspeaking" }, { role: "stopspeaking" }]
182-
}
168+
label: 'Speech',
169+
submenu: [{ role: 'startspeaking' }, { role: 'stopspeaking' }],
170+
},
183171
);
184172

185173
// Window menu
186174
template[4].submenu = [
187-
{ role: "close" },
188-
{ role: "minimize" },
189-
{ role: "zoom" },
190-
{ type: "separator" },
191-
{ role: "front" }
175+
{ role: 'close' },
176+
{ role: 'minimize' },
177+
{ role: 'zoom' },
178+
{ type: 'separator' },
179+
{ role: 'front' },
192180
];
193181
}
194182

195183
const menu = Menu.buildFromTemplate(template);
196184
Menu.setApplicationMenu(menu);
197185

198186
// Emitted when the window is closed.
199-
mainWindow.on("closed", () => {
187+
mainWindow.on('closed', () => {
200188
// Dereference the window object, usually you would store windows
201189
// in an array if your app supports multi windows, this is the time
202190
// when you should delete the corresponding element.
@@ -207,13 +195,13 @@ const createWindow = () => {
207195
// This method will be called when Electron has finished
208196
// initialization and is ready to create browser windows.
209197
// Some APIs can only be used after this event occurs.
210-
app.on("ready", () => {
198+
app.on('ready', () => {
211199
if (isDev) {
212200
const {
213201
default: installExtension,
214202
REACT_DEVELOPER_TOOLS,
215-
REDUX_DEVTOOLS
216-
} = require("electron-devtools-installer");
203+
REDUX_DEVTOOLS,
204+
} = require('electron-devtools-installer');
217205

218206
installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS])
219207
.then(() => {
@@ -226,15 +214,15 @@ app.on("ready", () => {
226214
});
227215

228216
// Quit when all windows are closed.
229-
app.on("window-all-closed", () => {
217+
app.on('window-all-closed', () => {
230218
// On OS X it is common for applications and their menu bar
231219
// to stay active until the user quits explicitly with Cmd + Q
232-
if (process.platform !== "darwin") {
220+
if (process.platform !== 'darwin') {
233221
app.quit();
234222
}
235223
});
236224

237-
app.on("activate", () => {
225+
app.on('activate', () => {
238226
// On OS X it's common to re-create a window in the app when the
239227
// dock icon is clicked and there are no other windows open.
240228
if (mainWindow === null) {

0 commit comments

Comments
 (0)