From b1e67bcd4d7ac3ba10c02573f91ea6567b0840fd Mon Sep 17 00:00:00 2001 From: pmhua Date: Tue, 14 Sep 2021 20:06:25 -0700 Subject: [PATCH 01/22] created checkbox, still needs logic implementation. Philip, Daniel, William, Miles --- app/src/components/right/ExportButton.tsx | 9 +++++++++ app/src/utils/createGatsbyApp.util.ts | 10 +++++++++- app/src/utils/createTestSuite.util.ts | 9 +++++++++ app/src/utils/exportProject.util.ts | 4 +++- package.json | 6 +++--- 5 files changed, 33 insertions(+), 5 deletions(-) create mode 100644 app/src/utils/createTestSuite.util.ts diff --git a/app/src/components/right/ExportButton.tsx b/app/src/components/right/ExportButton.tsx index 8c08ed54e..09f92467a 100644 --- a/app/src/components/right/ExportButton.tsx +++ b/app/src/components/right/ExportButton.tsx @@ -60,15 +60,22 @@ export default function ExportButton() { ))} + + + + ); + let testchecked = 0; // helper function called by showGenerateAppModal // this function will prompt the user to choose an app directory once they've chosen their export option const chooseGenOptions = (genOpt: number) => { // set export option: 0 --> export only components, 1 --> export full project + genOption = genOpt; window.api.chooseAppDir(); + testchecked = document.getElementById('tests').checked; closeModal(); }; @@ -80,12 +87,14 @@ export default function ExportButton() { // when a directory is chosen, the callback will export the project to the chosen folder // Note: this listener is imported from the main process via preload.js window.api.addAppDirChosenListener(path => { + // console.log(testchecked); exportProject( path, state.name ? state.name : 'New_ReacType_Project_' + Math.ceil(Math.random() * 99).toString(), genOption, + testchecked, state.projectType, state.components, state.rootComponents diff --git a/app/src/utils/createGatsbyApp.util.ts b/app/src/utils/createGatsbyApp.util.ts index 32d54df28..506e32e9a 100644 --- a/app/src/utils/createGatsbyApp.util.ts +++ b/app/src/utils/createGatsbyApp.util.ts @@ -1,6 +1,7 @@ // Create all files necessary to run a gatsby.js application import createGatsbyFiles from './createGatsbyFiles.util'; +import createTestFiles from './createTestSuite.util'; import { Component } from '../interfaces/Interfaces'; const camelToKebab= (camel:string) => { @@ -140,14 +141,17 @@ async function createGatsbyAppUtil({ path, appName, components, - rootComponents + rootComponents, + testchecked, }: { path: string; appName: string; components: Component[]; rootComponents: number[]; + testchecked: boolean; }) { console.log('in the createGatsbyApplication util'); + console.log('testchecked: ',testchecked); await initFolders(path, appName); await createBaseTsx(path, appName); @@ -156,5 +160,9 @@ async function createGatsbyAppUtil({ await createTsConfig(path, appName); await createGatsbyFiles(components, path, appName, rootComponents); + if (testchecked) { + console.log('testchecked: ',testchecked); + await createTestFiles() + } } export default createGatsbyAppUtil; diff --git a/app/src/utils/createTestSuite.util.ts b/app/src/utils/createTestSuite.util.ts new file mode 100644 index 000000000..01f82b915 --- /dev/null +++ b/app/src/utils/createTestSuite.util.ts @@ -0,0 +1,9 @@ + +// create config files +// add webpack dependencies +// create tests for components +const createTestSuite = () => { + console.log('creating test suites'); +} + +export default createTestSuite; \ No newline at end of file diff --git a/app/src/utils/exportProject.util.ts b/app/src/utils/exportProject.util.ts index 5f65afe2d..3f4f52024 100644 --- a/app/src/utils/exportProject.util.ts +++ b/app/src/utils/exportProject.util.ts @@ -8,6 +8,7 @@ const exportProject = ( path: string, appName: string, genOption: number, + tests: boolean, projectType: string, components: any, rootComponents: number[] @@ -26,9 +27,10 @@ const exportProject = ( console.log(err) ); } else if (genOption === 1 && projectType === 'Gatsby.js') { - createGatsbyApp({ path, appName, components, rootComponents }).catch(err => + createGatsbyApp({ path, appName, components, rootComponents, tests }).catch(err => console.log(err)); } + }; export default exportProject; diff --git a/package.json b/package.json index 7a9ae9eb6..449fa41f1 100644 --- a/package.json +++ b/package.json @@ -47,8 +47,8 @@ "dev-server": "cross-env NODE_ENV=development webpack-dev-server --config ./webpack.development.js", "dev": "concurrently --success first \"cross-env NODE_ENV=development webpack-dev-server --config ./webpack.development.js\" \"cross-env NODE_ENV=development electron .\" \"npm run server\" -k", "p": "concurrently --success first \"npm run dev-server\" \"cross-env NODE_ENV=production electron .\" \"nodemon server/server.js\" -k", - "prod-build": "cross-env NODE_ENV=production npx webpack --mode=production --config ./webpack.production.js", - "prod": "npm run prod-build && electron . --no-sandbox", + "prod-build": "cross-env NODE_ENV=production npx webpack --mode=production --config ./webpack.production.js", + "prod": "npm run prod-build && electron . --no-sandbox", "pack": "electron-builder --dir", "dist": "npm run prod-build && electron-builder", "dist-mac": "npm run prod-build && electron-builder --mac", @@ -63,7 +63,7 @@ "url": "git+https://github.com/open-source-labs/ReacType.git" }, "keywords": [ - "electron", + "electron", "prototying", "react", "next.js" From c0cc38b8d41d3afc65abcf4ddbc7519710388920 Mon Sep 17 00:00:00 2001 From: pmhua Date: Wed, 15 Sep 2021 12:23:50 -0700 Subject: [PATCH 02/22] beta: tests config for gatsby app export in progress, Philip Miles --- app/src/utils/createGatsbyApp.util.ts | 86 +++++++++++++++++++-------- app/src/utils/exportProject.util.ts | 2 +- 2 files changed, 61 insertions(+), 27 deletions(-) diff --git a/app/src/utils/createGatsbyApp.util.ts b/app/src/utils/createGatsbyApp.util.ts index 506e32e9a..e52548817 100644 --- a/app/src/utils/createGatsbyApp.util.ts +++ b/app/src/utils/createGatsbyApp.util.ts @@ -25,30 +25,64 @@ const compToCSS = (component: Component) => { } //createPackage -export const createPackage = (path, appName) => { +export const createPackage = (path, appName, test) => { + // console.log('in createpackage: ',test); const filePath = `${path}/${appName}/package.json`; - const data = ` -{ - "name": "reactype-gatsby", - "version": "1.0.0", - "description": "", - "scripts": { - "dev": "gatsby develop", - "build": "gatsby build", - "start": "npm run dev" - }, - "dependencies": { - "gatsby": "^2.26.1", - "react": "16.13.1", - "react-dom": "16.13.1" - }, - "devDependencies": { - "@types/node": "^14.0.20", - "@types/react": "^16.9.41", - "typescript": "^3.9.6" + let data = ``; + if (!test) { + data = ` + { + "name": "reactype-gatsby", + "version": "1.0.0", + "description": "", + "scripts": { + "dev": "gatsby develop", + "build": "gatsby build", + "start": "npm run dev" + }, + "dependencies": { + "gatsby": "^2.26.1", + "react": "16.13.1", + "react-dom": "16.13.1" + }, + "devDependencies": { + "@types/node": "^14.0.20", + "@types/react": "^16.9.41", + "typescript": "^3.9.6" + } + } + `; + } else { + data = ` + { + "name": "reactype-gatsby", + "version": "1.0.0", + "description": "", + "scripts": { + "dev": "gatsby develop", + "build": "gatsby build", + "start": "npm run dev" + }, + "dependencies": { + "gatsby": "^2.26.1", + "react": "16.13.1", + "react-dom": "16.13.1" + }, + "devDependencies": { + "@types/node": "^14.0.20", + "@types/react": "^16.9.41", + "typescript": "^3.9.6", + "@types/enzyme": "^3.10.9", + "@types/jest": "^27.0.1", + "babel-jest": "^27.2.0", + "enzyme": "^3.11.0", + "enzyme-adapter-react-16": "^1.15.6", + "jest": "^27.2.0", + "react-test-renderer": "^17.0.2" + } + } + `; } -} - `; window.api.writeFile(filePath, data, err => { if (err) { console.log('package.json error:', err.message); @@ -152,17 +186,17 @@ async function createGatsbyAppUtil({ }) { console.log('in the createGatsbyApplication util'); console.log('testchecked: ',testchecked); - + await initFolders(path, appName); await createBaseTsx(path, appName); await createDefaultCSS(path, appName, components); - await createPackage(path, appName); + await createPackage(path, appName, testchecked); await createTsConfig(path, appName); - await createGatsbyFiles(components, path, appName, rootComponents); - if (testchecked) { console.log('testchecked: ',testchecked); await createTestFiles() } + await createGatsbyFiles(components, path, appName, rootComponents); + } export default createGatsbyAppUtil; diff --git a/app/src/utils/exportProject.util.ts b/app/src/utils/exportProject.util.ts index 3f4f52024..e5b90b527 100644 --- a/app/src/utils/exportProject.util.ts +++ b/app/src/utils/exportProject.util.ts @@ -27,7 +27,7 @@ const exportProject = ( console.log(err) ); } else if (genOption === 1 && projectType === 'Gatsby.js') { - createGatsbyApp({ path, appName, components, rootComponents, tests }).catch(err => + createGatsbyApp({ path, appName, components, rootComponents, testchecked: tests }).catch(err => console.log(err)); } From c0660f24672a8ce93161b3e595c4d0c73023d788 Mon Sep 17 00:00:00 2001 From: pmhua Date: Wed, 15 Sep 2021 17:30:36 -0700 Subject: [PATCH 03/22] finished configuring package.json in createGatsbyApp.util.ts, Philip, Miles --- app/src/utils/createGatsbyApp.util.ts | 57 ++++++++++----------------- 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/app/src/utils/createGatsbyApp.util.ts b/app/src/utils/createGatsbyApp.util.ts index e52548817..a5ecd8c63 100644 --- a/app/src/utils/createGatsbyApp.util.ts +++ b/app/src/utils/createGatsbyApp.util.ts @@ -28,32 +28,23 @@ const compToCSS = (component: Component) => { export const createPackage = (path, appName, test) => { // console.log('in createpackage: ',test); const filePath = `${path}/${appName}/package.json`; - let data = ``; - if (!test) { - data = ` - { - "name": "reactype-gatsby", - "version": "1.0.0", - "description": "", - "scripts": { - "dev": "gatsby develop", - "build": "gatsby build", - "start": "npm run dev" - }, - "dependencies": { - "gatsby": "^2.26.1", - "react": "16.13.1", - "react-dom": "16.13.1" - }, - "devDependencies": { - "@types/node": "^14.0.20", - "@types/react": "^16.9.41", - "typescript": "^3.9.6" - } - } - `; - } else { - data = ` + + let tsjest = `, + "@types/enzyme": "^3.10.9", + "@types/jest": "^27.0.1", + "babel-jest": "^27.2.0", + "enzyme": "^3.11.0", + "enzyme-adapter-react-16": "^1.15.6", + "jest": "^27.2.0", + "react-test-renderer": "^17.0.2", + "@types/react-dom": "^17.0.9", + "@types/enzyme-adapter-react-16": "^1.0.6", + "@types/react-test-renderer": "^17.0.1", + "babel-preset-gatsby": "^1.13.0", + "identity-obj-proxy": "^3.0.0", + "ts-jest": "^27.0.5"`; + + const data = ` { "name": "reactype-gatsby", "version": "1.0.0", @@ -61,7 +52,8 @@ export const createPackage = (path, appName, test) => { "scripts": { "dev": "gatsby develop", "build": "gatsby build", - "start": "npm run dev" + "start": "npm run dev"${ + test ? '"test": "jest"': '' } }, "dependencies": { "gatsby": "^2.26.1", @@ -71,18 +63,11 @@ export const createPackage = (path, appName, test) => { "devDependencies": { "@types/node": "^14.0.20", "@types/react": "^16.9.41", - "typescript": "^3.9.6", - "@types/enzyme": "^3.10.9", - "@types/jest": "^27.0.1", - "babel-jest": "^27.2.0", - "enzyme": "^3.11.0", - "enzyme-adapter-react-16": "^1.15.6", - "jest": "^27.2.0", - "react-test-renderer": "^17.0.2" + "typescript": "^3.9.6"${ + test ? tsjest : '' } } } `; - } window.api.writeFile(filePath, data, err => { if (err) { console.log('package.json error:', err.message); From 8726be28dde7c4757f7dbce57856913055c0b27a Mon Sep 17 00:00:00 2001 From: dreille <66196129+dreille@users.noreply.github.com> Date: Wed, 15 Sep 2021 17:30:41 -0700 Subject: [PATCH 04/22] Co-authored-by: wbrittwage --- app/electron/main.js | 296 ++++++++++++------------ app/src/components/login/SignIn.tsx | 23 +- app/src/helperFunctions/gitHubOauth.ts | 2 +- package.json | 7 +- server/controllers/sessionController.js | 182 ++++++++------- server/controllers/userController.js | 57 +++-- server/server.js | 40 ++-- 7 files changed, 313 insertions(+), 294 deletions(-) diff --git a/app/electron/main.js b/app/electron/main.js index c6efa1eba..983092fe8 100644 --- a/app/electron/main.js +++ b/app/electron/main.js @@ -360,153 +360,153 @@ if (isDev) { } // // for github oauth login in production, since cookies are not accessible through document.cookie on local filesystem, we need electron to grab the cookie that is set from oauth, this listens for an set cookie event from the renderer process then sends back the cookie -// ipcMain.on('set_cookie', event => { -// session.defaultSession.cookies -// .get({ url: serverUrl }) -// .then(cookie => { -// // this if statement is necessary or the setInterval on main app will constantly run and will emit this event.reply, causing a memory leak -// // checking for a cookie inside array will only emit reply when a cookie exists -// if (cookie[0]) { -// //console.log(cookie); -// event.reply('give_cookie', cookie); -// } -// }) -// .catch(error => { -// console.log('Error giving cookies in set_cookie:', error); -// }); -// }); - -// // again for production, document.cookie is not accessible so we need this listener on main to delete the cookie on logout -// ipcMain.on('delete_cookie', event => { -// session.defaultSession.cookies -// .remove(serverUrl, 'ssid') -// // .then(removed => { -// // console.log('Cookies deleted', removed); -// // }) -// .catch(err => console.log('Error deleting cookie:', err)); -// }); - -// // opens new window for github oauth when button on sign in page is clicked -// ipcMain.on('github', event => { -// // your applications credentials -// const githubUrl = 'https://github.com/login/oauth/authorize?'; -// const options = { -// client_id: process.env.GITHUB_ID, -// client_secret: process.env.GITHUB_SECRET, -// scopes: ['user:email', 'notifications'] -// }; -// // create new browser window object with size, title, security options -// const github = new BrowserWindow({ -// width: 800, -// height: 600, -// title: 'Github Oauth', -// webPreferences: { -// nodeIntegration: false, -// nodeIntegrationInWorker: false, -// nodeIntegrationInSubFrames: false, -// contextIsolation: true, -// enableRemoteModule: false, -// zoomFactor: 1.0 -// } -// }); -// const authUrl = `${githubUrl}client_id=${process.env.GITHUB_ID}`; -// github.loadURL(authUrl); -// github.show(); -// const handleCallback = url => { -// const raw_code = /code=([^&]\*)/.exec(url) || null; -// const code = raw_code && raw_code.length > 1 ? raw_code[1] : null; -// const error = /\?error=(.+)\$/.exec(url); - -// if (code || error) { -// // Close the browser if code found or error -// authWindow.destroy(); -// } - -// // If there is a code, proceed to get token from github -// if (code) { -// self.requestGithubToken(options, code); -// } else if (error) { -// alert( -// "Oops! Something went wrong and we couldn't" + -// 'log you in using Github. Please try again.' -// ); -// } -// }; - -// github.webContents.on('will-navigate', (e, url) => handleCallback(url)); - -// github.webContents.on('did-finish-load', (e, url, a, b) => { -// github.webContents.selectAll(); -// }); - -// github.webContents.on('did-get-redirect-request', (e, oldUrl, newUrl) => -// handleCallback(newUrl) -// ); - -// // Reset the authWindow on close -// github.on('close', () => (authWindow = null), false); - -// // if final callback is reached and we get a redirect from server back to our app, close oauth window -// github.webContents.on('will-redirect', (e, callbackUrl) => { -// const matches = callbackUrl.match(/(?<=\?=).*/); -// const ssid = matches ? matches[0] : ''; -// callbackUrl = callbackUrl.replace(/\?=.*/, ''); -// let redirectUrl = 'app://rse/'; -// if (isDev) { -// redirectUrl = 'http://localhost:8080/'; -// } -// if (callbackUrl === redirectUrl) { -// dialog.showMessageBox({ -// type: 'info', -// title: 'ReacType', -// icon: resolve('app/src/public/icons/png/256x256.png'), -// message: 'Github Oauth Successful!' -// }); -// github.close(); -// win.webContents -// .executeJavaScript(`window.localStorage.setItem('ssid', '${ssid}')`) -// .then(result => win.loadURL(selfHost)) -// .catch(err => console.log(err)); -// } -// }); -// }); - -// ipcMain.on('tutorial', event => { -// // create new browser window object with size, title, security options -// const tutorial = new BrowserWindow({ -// width: 800, -// height: 600, -// minWidth: 661, -// title: 'Tutorial', -// webPreferences: { -// nodeIntegration: false, -// nodeIntegrationInWorker: false, -// nodeIntegrationInSubFrames: false, -// contextIsolation: true, -// enableRemoteModule: false, -// zoomFactor: 1.0 -// } -// }); -// // redirects to relevant server endpoint -// //github.loadURL(`${serverUrl}/github`); -// // show window -// tutorial.show(); -// // if final callback is reached and we get a redirect from server back to our app, close oauth window -// // github.webContents.on('will-redirect', (e, callbackUrl) => { -// // let redirectUrl = 'app://rse/'; -// // if (isDev) { -// // redirectUrl = 'http://localhost:8080/'; -// // } -// // if (callbackUrl === redirectUrl) { -// // dialog.showMessageBox({ -// // type: 'info', -// // title: 'ReacType', -// // icon: resolve('app/src/public/icons/png/256x256.png'), -// // message: 'Github Oauth Successful!' -// // }); -// // github.close(); -// // } -// // }); -// }); +ipcMain.on('set_cookie', event => { + session.defaultSession.cookies + .get({ url: serverUrl }) + .then(cookie => { + // this if statement is necessary or the setInterval on main app will constantly run and will emit this event.reply, causing a memory leak + // checking for a cookie inside array will only emit reply when a cookie exists + if (cookie[0]) { + //console.log(cookie); + event.reply('give_cookie', cookie); + } + }) + .catch(error => { + console.log('Error giving cookies in set_cookie:', error); + }); +}); + +// again for production, document.cookie is not accessible so we need this listener on main to delete the cookie on logout +ipcMain.on('delete_cookie', event => { + session.defaultSession.cookies + .remove(serverUrl, 'ssid') + // .then(removed => { + // console.log('Cookies deleted', removed); + // }) + .catch(err => console.log('Error deleting cookie:', err)); +}); + +// opens new window for github oauth when button on sign in page is clicked +ipcMain.on('github', event => { + // your applications credentials + const githubUrl = 'https://github.com/login/oauth/authorize?'; + const options = { + client_id: process.env.GITHUB_ID, + client_secret: process.env.GITHUB_SECRET, + scopes: ['user:email', 'notifications'] + }; + // create new browser window object with size, title, security options + const github = new BrowserWindow({ + width: 800, + height: 600, + title: 'Github Oauth', + webPreferences: { + nodeIntegration: false, + nodeIntegrationInWorker: false, + nodeIntegrationInSubFrames: false, + contextIsolation: true, + enableRemoteModule: false, + zoomFactor: 1.0 + } + }); + const authUrl = `${githubUrl}client_id=${process.env.GITHUB_ID}`; + github.loadURL(authUrl); + github.show(); + const handleCallback = url => { + const raw_code = /code=([^&]\*)/.exec(url) || null; + const code = raw_code && raw_code.length > 1 ? raw_code[1] : null; + const error = /\?error=(.+)\$/.exec(url); + + if (code || error) { + // Close the browser if code found or error + authWindow.destroy(); + } + + // If there is a code, proceed to get token from github + if (code) { + self.requestGithubToken(options, code); + } else if (error) { + alert( + "Oops! Something went wrong and we couldn't" + + 'log you in using Github. Please try again.' + ); + } + }; + + github.webContents.on('will-navigate', (e, url) => handleCallback(url)); + + github.webContents.on('did-finish-load', (e, url, a, b) => { + github.webContents.selectAll(); + }); + + github.webContents.on('did-get-redirect-request', (e, oldUrl, newUrl) => + handleCallback(newUrl) + ); + + // Reset the authWindow on close + github.on('close', () => (authWindow = null), false); + + // if final callback is reached and we get a redirect from server back to our app, close oauth window + github.webContents.on('will-redirect', (e, callbackUrl) => { + const matches = callbackUrl.match(/(?<=\?=).*/); + const ssid = matches ? matches[0] : ''; + callbackUrl = callbackUrl.replace(/\?=.*/, ''); + let redirectUrl = 'app://rse/'; + if (isDev) { + redirectUrl = 'http://localhost:8080/'; + } + if (callbackUrl === redirectUrl) { + dialog.showMessageBox({ + type: 'info', + title: 'ReacType', + icon: resolve('app/src/public/icons/png/256x256.png'), + message: 'Github Oauth Successful!' + }); + github.close(); + win.webContents + .executeJavaScript(`window.localStorage.setItem('ssid', '${ssid}')`) + .then(result => win.loadURL(selfHost)) + .catch(err => console.log(err)); + } + }); +}); + +ipcMain.on('tutorial', event => { + // create new browser window object with size, title, security options + const tutorial = new BrowserWindow({ + width: 800, + height: 600, + minWidth: 661, + title: 'Tutorial', + webPreferences: { + nodeIntegration: false, + nodeIntegrationInWorker: false, + nodeIntegrationInSubFrames: false, + contextIsolation: true, + enableRemoteModule: false, + zoomFactor: 1.0 + } + }); + // redirects to relevant server endpoint + github.loadURL(`${serverUrl}/github`); + // show window + tutorial.show(); + // if final callback is reached and we get a redirect from server back to our app, close oauth window + github.webContents.on('will-redirect', (e, callbackUrl) => { + let redirectUrl = 'app://rse/'; + if (isDev) { + redirectUrl = 'http://localhost:8080/'; + } + if (callbackUrl === redirectUrl) { + dialog.showMessageBox({ + type: 'info', + title: 'ReacType', + icon: resolve('app/src/public/icons/png/256x256.png'), + message: 'Github Oauth Successful!' + }); + github.close(); + } + }); +}); module.exports = dialog; diff --git a/app/src/components/login/SignIn.tsx b/app/src/components/login/SignIn.tsx index 39f94e4ad..fae7d9561 100644 --- a/app/src/components/login/SignIn.tsx +++ b/app/src/components/login/SignIn.tsx @@ -73,7 +73,7 @@ const SignIn: React.FC = props => { // Commented because window api is broken. Work in progress - /* useEffect(() => { + useEffect(() => { const githubCookie = setInterval(() => { window.api.setCookie(); window.api.getCookie(cookie => { @@ -88,7 +88,7 @@ const SignIn: React.FC = props => { } }); }, 2000); - }, []);*/ + }, []); const handleChange = (e: React.ChangeEvent) => { let inputVal = e.target.value; @@ -158,7 +158,15 @@ const SignIn: React.FC = props => { window.localStorage.setItem('ssid', 'guest'); props.history.push('/'); }; + + const handleGithubLogin = ( + e: React.MouseEvent + ) => { + e.preventDefault(); + window.api.github(); + props.history.push('/'); + } const responseFacebook = response => { if (response.accessToken) { newUserIsCreated(response.email, response.email, randomPassword()).then( @@ -235,7 +243,16 @@ const SignIn: React.FC = props => { > Sign In - + ); @@ -62,14 +69,20 @@ const getColumns = (props) => { }; const TableStateProps = (props) => { + const classes = useStyles(); const [state] = useContext(StateContext); const [editRowsModel] = useState ({}); const [gridColumns, setGridColumns] = useState([]); + + useEffect(() => { + console.log('isThemeLight: ',props.isThemeLight) + setGridColumns(getColumns(props)); + }, [props.isThemeLight]) // get currentComponent by using currently focused component's id const currentId = state.canvasFocus.componentId; const currentComponent = state.components[currentId - 1]; - + const rows = currentComponent.stateProps.slice(); const { selectHandler } : StatePropsPanelProps = props; @@ -87,9 +100,21 @@ const TableStateProps = (props) => { pageSize={5} editRowsModel={editRowsModel} onRowClick = {selectHandler} + headerClassName: props.isThemeLight ? 'classes.themeLight' : 'classes.themeDark', + /> ); }; + +const useStyles = makeStyles({ + themeLight: { + color: 'rbga(0,0,0,054)' + }, + themeDark: { + color: 'white' + } +}); + export default TableStateProps; diff --git a/app/src/containers/CustomizationPanel.tsx b/app/src/containers/CustomizationPanel.tsx index eab20b9fd..2598df41b 100644 --- a/app/src/containers/CustomizationPanel.tsx +++ b/app/src/containers/CustomizationPanel.tsx @@ -735,6 +735,15 @@ const useStyles = makeStyles({ border: isThemeLight ? '1px solid #808080' : '1px solid #ECECEA' } }), + // buttonRow: { + // textAlign: 'center', + // marginTop: '25px', + // '& .MuiButton-textSecondary': { + // color: '#808080', // color for delete page + // border: '1px solid #808080' + // } + // }, + button: { fontSize: '1rem', paddingLeft: '20px', From 801421c09a31e15d87108c3196119ba5b94fee08 Mon Sep 17 00:00:00 2001 From: pmhua Date: Tue, 21 Sep 2021 16:25:46 -0700 Subject: [PATCH 18/22] finished darkmode Co-authored-by: Philip Hua Co-authored-by: Miles Wright Co-authored-by: William Rittwage Co-authored-by: Daniel Reilley --- app/src/components/left/HTMLPanel.tsx | 10 +++++-- app/src/components/right/ComponentDrag.tsx | 1 + app/src/components/right/ComponentPanel.tsx | 10 +++++-- .../components/right/ComponentPanelItem.tsx | 15 ++++++++--- app/src/components/right/StatePropsPanel.tsx | 16 ++++++++--- app/src/components/right/TableStateProps.tsx | 27 ++++++++++++------- 6 files changed, 59 insertions(+), 20 deletions(-) diff --git a/app/src/components/left/HTMLPanel.tsx b/app/src/components/left/HTMLPanel.tsx index e563da318..34f849f60 100644 --- a/app/src/components/left/HTMLPanel.tsx +++ b/app/src/components/left/HTMLPanel.tsx @@ -271,10 +271,16 @@ const useStyles = makeStyles({ borderRadius: '4px', }, lightThemeFontColor: { - color: '#155084' + color: '#155084', + '& .MuiInputBase-root': { + color: 'rgba (0, 0, 0, 0.54)', + } }, darkThemeFontColor: { - color: '#ffffff' + color: '#ffffff', + '& .MuiInputBase-root': { + color: '#fff', + } }, errorMessage: { fontSize:"11px", diff --git a/app/src/components/right/ComponentDrag.tsx b/app/src/components/right/ComponentDrag.tsx index 777c68849..60fda99da 100644 --- a/app/src/components/right/ComponentDrag.tsx +++ b/app/src/components/right/ComponentDrag.tsx @@ -34,6 +34,7 @@ const ComponentDrag = ({isThemeLight}): JSX.Element => { name={comp.name} id={comp.id} root={true} + isThemeLight={isThemeLight} /> ); diff --git a/app/src/components/right/ComponentPanel.tsx b/app/src/components/right/ComponentPanel.tsx index 0b3750665..e30beb2d5 100644 --- a/app/src/components/right/ComponentPanel.tsx +++ b/app/src/components/right/ComponentPanel.tsx @@ -261,10 +261,16 @@ const useStyles = makeStyles({ fontSize: '0.85rem' }, lightThemeFontColor: { - color: '#155084' + color: '#155084', + '& .MuiInputBase-root': { + color: 'rgba (0, 0, 0, 0.54)', + } }, darkThemeFontColor: { - color: '#fff' + color: '#fff', + '& .MuiInputBase-root': { + color: '#fff', + } } }); diff --git a/app/src/components/right/ComponentPanelItem.tsx b/app/src/components/right/ComponentPanelItem.tsx index 410ff224f..c291c0739 100644 --- a/app/src/components/right/ComponentPanelItem.tsx +++ b/app/src/components/right/ComponentPanelItem.tsx @@ -41,7 +41,8 @@ const ComponentPanelItem: React.FC<{ id: number; root: boolean; isFocus: boolean; -}> = ({ name, id, root, isFocus }) => { + isThemeLight: boolean; +}> = ({ name, id, root, isFocus, isThemeLight }) => { const classes = useStyles(); const [state, dispatch] = useContext(StateContext); @@ -66,6 +67,7 @@ const ComponentPanelItem: React.FC<{ payload: { componentId: id, childId: null } }); }; + console.log('isThemeLight 3:',isThemeLight) return ( {isFocus &&
}
-

{name}

+

{name}

); @@ -102,6 +103,12 @@ const useStyles = makeStyles({ width: '12px', height: '12px', borderRadius: '25px', + }, + lightTheme: { + color: 'rgba (0, 0, 0, 0.54)' + }, + darkTheme: { + color: '#fff' } }); diff --git a/app/src/components/right/StatePropsPanel.tsx b/app/src/components/right/StatePropsPanel.tsx index 01b4416bd..8efc8a4a8 100644 --- a/app/src/components/right/StatePropsPanel.tsx +++ b/app/src/components/right/StatePropsPanel.tsx @@ -130,15 +130,15 @@ const StatePropsPanel = ({ isThemeLight }): JSX.Element => { variant="outlined" value={inputKey} onChange={(e) => setInputKey(e.target.value)} - className={isThemeLight ? classes.rootLight : classes.rootDark} + className={isThemeLight ? `${classes.rootLight} ${classes.inputTextLight}` : `${classes.rootDark} ${classes.inputTextDark}`} /> setInputValue(e.target.value)} + className={isThemeLight ? `${classes.rootLight} ${classes.inputTextLight}` : `${classes.rootDark} ${classes.inputTextDark}`} /> {