Skip to content

Beta to OSLabs Launch Merge #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 57 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
f5463b5
debugged json
chrisjtang Nov 2, 2021
9b87d92
Added switch component
WilliamCheng12345 Nov 4, 2021
9383573
Added 17th componenent switch
WilliamCheng12345 Nov 4, 2021
908d5bd
Added link to component and its code preview
WilliamCheng12345 Nov 4, 2021
989806e
Made linkTo nested and fixed nested linkTo code preview, added react-…
WilliamCheng12345 Nov 5, 2021
e804601
added Route type and button to add Routes
crlim Nov 5, 2021
9410714
made Route nestable
crlim Nov 5, 2021
a760bb0
generate code for switch. import reactrouter. spacing issues still …
chrisjtang Nov 6, 2021
039dbcf
removed extra comments to clean up code
chrisjtang Nov 6, 2021
7329a36
Merge pull request #1 from oslabs-beta/feat/Switch
rfvisuals Nov 6, 2021
57bf004
Make style in code preview appear, but commented out for now
WilliamCheng12345 Nov 6, 2021
13874b4
Merge branch 'dev-46' into ron-william-changes
rfvisuals Nov 6, 2021
a051a72
Merge pull request #2 from oslabs-beta/ron-william-changes
crlim Nov 6, 2021
33b428a
fixed linkto pointing in the wrong direction. also removed extra ins…
chrisjtang Nov 6, 2021
956846e
Added hook bracket, style is changed from [Object] to actual style, f…
WilliamCheng12345 Nov 7, 2021
fb032d3
gave DemoRender ability to render React Router components
crlim Nov 8, 2021
cc29ba4
made paths visible on canvas for react router links and routes
crlim Nov 9, 2021
8fcbfca
Fixed style so it doesnt appear as props.style, editing state now upd…
WilliamCheng12345 Nov 9, 2021
996e25f
Merge pull request #3 from oslabs-beta/c2
WilliamCheng12345 Nov 9, 2021
0839e5f
Merge branch 'dev-46' into ron-william-changes
crlim Nov 9, 2021
745370f
Merge pull request #4 from oslabs-beta/ron-william-changes
crlim Nov 9, 2021
31f5600
customization panel can now render useStateModal with a button click.…
chrisjtang Nov 11, 2021
9d5c5ae
Fixed delete and add state, added context to code preview
WilliamCheng12345 Nov 11, 2021
3979fc6
gave our usestatemodal the functionality to dynamically pass state in…
chrisjtang Nov 11, 2021
f3b5756
Removed console.logs and commented lines
WilliamCheng12345 Nov 11, 2021
8bc0bbf
Merge pull request #5 from oslabs-beta/c2
rfvisuals Nov 11, 2021
949030c
Merge pull request #6 from oslabs-beta/ron-william-changes
crlim Nov 11, 2021
96d3e9c
when state is selected from useStateModal, the modal auto-closes and …
chrisjtang Nov 11, 2021
5ea14ce
updated styling
chrisjtang Nov 12, 2021
ac24d84
Merge pull request #7 from oslabs-beta/rwc2
crlim Nov 12, 2021
62738eb
fixed StatePropsPanel to save values as correct type when creating ne…
crlim Nov 13, 2021
75df4fd
Removed Separator from Tree
WilliamCheng12345 Nov 14, 2021
2390734
Currently working on delete state, which is bugged
WilliamCheng12345 Nov 14, 2021
a3e3a0a
Fixed delete state button, but useContext needs to be fixed now
WilliamCheng12345 Nov 15, 2021
81f1a5f
statepanel can now receive JSON objects. also added forEach element …
chrisjtang Nov 15, 2021
ae53bac
updated componentBuilder in DemoRender to handle arrays in innerText
crlim Nov 15, 2021
59c7361
application can now handle arrays for both text and link inputs from …
chrisjtang Nov 16, 2021
23b2cd1
Added imports
WilliamCheng12345 Nov 16, 2021
e11019c
Fixed multiple states from context being replaced
WilliamCheng12345 Nov 17, 2021
ae92eb8
edits to usestatemodal for handling objects in the modal
chrisjtang Nov 18, 2021
629e217
Currently working on bug of deleting the first state
WilliamCheng12345 Nov 19, 2021
7e00a7c
added stateUsed object to childelement interface. this keeps track o…
chrisjtang Nov 19, 2021
790750f
Fixed issue when first state of current component deleted and indenta…
WilliamCheng12345 Nov 19, 2021
e13c20e
updated modal and table state props to use and display nested arrays …
crlim Nov 19, 2021
1acccbb
fixed useStateModal's component buttons to refresh the modal view to …
chrisjtang Nov 19, 2021
5b9da19
fixed statePropsId to pass correctly for nested objects and arrays
crlim Nov 20, 2021
a6e835f
cleaned up code, removing console.logs and comments
crlim Nov 20, 2021
f04de67
Merge pull request #8 from oslabs-beta/c2
WilliamCheng12345 Nov 20, 2021
5ede225
Merge branch 'dev-46' into ron-william-changes
WilliamCheng12345 Nov 20, 2021
d66a08d
Merge pull request #9 from oslabs-beta/ron-william-changes
crlim Nov 20, 2021
61c34b6
fixed some bugs after the merge
chrisjtang Nov 20, 2021
e511746
Fixed state bug where setState is aysnc and not updating the state ri…
WilliamCheng12345 Nov 20, 2021
0577931
Fixed electron and code styling bugs
WilliamCheng12345 Nov 21, 2021
bad6eb2
Fixed delete resuable component bug, separator in tree char, removed …
WilliamCheng12345 Nov 22, 2021
ae9f463
Fixed same stateUsedObj reference and delete state from child element…
WilliamCheng12345 Nov 23, 2021
092d6d3
Merge pull request #10 from oslabs-beta/final-bugs-fix
chrisjtang Nov 24, 2021
f67c7e0
Merge pull request #11 from oslabs-beta/dev-46
rfvisuals Nov 24, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo

### How to use

- **Sign-in page**: Sign up for an account, sign in via Github, or just continue as a guest. Registered users enjoy additional project-saving functionality.
- **Sign-in page**: Sign up for an account or just continue as a guest. Registered users enjoy additional project-saving functionality.
- **Tutorial**: Click ‘Tutorial’ from the Help tab’s dropdown menu (at the top left of the application) to view a tutorial.
- **Start a project (only after registration)**: Registered users can create a new project and select whether they want their project to be a Next.js, Gatsby.js, or classic React project. Also, registered users can save projects to return to them at a later time.
- **Add Components**: Create components on the right panel. Components can be associated with a route, or they can be used within other components.
Expand All @@ -34,6 +34,7 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
- **Create Instances on the Canvas**: Each component has its own canvas. Add an element to a component by dragging it onto the canvas. Div components are arbitrarily nestable and useful for complex layouts. Next.js and Gatsby.js projects have Link components to enable client-side navigation to other routes.
- **Component Tree**: Click on the Component Tree tab next to the Code Preview tab to view the component tree hierarchy.
- **Update Styling**: Select an element on the canvas to update its basic style attributes on the right panel. As you create new instances and add styling, watch as your code dynamically generates in the code preview in the bottom panel.
- **Using State in Elements**: As of 9.0.0, you can now select an HTML element on the canvas and then navigate to the customization panel to click a button to pass a variable from state into your element's text or link field.
- **User Preference Features**: With the click of a button, toggle between light mode and dark mode, depending on your preference.
- **Export project**: Click the “Export Project’ button to export the project’s application files into a TypeScript file. The exported project is fully functional with Webpack, Express server, routing, etc., and will match what is mocked on the canvas.
- **Export project with Tests**: Click the "includes tests" checkbox while exporting to include pre-configured Webpack, Jest, and Typescript files along with tests for your project.
Expand All @@ -43,11 +44,17 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
- Modernized and cleaner UI, including enhanced dark mode
- Tutorial has been updated to reflect other modifications

**New with version 8.0.0:**
**New with version 9.0.0:**

![CSSEditor](https://raw.githubusercontent.com/open-source-labs/ReacType/master/resources/export_tests_images/export-new.gif)

### Features
### 9.0.0 New Features
- **React Router**: Drag-and-drop LinkTo and Router elements (located below the HTML elements list) to implement fully-functional React Router components into your application to dynamically and quickly render components in the live demo render and in your exported application.
- **Global State Management**: For the first time in ReacType history, users can utilize
- **Composite Data Structures in State**: State creation in ReacType can now handle composite data types, which includes arrays, objects, and any amount of nesting of composite data types within other composite data types (i.e. arrays of objects and objects with objects as values).
- **Additional Improvements with Local State Management**:
- **Annotations**:


- **OAuth via Github**: Sign up with your github accounts.
- **Live Render Demo**: Live render demo in React using Electron's sandbox environment. Updates in realtime to reflect canvas structure and customization options.
Expand Down Expand Up @@ -81,7 +88,7 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
- Delete Project: Command + Backspace
- Open Project: Command + o

**Windows**:
**Windows**:
- Export Project: Control + e
- Undo: Control + z
- Redo: Control + Shift + z
Expand All @@ -90,7 +97,7 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
- Delete HTML Tag on Canvas: Backspace
- Delete Project: Control + Backspace
- Open Project: Control + o

#### Contributors

[Alex Yu](https://www.linkedin.com/in/alexjihunyu/) [@buddhajjigae](https://github.com/buddhajjigae)
Expand All @@ -111,8 +118,12 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo

[Chelsey Fewer](https://www.linkedin.com/in/chelsey-fewer/) [@chelseyeslehc](https://github.com/chelseyeslehc)

[Chris Tang] (https://www.linkedin.com/in/chrisjtang/) [@chrisjtang](https://github.com/chrisjtang)

[Christian Padilla](https://linkedin.com/in/ChristianEdwardPadilla) [@ChristianEdwardPadilla](https://github.com/ChristianEdwardPadilla)

[Crystal Lim] (https://linkedin.com/in/crystallim) [@crlim](https://github.com/crlim)

[Danial Reilley](https://linkedin.com/in/daniel-reilley)
[@dreille](https://github.com/dreille)

Expand Down Expand Up @@ -156,6 +167,8 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo
[Philip Hua](https://www.linkedin.com/in/philip-minh-hua)
[@pmhua](https://github.com/pmhua)

[Ron Fu] (https://www.linkedin.com/in/ronfu)[@rfvisuals] (https://github.com/rfvisuals)

[Sean Sadykoff](https://www.linkedin.com/in/sean-sadykoff/) [@sean1292](https://github.com/sean1292)

[Shana Hoehn](https://www.linkedin.com/in/shana-hoehn-70297b169/) [@slhoehn](https://github.com/slhoehn)
Expand All @@ -172,6 +185,8 @@ Download for [MacOS](https://github.com/team-reactype/ReacType/releases), [Windo

[Tyler Sullberg](https://www.linkedin.com/in/tyler-sullberg) [@tsully](https://github.com/tsully)

[William Cheng] (https://www.linkedin.com/in/william-cheng-0723/) [@williamcheng12345](https://github.com/WilliamCheng12345)

[William Rittwage](https://www.linkedin.com/in/william-rittwage)
[@wbrittwage](https://github.com/wbrittwage)

Expand Down
2 changes: 1 addition & 1 deletion app/electron/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ async function createWindow() {
webPreferences: {
zoomFactor: 0.7,
// enable devtools when in development mode
devTools: isDev,
devTools: true,
// crucial security feature - blocks rendering process from having access to node modules
nodeIntegration: false,
// web workers will not have access to node
Expand Down
87 changes: 87 additions & 0 deletions app/src/components/bottom/UseStateModal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React, {useRef, useState, useContext, useEffect } from 'react';
import Modal from '@material-ui/core/Modal';
import StateContext from '../../context/context';
import TableStateProps from '../right/TableStateProps';

function UseStateModal({ updateAttributeWithState, attributeToChange, childId }) {
const [state, dispatch] = useContext(StateContext);
const [open, setOpen] = useState(false);
const [displayObject, setDisplayObject] = useState(null)
const [stateKey, setStateKey] = useState('');
const [statePropsId, setStatePropsId] = useState(-1);
const [componentProviderId, setComponentProviderId] = useState(1);

// make tabs to choose which component to get state from
const componentTabs = [];
for (let i = 0; i < state.components.length; i ++) {
componentTabs.push(<button
onClick={() => {
setComponentProviderId(i+1);
setDisplayObject(null);
setStateKey('');
}}>
{state.components[i].name}
</button>)
}

// table to choose state from
const body = (
<div className="useState-position">
<div className="useState-header">
<span>Choose State Source</span>
<button
style={{ margin: '5px 5px' ,padding: '1px', float: 'right' }}
onClick={() => {
setStateKey('');
setStatePropsId(-1);
setDisplayObject(null)
setOpen(false)}}
>
X
</button>
</div>
<div className="useState-window">
<div className="useState-dropdown">
{componentTabs}
</div>
<div className="useState-stateDisplay">
<TableStateProps
providerId = {componentProviderId}
canDeleteState = {false}
displayObject = {displayObject}
selectHandler={(table) => {
// if object or array => show sub table
if (table.row.type === "object") {
if (statePropsId < 0) setStatePropsId(table.row.id);
setStateKey(stateKey + table.row.key + '.');
setDisplayObject(table.row.value);
} else if (table.row.type === "array") {
if (statePropsId < 0) setStatePropsId(table.row.id);
setStateKey(stateKey + table.row.key)
setDisplayObject(table.row.value);
} else {
// if not object or array => update state
setDisplayObject(null);
updateAttributeWithState(attributeToChange, componentProviderId, statePropsId > 0 ? statePropsId : table.row.id, table.row, stateKey + table.row.key);
setStateKey('')
setStatePropsId(-1);
setOpen(false);
}
}}
deleteHandler={() => func()}
isThemeLight={true}
/>
</div>
</div>
</div>
);

return (
<div>
<button className="useState-btn" onClick={() => setOpen(true)}>USE STATE</button>
<Modal open={open}>{body}</Modal>
</div>
);
}

export default UseStateModal;
47 changes: 34 additions & 13 deletions app/src/components/left/DragDropPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Central state contains all available HTML elements (stored in the HTMLTypes prop
initialState.tsx.

Hook state:
-tag:
-tag:
*/
// Extracted the drag and drop functionality from HTMLPanel to make a modular component that can hang wherever the future designers may choose.
const DragDropPanel = (props): JSX.Element => {
Expand All @@ -37,25 +37,46 @@ const DragDropPanel = (props): JSX.Element => {
payload: id
});
};

// filter out separator so that it will not appear on the html panel
const htmlTypesToRender = state.HTMLTypes.filter(type => type.name !== 'separator');
const htmlTypesToRender = state.HTMLTypes.filter(type => type.name !== 'separator' && type.name !== 'Route');
return (
<div className="HTMLItems">
<div id="HTMLItemsTopHalf">
<Grid
id="HTMLItemsGrid"
>
{htmlTypesToRender.map(option => (
<HTMLItem
name={option.name}
key={`html-${option.name}`}
id={option.id}
Icon={option.icon}
handleDelete={handleDelete}
isThemeLight={isThemeLight}
/>
))}
<h3>HTML ELEMENTS</h3>
{htmlTypesToRender.map(option => {
if(option.id !== 17 && option.id !== 18) {
return (
<HTMLItem
name={option.name}
key={`html-${option.name}`}
id={option.id}
Icon={option.icon}
handleDelete={handleDelete}
isThemeLight={isThemeLight}
/>
);
}

})}
<h3>REACT ROUTER</h3>
{htmlTypesToRender.map(option => {
if(option.id === 17 || option.id === 18) {
return (
<HTMLItem
name={option.name}
key={`html-${option.name}`}
id={option.id}
Icon={option.icon}
handleDelete={handleDelete}
isThemeLight={isThemeLight}
/>
);
}
})}
</Grid>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions app/src/components/left/HTMLItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const useStyles = makeStyles({
darkThemeFontColor: {
color: '#fff'
}

});

const HTMLItem : React.FC<{
Expand All @@ -45,9 +45,9 @@ const HTMLItem : React.FC<{
handleDelete: (id: number) => void;
isThemeLight: boolean;
}> = ({ name, id, Icon, handleDelete, isThemeLight }) => {

const classes = useStyles();

const [modal, setModal] = useState(null);
const [{ isDragging }, drag] = useDrag({
item: {
Expand Down Expand Up @@ -122,11 +122,11 @@ const HTMLItem : React.FC<{
// updated the id's to reflect the new element types input and label
return ( // HTML Elements
<Grid item xs={5} key={`html-g${name}`}>
{ id <= 16 &&
{ id <= 18 &&
<div ref={drag} className={isThemeLight ? `${classes.HTMLPanelItem} ${classes.lightThemeFontColor}` : `${classes.HTMLPanelItem} ${classes.darkThemeFontColor}`} id="HTMLItem">
<h3>{name}</h3>
</div>}
{id > 16 &&
{id > 18 &&
<span id="customHTMLElement">
<div ref={drag} className={isThemeLight ? `${classes.HTMLPanelItem} ${classes.lightThemeFontColor}` : `${classes.HTMLPanelItem} ${classes.darkThemeFontColor}`} id="HTMLItem">
<h3>{name}</h3>
Expand Down
31 changes: 31 additions & 0 deletions app/src/components/main/AddRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { AddRoutes } from '../../interfaces/Interfaces'
import React, {
useRef, useState, useContext, useEffect,
} from 'react';
import StateContext from '../../context/context';

function AddRoute({
id,
name
}: AddRoutes) {
const [state, dispatch] = useContext(StateContext);

const handleClick = (id) => {
dispatch({
type: 'ADD CHILD',
payload: {
type: 'HTML Element',
typeId: -1,
childId: id // this is the id of the parent to attach it to
}
});
}

return (
<div style={{ padding: '1px', float: 'right' }}>
<button id={'routeBtn' + id} onClick={() => handleClick(id)}>+</button>
</div>
);
}

export default AddRoute;
8 changes: 4 additions & 4 deletions app/src/components/main/Annotation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function Annotation({
};

/**
* Handles when text exists in the textarea of the modal.
* Handles when text exists in the textarea of the modal.
* If text exists/does not exist, corresponding button changes colors.
* Sets hook value to what is contained in the textarea
*/
Expand All @@ -53,7 +53,7 @@ function Annotation({
}

/**
* This handler will find the specific anno for the corresponding component on the canvas in the childrenArray -
* This handler will find the specific anno for the corresponding component on the canvas in the childrenArray -
* where the canvas components are placed
*/
const handleFindAnno = (array, id) => {
Expand All @@ -65,7 +65,7 @@ function Annotation({
} else if (currentElement.children.length > 0) {
// temp is to prevent a return of empty string since canvas element should always exist and allows the
// recursion to continue
const temp = handleFindAnno(currentElement.children, id)
const temp = handleFindAnno(currentElement.children, id)
if (temp != '') {
return temp;
}
Expand All @@ -84,7 +84,7 @@ function Annotation({
}
handleAnnoChange(event);
}, [])

const body = (
<div className='annotate-position'>
<span className='annotate-textarea-header'> Notes for: {name} ( {id} )</span>
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/main/Canvas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ function Canvas() {
const currentComponent: Component = state.components.find(
(elem: Component) => elem.id === state.canvasFocus.componentId
);

// changes focus of the canvas to a new component / child
const changeFocus = (componentId?: number, childId?: number | null) => {
dispatch({ type: 'CHANGE FOCUS', payload: { componentId, childId } });
};
// onClickHandler is responsible for changing the focused component and child component
function onClickHandler(event) {
event.stopPropagation();
// note: a null value for the child id means that we are focusing on the top-level component rather than any child
// note: a null value for the child id means that we are focusing on the top-level component rather than any child
changeFocus(state.canvasFocus.componentId, null);
};

// stores a snapshot of state into the past array for UNDO. snapShotFunc is also invoked for nestable elements in DirectChildHTMLNestable.tsx
const snapShotFunc = () => {
// make a deep clone of state
Expand Down
Loading