Skip to content

Commit 56c6986

Browse files
atvaneksophia-bui
andcommitted
Merge with dev
Co-authored-by: Sophia Bui <[email protected]>
2 parents 0a6f896 + 29c124a commit 56c6986

File tree

16 files changed

+315
-219
lines changed

16 files changed

+315
-219
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"sourceType": "module"
99
},
1010
"plugins": ["import", "react", "jest", "jsx-a11y", "babel"],
11-
"parser": "babel-eslint",
11+
"parser": "@babel/eslint-parser",
1212
"env": {
1313
"browser": true,
1414
"node": true,

__tests__/componentReducer.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import reducer from '../app/src/redux/reducers/slice/appStateSlice';
22
import { State, Action } from '../app/src/interfaces/Interfaces';
33
import { initialState } from '../app/src/redux/reducers/slice/appStateSlice';
4+
import styled from '@emotion/styled';
45

56
describe('componentReducer Test', () => {
67
let state: State = initialState;
@@ -173,15 +174,15 @@ describe('componentReducer Test', () => {
173174
expect(state.canvasFocus.childId).toEqual(null);
174175
});
175176
});
176-
177+
177178
// TEST 'UPDATE CSS'
178-
describe('updateCss', () => {
179+
xdescribe('updateCss', () => {
179180
it('should add style to focused component', () => {
180181
const action: Action = {
181182
type: 'appState/updateCss',
182183
payload: {
183184
style: {
184-
backgroundColor: 'gray'
185+
backgroundColor: 'gray',
185186
},
186187
contextParam: {
187188
allContext: []
@@ -192,10 +193,13 @@ describe('componentReducer Test', () => {
192193
const styledComp = state.components.find(
193194
(comp) => comp.id === state.canvasFocus.componentId
194195
);
196+
console.log('styledcomp',styledComp.style)
195197
// expect the style property on targeted comp to equal style property in payload
198+
if (styledComp) {
196199
expect(styledComp.style.backgroundColor).toEqual(
197200
action.payload.style.backgroundColor
198201
);
202+
}
199203
});
200204
});
201205

__tests__/contextReducer.test.js

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import subject from '../app/src/redux/reducers/slice/contextReducer';
1+
import subject from '../app/src/redux/reducers/slice/contextReducer.ts';
22

33
describe('contextReducer test', () => {
44
let state;
55

66
beforeEach(() => {
77
state = {
8-
allContext: []
8+
allContext: [],
99
};
1010
});
1111

@@ -25,16 +25,16 @@ describe('contextReducer test', () => {
2525
const action = {
2626
type: 'context/addContext',
2727
payload: {
28-
name: 'Theme Context'
29-
}
28+
name: 'Theme Context',
29+
},
3030
};
3131

3232
it('adds a context', () => {
3333
const { allContext } = subject(state, action);
3434
expect(allContext[0]).toEqual({
3535
name: 'Theme Context',
3636
values: [],
37-
components: []
37+
components: [],
3838
});
3939
});
4040

@@ -49,7 +49,7 @@ describe('contextReducer test', () => {
4949
});
5050
});
5151

52-
//OLD ADD CONTEX TEST
52+
// OLD ADD CONTEX TEST
5353

5454
// describe('ADD_CONTEXT', () => {
5555
// const action = {
@@ -86,9 +86,9 @@ describe('contextReducer test', () => {
8686
{
8787
name: 'Theme Context',
8888
values: [],
89-
components: []
90-
}
91-
]
89+
components: [],
90+
},
91+
],
9292
};
9393
});
9494

@@ -97,8 +97,8 @@ describe('contextReducer test', () => {
9797
payload: {
9898
name: 'Theme Context',
9999
inputKey: 'Theme Color',
100-
inputValue: 'Dark'
101-
}
100+
inputValue: 'Dark',
101+
},
102102
};
103103

104104
it('adds a key-value pair to values array of the specified context', () => {
@@ -123,21 +123,21 @@ describe('contextReducer test', () => {
123123
{
124124
name: 'Theme Context',
125125
values: [],
126-
components: []
126+
components: [],
127127
},
128128
{
129129
name: 'To be deleted',
130130
values: [],
131-
components: []
132-
}
133-
]
131+
components: [],
132+
},
133+
],
134134
};
135135

136136
action = {
137137
type: 'context/deleteContext',
138138
payload: {
139-
name: 'Theme Context'
140-
}
139+
name: 'Theme Context',
140+
},
141141
};
142142
});
143143

@@ -161,22 +161,22 @@ describe('contextReducer test', () => {
161161
{
162162
name: 'Theme Context',
163163
values: [],
164-
components: []
165-
}
166-
]
164+
components: [],
165+
},
166+
],
167167
};
168168
});
169169

170170
const action = {
171171
type: 'context/addComponentToContext',
172172
payload: {
173173
context: {
174-
name: 'Theme Context'
174+
name: 'Theme Context',
175175
},
176176
component: {
177-
name: 'Main Component'
178-
}
179-
}
177+
name: 'Main Component',
178+
},
179+
},
180180
};
181181

182182
it('adds a new component to the specified context', () => {

app/src/components/main/DemoRender.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ const DemoRender = (): JSX.Element => {
2828
const html = `
2929
<html>
3030
<head>
31+
<link
32+
rel="stylesheet"
33+
href="./fake.css"
34+
/>
3135
</head>
3236
<body>
3337
<div id="app">

app/src/components/main/fake.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
.test {
2+
color: red !important
3+
}
4+
.MuiBox-root {
5+
color: red
6+
}
7+
css-0 {
8+
color: red
9+
}
10+
11+
#rend1 {
12+
color: red !important
13+
}

app/src/components/right/ExportButton.tsx

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,8 @@ export default function ExportButton() {
1515
const state = useSelector((store: RootState) => store.appState);
1616

1717
const genOptions: string[] = [
18-
'Export components',
19-
'Export components with application files'
18+
'Export components'
2019
];
21-
let genOption = 0;
2220

2321
// Closes out the open modal
2422
const closeModal = () => setModal('');
@@ -29,7 +27,7 @@ export default function ExportButton() {
2927
{genOptions.map((option: string, i: number) => (
3028
<ListItem
3129
key={i}
32-
onClick={() => chooseGenOptions(i)}
30+
onClick={() => chooseGenOptions()}
3331
style={{
3432
border: '1px solid #3f51b5',
3533
marginBottom: '2%',
@@ -39,32 +37,19 @@ export default function ExportButton() {
3937
<ListItemText primary={option} style={{ textAlign: 'center' }} />
4038
</ListItem>
4139
))}
42-
<ListItem>
43-
<input type="checkbox" id="tests" name="tests"></input>
44-
<label for="tests">Include Tests</label>
45-
</ListItem>
4640
</List>
4741
);
48-
let testchecked = 0;
49-
// helper function called by showGenerateAppModal
50-
// this function will prompt the user to choose an app directory once they've chosen their export option
51-
const chooseGenOptions = (genOpt: number) => {
52-
// set export option: 0 --> export only components, 1 --> export full project
53-
genOption = genOpt;
54-
55-
//This is exclusive to the electron app
56-
// window.api.chooseAppDir();
57-
// testchecked = document.getElementById('tests').checked;
42+
43+
const chooseGenOptions = () => {
5844
zipFiles(state);
59-
6045
closeModal();
6146
};
6247

6348
setModal(
6449
createModal({
6550
closeModal,
6651
children,
67-
message: 'Choose export preference:',
52+
message: 'Click to download in zip file:',
6853
primBtnLabel: null,
6954
primBtnAction: null,
7055
secBtnAction: null,
@@ -100,17 +85,10 @@ export default function ExportButton() {
10085
);
10186
}
10287

103-
//The below code is exclusive to the Electron App's export function
104-
105-
// import React, { useState, useCallback, useEffect } from 'react';
106-
// import List from '@mui/material/List';
107-
// import ListItem from '@mui/material/ListItem';
108-
// import ListItemText from '@mui/material/ListItemText';
109-
// import GetAppIcon from '@mui/icons-material/GetApp';
110-
// import Button from '@mui/material/Button';
111-
// import exportProject from '../../utils/exportProject.util';
112-
// import createModal from './createModal';
113-
// import { useSelector } from 'react-redux';
88+
//The below code is exclusive to ReacType's Electron App
89+
//If you would like to deploy the app, please comment out the exportButton function above and uncomment the code below
90+
91+
11492
// export default function ExportButton() {
11593
// const [modal, setModal] = useState(null);
11694
// const state = useSelector(store => store.appState)

0 commit comments

Comments
 (0)