Skip to content

Commit fddf6fb

Browse files
authored
Merge pull request #18 from oslabs-beta/combineReduxStores
combined redux store, fixed visual bugs, & updated readme
2 parents 3621590 + ac4a40c commit fddf6fb

File tree

8 files changed

+126
-49
lines changed

8 files changed

+126
-49
lines changed

CHANGE_LOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<p align="center">
2+
<img width="100" src="https://i.imgur.com/Yn70tqI.png">
3+
<h1 align="center">ReacType Change Log</h1>
4+
</p>
5+
6+
**Version 11.0.0 Changes:**
7+
8+
- Added Next.js functionality
9+
- Next.js projects will generate the right code needed for exporting a Next.js application
10+
- Link & Image elements have been added
11+
- Link components are able to couple with a page to enable SSR
12+
- Current canvas can be saved as a page to be coupled with a Next.js Link element
13+
- Image element can accept special attribute that allow for it to optimize performance
14+
- Added Redux and began migrating some state over for ease of development (debugging & readability)
15+
- Fixed bug causing electron to crash when closing the window rather than going to file > exit
16+
- Fixed bug causing app to crash when project was changed to either Next.js or Gatsby.js
17+
- Fixed GitHub OAuth
18+
- added Passport.js & Passport-Github libraries for strategies which takes care of all the credential exchanges and session information
19+
- linked electron front end to talk to backend to exchange credentials
20+
- Fixed code preview not displaying properly
21+
- Fixed dark mode not syncing properly across pages
22+
23+
**Version 11.0.0 Stretch Features:**
24+
25+
- Move more state away from the react hook & context API and into the Redux store
26+
- This will be very time consuming but will make implementing new features much easier
27+
- Highly suggest you read Redux documentation on best practices before diving into this
28+
- This will improve performance by reducing the amount of unneccessary re-render. The context API causes certain pieces of state to be needlessly coupled
29+
- Debugging is much easier by the use of Redux dev tools which allow time travel debugging
30+
- Code will be easier to read and thus data flow will be easier to visualize
31+
- Tried to implement peer to peer communication via webRTC with redux swarmlog but was not successful. Look into websockets.
32+
- Save project (state) onto local storage for guests

README.md

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<p align="center">
2-
<img width="50" src="https://i.imgur.com/Yn70tqI.png">
2+
<img width="100" src="https://i.imgur.com/Yn70tqI.png">
33
<h1 align="center">ReacType </h1>
44
</p>
55

66
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/team-reactype/ReacType/pulls)
77
![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)
8-
![Version 10.0.0]
8+
![Version 11.0.0]
99

1010
**ReacType** is a rapid prototyping tool for developers employing **React** component architecture alongside the comprehensive type-checking of **TypeScript**.
1111
In other words, **you can draw prototypes and export React / TypeScript code!**
@@ -16,7 +16,7 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
1616

1717
- **Mac users**: After opening the dmg and dragging ReacType into your Applications folder, ctrl+click the icon and select 'Open' from the context menu to run the app. This extra step is necessary since we don't have an Apple developer license yet.
1818

19-
- **Windows users**: Install the application by running ReacType Setup 10.0.0.exe.
19+
- **Windows users**: Install the application by running ReacType Setup 11.0.0.exe.
2020

2121
- **Linux users**: Run the application as a super user in order to read and write files.
2222

@@ -49,7 +49,7 @@ How to use
4949
- **Like**: Like other people's templates by clicking on the thumbs up icon.
5050
- **Comment**: Comment on other templates by typing in the input field and clicking the comment icon.
5151
- **Download**: Save any public template by clicking the download icon to save a copy as your own.
52-
- **Publish**: Publish any template to the Public Dashboard for other users to download, like, or comment on. Click again to unpublish projects.
52+
- **Publish**: Publish any template to the Public Dashboard for other users to download, like, or comment on. Click again to unpublish projects.
5353
- **Sort By**: Click the 'Sort By' button to choose different metrics to sort the Public Dashboard by.
5454
- **Form Nesting**: Nesting within form tags is now fully functional
5555
- **Added Undo and Redo functionality**
@@ -60,31 +60,36 @@ How to use
6060
- Modernized and cleaner UI, including enhanced dark mode
6161
- Tutorial has been updated to reflect other modifications
6262

63+
**New with version 11.0.0:**
6364

64-
**New with version 10.0.0:**
65-
- **Live Code Preview**: See your code preview update in real time as you build. React hooks are enabled for application lifecycle management. Dynamically render functional components using a live code editor. User's can hook event listeners to components and see them render in real time.
65+
- **Enhanced Next.js Functionality**: Create a Next.js application in Reactype! Take advantage of server side rendering and static site generation by using the new improved Next.js link and image components. Simply drag and drop a Link element onto the canvas which can be coupled with a page to support SSR or optimize performance by using Next.js' Image component to enable on-demand image resizing. After you're done, export your project as a Next.js application written in Typescript!
66+
- **More Dark Mode**: Cleaned up the dark mode UI and added it to all areas of the application including the sign in and sign up page.
67+
- **Various Performance Enhancements**: Improved performance by reducing unnecessary re-rendering due to needlessly coupled state hooks
68+
- **And more:** See CHANGE_LOG.md for more details on what was changed from the previous version as well as plans for upcoming features!
6669

6770
### Keyboard Shortcuts
6871

6972
**Mac**:
70-
- Export Project: Command + e
71-
- Undo: Command + z
72-
- Redo: Command + Shift + z
73-
- Save Project As: Command + s
74-
- Save Project: Command + shift + s
75-
- Delete HTML Tag on Canvas: Backspace
76-
- Delete Project: Command + Backspace
77-
- Open Project: Command + o
73+
74+
- Export Project: Command + e
75+
- Undo: Command + z
76+
- Redo: Command + Shift + z
77+
- Save Project As: Command + s
78+
- Save Project: Command + shift + s
79+
- Delete HTML Tag on Canvas: Backspace
80+
- Delete Project: Command + Backspace
81+
- Open Project: Command + o
7882

7983
**Windows**:
80-
- Export Project: Control + e
81-
- Undo: Control + z
82-
- Redo: Control + Shift + z
83-
- Save Project As: Control + s
84-
- Save Project: Control + shift + s
85-
- Delete HTML Tag on Canvas: Backspace
86-
- Delete Project: Control + Backspace
87-
- Open Project: Control + o
84+
85+
- Export Project: Control + e
86+
- Undo: Control + z
87+
- Redo: Control + Shift + z
88+
- Save Project As: Control + s
89+
- Save Project: Control + shift + s
90+
- Delete HTML Tag on Canvas: Backspace
91+
- Delete Project: Control + Backspace
92+
- Open Project: Control + o
8893

8994
#### Contributors
9095

@@ -106,6 +111,8 @@ How to use
106111

107112
[Bryan Chau](https://www.linkedin.com/in/chaubryan1/) [@bchauu](https://github.com/bchauu)
108113

114+
[Calvin Cao](http://www.linkedin.com/in/calvincao9/) [@calvincao](https://github.com/calvincao)
115+
109116
[Charles Finocchiaro](https://www.linkedin.com/in/charles-finocchiaro-62440040/) [@null267](https://github.com/null267)
110117

111118
[Chelsey Fewer](https://www.linkedin.com/in/chelsey-fewer/) [@chelseyeslehc](https://github.com/chelseyeslehc)
@@ -128,6 +135,8 @@ How to use
128135

129136
[Eliot Nguyen](https://linkedin.com/in/ibeeliot) [@ibeeliot](https://github.com/ibeeliot)
130137

138+
[Evan Crews](http://www.linkedin.com/in/<ADD_LINKEDIN_USERNAME>/) [@Evan-Crews](https://github.com/Evan-Crews)
139+
131140
[Fredo Chen](https://www.linkedin.com/in/fredochen/) [@fredosauce](https://github.com/fredosauce)
132141

133142
[Jonathan Calvo Ramirez](https://www.linkedin.com/in/jonathan-calvo/) [@jonocr](https://github.com/jonocr)
@@ -142,10 +151,14 @@ How to use
142151

143152
[Khuong Nguyen](https://www.linkedin.com/in/khuong-nguyen/) [@khuongdn16](https://github.com/khuongdn16)
144153

154+
[Katrina Henderson](https://www.linkedin.com/in/katrinahenderson/) [@kchender](https://github.com/kchender)
155+
145156
[Linh Tran](https://www.linkedin.com/in/linhtran51/) [@Linhatran](https://github.com/Linhatran)
146157

147158
[Luke Madden](https://www.linkedin.com/in/lukemadden/) [@lukemadden](https://github.com/lukemadden)
148159

160+
[Michael Ng](https://www.linkedin.com/in/<ADD_USERNAME>/) [@MikoGome](https://github.com/MikoGome)
161+
149162
[Miles Wright](https://www.linkedin.com/in/miles-m-wright) [@Miles818](https://github.com/Miles818)
150163

151164
[Mitchel Severe](https://www.linkedin.com/in/misevere/) [@mitchelsevere](https://github.com/mitchelsevere)
@@ -184,6 +197,8 @@ How to use
184197

185198
[William Yoon](https://www.linkedin.com/in/williamdyoon/) [@williamdyoon](https://github.com/williamdyoon)
186199

200+
[Yuanji Huang](https://www.linkedin.com/in/yuanjihuang/) [@kr1spybacon](https://github.com/kr1spybacon)
201+
187202
## To Run Your Own Version
188203

189204
- **Fork** and **Clone** Repository.

app/src/components/bottom/BottomTabs.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ const BottomTabs = (props): JSX.Element => {
8989
value={state.projectType}
9090
onChange={handleProjectChange}
9191
>
92-
<MenuItem value={'Classic React'}>Classic React</MenuItem>
93-
<MenuItem value={'Gatsby.js'}>Gatsby.js</MenuItem>
94-
<MenuItem value={'Next.js'}>Next.js</MenuItem>
92+
<MenuItem style={{ color: 'black' }} value={'Classic React'}>Classic React</MenuItem>
93+
<MenuItem style={{ color: 'black' }} value={'Gatsby.js'}>Gatsby.js</MenuItem>
94+
<MenuItem style={{ color: 'black' }} value={'Next.js'}>Next.js</MenuItem>
9595
</Select>
9696
</FormControl>
9797
</div>

app/src/components/bottom/CodePreview.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ import useResizeObserver from '../../tree/useResizeObserver';
1414
import { unpkgPathPlugin } from '../../plugins/unpkg-path-plugin';
1515
import { fetchPlugin } from '../../plugins/fetch-plugin';
1616
import * as esbuild from 'esbuild-wasm';
17-
import { store } from './../../index';
17+
import store from '../../redux/store';
18+
// import { store } from './../../index';
1819
const CodePreview: React.FC<{
1920
theme: string | null;
2021
setTheme: any | null;
@@ -57,7 +58,7 @@ const CodePreview: React.FC<{
5758
useEffect(() => {
5859

5960
setInput(currentComponent.code);
60-
store.dispatch({type: "INPUT", payload: currentComponent.code});
61+
store.dispatch({type: "CODE_PREVIEW_INPUT", payload: currentComponent.code});
6162
}, [state.components])
6263

6364
/**
@@ -66,7 +67,7 @@ const CodePreview: React.FC<{
6667
*/
6768
const handleChange = async (data) => {
6869
setInput(data);
69-
store.dispatch({type: "INPUT", payload: data});
70+
store.dispatch({type: "CODE_PREVIEW_INPUT", payload: data});
7071
if(!ref.current) {
7172
return;
7273
}
@@ -85,7 +86,7 @@ const CodePreview: React.FC<{
8586
global: 'window'
8687
}
8788
})
88-
store.dispatch({type: "SAVE", payload: result.outputFiles[0].text});
89+
store.dispatch({type: "CODE_PREVIEW_SAVE", payload: result.outputFiles[0].text});
8990
}
9091

9192
return (
@@ -106,7 +107,7 @@ const CodePreview: React.FC<{
106107
value={input}
107108
name="Code_div"
108109
readOnly={false}
109-
fontSize={16}
110+
fontSize={18}
110111
tabSize={2}
111112
/>
112113

app/src/index.js

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import {
77
} from 'react-router-dom';
88
import 'babel-polyfill';
99
import React from 'react';
10-
import reduxStore from './redux/store';
10+
import store from './redux/store';
1111
import { Provider } from 'react-redux';
12-
import { createStore } from 'redux';
12+
// import { createStore } from 'redux';
1313
import ReactDOM from 'react-dom';
1414
import Cookies from 'js-cookie';
1515
import App from './components/App.tsx';
@@ -24,22 +24,22 @@ const client = new ApolloClient({
2424
uri: 'https://reactype-caret.herokuapp.com/graphql',
2525
cache: new InMemoryCache()
2626
});
27-
const initialState = { code: ``, input: `` };
28-
const rootReducer = (state = initialState, action) => {
29-
switch (action.type) {
30-
case 'SAVE':
31-
return { ...state, code: action.payload };
32-
case 'INPUT':
33-
return { ...state, input: action.payload };
34-
default:
35-
return state;
36-
}
37-
};
27+
// const initialState = { code: ``, input: `` };
28+
// const rootReducer = (state = initialState, action) => {
29+
// switch (action.type) {
30+
// case 'SAVE':
31+
// return { ...state, code: action.payload };
32+
// case 'INPUT':
33+
// return { ...state, input: action.payload };
34+
// default:
35+
// return state;
36+
// }
37+
// };
3838

39-
export const store = createStore(
40-
rootReducer,
41-
window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
42-
);
39+
// export const store = createStore(
40+
// rootReducer,
41+
// window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__()
42+
// );
4343

4444
const PrivateRoute = ({ component: Component, ...rest }) => (
4545
<Route
@@ -56,7 +56,7 @@ const PrivateRoute = ({ component: Component, ...rest }) => (
5656

5757
ReactDOM.render(
5858
<ApolloProvider client={client}>
59-
<Provider store={reduxStore}>
59+
<Provider store={store}>
6060
<Router>
6161
<Switch>
6262
<Route exact path="/login" component={SignIn} />
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
// save all action as constants here
22
export const DARK_MODE_TOGGLE = 'DARK_MODE_TOGGLE';
3+
export const CODE_PREVIEW_SAVE = 'CODE_PREVIEW_SAVE';
4+
export const CODE_PREVIEW_INPUT = 'CODE_PREVIEW_INPUT';

app/src/redux/reducers/rootReducer.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { combineReducers } from 'redux';
22

33
import darkModeReducer from './slice/darkModeSlice';
4+
import codePreviewReducer from './slice/codePreviewSlice';
45

56
const rootReducer = combineReducers({
6-
darkModeSlice: darkModeReducer
7+
darkModeSlice: darkModeReducer,
8+
codePreviewSlice: codePreviewReducer
79
// add the rest of your slice imports here
810
});
911

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import * as types from '../../constants/actionTypes';
2+
3+
const initialState = {
4+
code: ``,
5+
input: ``
6+
};
7+
8+
const codePreviewReducer = (state = initialState, action) => {
9+
switch (action.type) {
10+
case types.CODE_PREVIEW_SAVE:
11+
return {
12+
...state,
13+
code: action.payload
14+
};
15+
case types.CODE_PREVIEW_INPUT:
16+
return {
17+
...state,
18+
input: action.payload
19+
};
20+
default:
21+
return state;
22+
}
23+
};
24+
25+
export default codePreviewReducer;

0 commit comments

Comments
 (0)