From 577fb7cfab97d3d24379d5f1cdba0784c2844b03 Mon Sep 17 00:00:00 2001 From: Axel Date: Sun, 28 Nov 2021 19:55:43 -0300 Subject: [PATCH] Integrate React frontend for desktop app * Added component files * Added dependencies and settings on package.json * Updated package-lock.json to match new dependencies * Added react scripts and config files --- Desktop/DesktopApp.js | 8 +- Desktop/UI/WebApp.js | 33 +- Desktop/WebServer/index.html | 134 +- Desktop/components/ReactBase.js | 16 + Desktop/components/Root.js | 31 + Desktop/components/User/UserCard.css | 17 + Desktop/components/User/UserCard.js | 30 + .../components/UsersSidebar/UsersSidebar.css | 4 + .../components/UsersSidebar/UsersSidebar.js | 23 + Desktop/components/feed/Feed.css | 11 + Desktop/components/feed/Feed.js | 14 + Desktop/components/home/App.css | 7 + Desktop/components/home/App.js | 23 + Desktop/components/logo/Logo.css | 10 + Desktop/components/logo/Logo.js | 17 + Desktop/components/notFound/NotFound.js | 10 + Desktop/components/post/Post.css | 32 + Desktop/components/post/Post.js | 62 + .../postPlaceholder/PostPlaceholder.css | 47 + .../postPlaceholder/PostPlaceholder.js | 54 + Desktop/components/postsFeed/PostsFeed.css | 4 + Desktop/components/postsFeed/PostsFeed.js | 26 + Desktop/components/searchBox/SearchBox.css | 3 + Desktop/components/searchBox/SearchBox.js | 16 + .../components/showMoreUsers/ShowMoreUsers.js | 16 + Desktop/components/sidebar/Sidebar.css | 3 + Desktop/components/sidebar/Sidebar.js | 42 + .../components/sidebarItem/SidebarItem.css | 21 + Desktop/components/sidebarItem/SidebarItem.js | 22 + .../suggestedUsers/SuggestedUsers.css | 0 .../suggestedUsers/SuggestedUsers.js | 32 + .../components/userProfile/UserProfile.css | 41 + Desktop/components/userProfile/UserProfile.js | 28 + .../userProfileHeader/UserProfileHeader.css | 0 .../userProfileHeader/UserProfileHeader.js | 30 + Desktop/config/env.js | 106 + Desktop/config/getHttpsConfig.js | 66 + Desktop/config/modules.js | 134 + Desktop/config/paths.js | 76 + Desktop/config/pnpTs.js | 35 + Desktop/config/webpack.config.js | 757 + Desktop/config/webpackDevServer.config.js | 130 + Desktop/images/banner.jpg | Bin 0 -> 6595126 bytes Desktop/images/pfp.png | Bin 0 -> 17477 bytes Desktop/images/superalgos.png | Bin 0 -> 17477 bytes Desktop/public/favicon.ico | Bin 0 -> 15086 bytes Desktop/public/index.html | 43 + Desktop/public/logo192.png | Bin 0 -> 5347 bytes Desktop/public/logo512.png | Bin 0 -> 9664 bytes Desktop/public/manifest.json | 25 + Desktop/public/robots.txt | 3 + Desktop/scripts/build.js | 212 + Desktop/scripts/start.js | 162 + Desktop/scripts/test.js | 53 + Desktop/src/components/ReactBase.js | 16 + Desktop/src/components/Root.js | 31 + Desktop/src/components/User/UserCard.css | 17 + Desktop/src/components/User/UserCard.js | 30 + .../components/UsersSidebar/UsersSidebar.css | 4 + .../components/UsersSidebar/UsersSidebar.js | 23 + Desktop/src/components/feed/Feed.css | 11 + Desktop/src/components/feed/Feed.js | 14 + Desktop/src/components/home/App.css | 7 + Desktop/src/components/home/App.js | 23 + Desktop/src/components/logo/Logo.css | 10 + Desktop/src/components/logo/Logo.js | 17 + Desktop/src/components/notFound/NotFound.js | 10 + Desktop/src/components/post/Post.css | 49 + Desktop/src/components/post/Post.js | 64 + .../postPlaceholder/PostPlaceholder.css | 47 + .../postPlaceholder/PostPlaceholder.js | 54 + .../src/components/postsFeed/PostsFeed.css | 5 + Desktop/src/components/postsFeed/PostsFeed.js | 25 + .../src/components/searchBox/SearchBox.css | 3 + Desktop/src/components/searchBox/SearchBox.js | 16 + .../components/showMoreUsers/ShowMoreUsers.js | 16 + Desktop/src/components/sidebar/Sidebar.css | 3 + Desktop/src/components/sidebar/Sidebar.js | 42 + .../components/sidebarItem/SidebarItem.css | 21 + .../src/components/sidebarItem/SidebarItem.js | 22 + .../suggestedUsers/SuggestedUsers.css | 0 .../suggestedUsers/SuggestedUsers.js | 32 + .../components/userProfile/UserProfile.css | 41 + .../src/components/userProfile/UserProfile.js | 28 + .../userProfileHeader/UserProfileHeader.css | 0 .../userProfileHeader/UserProfileHeader.js | 30 + Desktop/src/images/banner.jpg | Bin 0 -> 6595126 bytes Desktop/src/images/pfp.jpg | Bin 0 -> 24092 bytes Desktop/src/images/superalgos.png | Bin 0 -> 17477 bytes Desktop/src/index.css | 13 + Desktop/src/index.js | 18 + Desktop/src/reportWebVitals.js | 13 + Desktop/src/store/index.js | 9 + Desktop/src/store/slices/Example.slice.js | 21 + Desktop/store/index.js | 9 + Desktop/store/slices/Example.slice.js | 21 + MultiProject.js | 2 +- .../Plugins/User-Profiles/Loui-Molina.json | 339 +- package-lock.json | 41541 +++++++++++++++- package.json | 86 +- 100 files changed, 45030 insertions(+), 422 deletions(-) create mode 100644 Desktop/components/ReactBase.js create mode 100644 Desktop/components/Root.js create mode 100644 Desktop/components/User/UserCard.css create mode 100644 Desktop/components/User/UserCard.js create mode 100644 Desktop/components/UsersSidebar/UsersSidebar.css create mode 100644 Desktop/components/UsersSidebar/UsersSidebar.js create mode 100644 Desktop/components/feed/Feed.css create mode 100644 Desktop/components/feed/Feed.js create mode 100644 Desktop/components/home/App.css create mode 100644 Desktop/components/home/App.js create mode 100644 Desktop/components/logo/Logo.css create mode 100644 Desktop/components/logo/Logo.js create mode 100644 Desktop/components/notFound/NotFound.js create mode 100644 Desktop/components/post/Post.css create mode 100644 Desktop/components/post/Post.js create mode 100644 Desktop/components/postPlaceholder/PostPlaceholder.css create mode 100644 Desktop/components/postPlaceholder/PostPlaceholder.js create mode 100644 Desktop/components/postsFeed/PostsFeed.css create mode 100644 Desktop/components/postsFeed/PostsFeed.js create mode 100644 Desktop/components/searchBox/SearchBox.css create mode 100644 Desktop/components/searchBox/SearchBox.js create mode 100644 Desktop/components/showMoreUsers/ShowMoreUsers.js create mode 100644 Desktop/components/sidebar/Sidebar.css create mode 100644 Desktop/components/sidebar/Sidebar.js create mode 100644 Desktop/components/sidebarItem/SidebarItem.css create mode 100644 Desktop/components/sidebarItem/SidebarItem.js create mode 100644 Desktop/components/suggestedUsers/SuggestedUsers.css create mode 100644 Desktop/components/suggestedUsers/SuggestedUsers.js create mode 100644 Desktop/components/userProfile/UserProfile.css create mode 100644 Desktop/components/userProfile/UserProfile.js create mode 100644 Desktop/components/userProfileHeader/UserProfileHeader.css create mode 100644 Desktop/components/userProfileHeader/UserProfileHeader.js create mode 100644 Desktop/config/env.js create mode 100644 Desktop/config/getHttpsConfig.js create mode 100644 Desktop/config/modules.js create mode 100644 Desktop/config/paths.js create mode 100644 Desktop/config/pnpTs.js create mode 100644 Desktop/config/webpack.config.js create mode 100644 Desktop/config/webpackDevServer.config.js create mode 100644 Desktop/images/banner.jpg create mode 100644 Desktop/images/pfp.png create mode 100644 Desktop/images/superalgos.png create mode 100644 Desktop/public/favicon.ico create mode 100644 Desktop/public/index.html create mode 100644 Desktop/public/logo192.png create mode 100644 Desktop/public/logo512.png create mode 100644 Desktop/public/manifest.json create mode 100644 Desktop/public/robots.txt create mode 100644 Desktop/scripts/build.js create mode 100644 Desktop/scripts/start.js create mode 100644 Desktop/scripts/test.js create mode 100644 Desktop/src/components/ReactBase.js create mode 100644 Desktop/src/components/Root.js create mode 100644 Desktop/src/components/User/UserCard.css create mode 100644 Desktop/src/components/User/UserCard.js create mode 100644 Desktop/src/components/UsersSidebar/UsersSidebar.css create mode 100644 Desktop/src/components/UsersSidebar/UsersSidebar.js create mode 100644 Desktop/src/components/feed/Feed.css create mode 100644 Desktop/src/components/feed/Feed.js create mode 100644 Desktop/src/components/home/App.css create mode 100644 Desktop/src/components/home/App.js create mode 100644 Desktop/src/components/logo/Logo.css create mode 100644 Desktop/src/components/logo/Logo.js create mode 100644 Desktop/src/components/notFound/NotFound.js create mode 100644 Desktop/src/components/post/Post.css create mode 100644 Desktop/src/components/post/Post.js create mode 100644 Desktop/src/components/postPlaceholder/PostPlaceholder.css create mode 100644 Desktop/src/components/postPlaceholder/PostPlaceholder.js create mode 100644 Desktop/src/components/postsFeed/PostsFeed.css create mode 100644 Desktop/src/components/postsFeed/PostsFeed.js create mode 100644 Desktop/src/components/searchBox/SearchBox.css create mode 100644 Desktop/src/components/searchBox/SearchBox.js create mode 100644 Desktop/src/components/showMoreUsers/ShowMoreUsers.js create mode 100644 Desktop/src/components/sidebar/Sidebar.css create mode 100644 Desktop/src/components/sidebar/Sidebar.js create mode 100644 Desktop/src/components/sidebarItem/SidebarItem.css create mode 100644 Desktop/src/components/sidebarItem/SidebarItem.js create mode 100644 Desktop/src/components/suggestedUsers/SuggestedUsers.css create mode 100644 Desktop/src/components/suggestedUsers/SuggestedUsers.js create mode 100644 Desktop/src/components/userProfile/UserProfile.css create mode 100644 Desktop/src/components/userProfile/UserProfile.js create mode 100644 Desktop/src/components/userProfileHeader/UserProfileHeader.css create mode 100644 Desktop/src/components/userProfileHeader/UserProfileHeader.js create mode 100644 Desktop/src/images/banner.jpg create mode 100644 Desktop/src/images/pfp.jpg create mode 100644 Desktop/src/images/superalgos.png create mode 100644 Desktop/src/index.css create mode 100644 Desktop/src/index.js create mode 100644 Desktop/src/reportWebVitals.js create mode 100644 Desktop/src/store/index.js create mode 100644 Desktop/src/store/slices/Example.slice.js create mode 100644 Desktop/store/index.js create mode 100644 Desktop/store/slices/Example.slice.js diff --git a/Desktop/DesktopApp.js b/Desktop/DesktopApp.js index 3a8cc7c6f..13795715d 100644 --- a/Desktop/DesktopApp.js +++ b/Desktop/DesktopApp.js @@ -70,8 +70,12 @@ exports.newDesktopApp = function newDesktopApp() { thisObject.webSocketsInterface.initialize() console.log('Desktop Client Web Sockets Interface ......................................... Listening at port ' + JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webSocketsPort) - thisObject.httpInterface = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface() - thisObject.httpInterface.initialize() + + /* TODO refactor this into something better */ + let react = require('./scripts/start'); + react.start(JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort); +/* thisObject.httpInterface = DK.projects.socialTrading.modules.httpInterface.newDesktopModulesHttpInterface() + thisObject.httpInterface.initialize()*/ console.log('Desktop Client Http Interface ................................................ Listening at port ' + JSON.parse(DK.desktopApp.p2pNetworkClient.node.config).webPort) } } diff --git a/Desktop/UI/WebApp.js b/Desktop/UI/WebApp.js index cb4b4da43..f0d6afd9d 100644 --- a/Desktop/UI/WebApp.js +++ b/Desktop/UI/WebApp.js @@ -1,3 +1,12 @@ +const reactReqs = { + + a: REQUIREJS([], () => {}), + React: require('react'), + ReactDOM: require('react-dom'), + ReactBase: require("../components/ReactBase") +} + + function newWebApp() { /* In it's current state of development, the Web App only has one module. @@ -5,7 +14,7 @@ function newWebApp() { Everything is being coded here until some structure emerges. */ let thisObject = { - messageReceived: messageReceived, + messageReceived: messageReceived, initialize: initialize, finalize: finalize } @@ -21,9 +30,10 @@ function newWebApp() { setupRootObject(UI, 'UI') setupRootObject(SA, 'SA') await UI.projects.socialTrading.modules.webSocketsWebAppClient.initialize() - loadWUserProfileTimeline() - loadWhoToFollow() - setupEventHandlers() + loadReactDom(); + // loadWUserProfileTimeline() + // loadWhoToFollow() + // setupEventHandlers() } catch (err) { console.log('[ERROR] initialize -> err.stack = ' + err.stack) } @@ -100,6 +110,15 @@ function newWebApp() { } } + async function loadReactDom() { + + reactReqs.ReactDOM.render( + reactReqs.ReactBase, + document.getElementById('root') + ); + + } + async function loadWUserProfileTimeline() { let queryMessage = { queryType: SA.projects.socialTrading.globals.queryTypes.EVENTS, @@ -163,8 +182,7 @@ function newWebApp() { postDiv.appendChild(textNode) contentDiv.appendChild(postDiv) } - } - catch (err) { + } catch (err) { console.log('[ERROR] err.stack = ' + err.stack) } } @@ -285,6 +303,7 @@ function newWebApp() { function updateTextArea() { textArea.value = "" } + break } case 'Follow Profile': { @@ -302,6 +321,7 @@ function newWebApp() { button.setAttribute("class", "profile-to-unfollow-button") button.name = 'Unfollow Profile' } + break } case 'Unfollow Profile': { @@ -319,6 +339,7 @@ function newWebApp() { button.setAttribute("class", "profile-to-follow-button") button.name = 'Follow Profile' } + break } } diff --git a/Desktop/WebServer/index.html b/Desktop/WebServer/index.html index 9b57e56e0..ab04c6658 100644 --- a/Desktop/WebServer/index.html +++ b/Desktop/WebServer/index.html @@ -4,8 +4,8 @@ Superalgos Desktop - - + + @@ -18,7 +18,9 @@ } else { top.location = self.location } - } catch (e) { console.error('CJ protection', e) } + } catch (e) { + console.error('CJ protection', e) + } try { loadSuperalgos() @@ -34,131 +36,7 @@ - -
-
- - - - - - -
- - - - - - - - - - -
LOGO
PROFILE
-
- - - - - - - -
CONTENT TITLE
-
-
- - - - - - - -
SEARCH
- - - - - - - - - - -
Who to follow
-
Show more
-
-
-
> -
-
- Placeholder -
-
- - - - - -
Profile Pic - - - - - - - - - - -
- -
Permissions
Tool Bar
-
-
-
- POST 2 -
-
- POST 3 -
-
- POST 4 -
-
- POST 5 -
-
-
+
\ No newline at end of file diff --git a/Desktop/components/ReactBase.js b/Desktop/components/ReactBase.js new file mode 100644 index 000000000..da695b918 --- /dev/null +++ b/Desktop/components/ReactBase.js @@ -0,0 +1,16 @@ +import React from 'react'; +import {Provider} from "react-redux"; +import reducers from "../store"; +import Root from "./Root"; + +const ReactBase = () => { + return ( + + + + + + ); +}; + +export default ReactBase; diff --git a/Desktop/components/Root.js b/Desktop/components/Root.js new file mode 100644 index 000000000..dd45f133c --- /dev/null +++ b/Desktop/components/Root.js @@ -0,0 +1,31 @@ +import React from 'react'; +import {BrowserRouter, Route, Routes} from 'react-router-dom'; +import App from './home/App'; +import UserProfile from "./userProfile/UserProfile"; +import NotFound from "./notFound/NotFound"; +import Feed from "./feed/Feed"; +import PostPlaceholder from "./postPlaceholder/PostPlaceholder"; + + +const Root = () => { + return ( + + + }> + }/> + }> + {/*}/>*/} + + }/> + + + } + /> + + ) +} + +export default Root; \ No newline at end of file diff --git a/Desktop/components/User/UserCard.css b/Desktop/components/User/UserCard.css new file mode 100644 index 000000000..2b98ba940 --- /dev/null +++ b/Desktop/components/User/UserCard.css @@ -0,0 +1,17 @@ +.followButton { + margin: 0.5rem; + width: 3rem; + max-height: 1.5rem; +} + +.userCard { + display: flex; + flex-direction: row; + align-items: center; + padding: 0.25rem 1rem; +} + +.avatar { + height: 3rem; + width: 3rem; +} \ No newline at end of file diff --git a/Desktop/components/User/UserCard.js b/Desktop/components/User/UserCard.js new file mode 100644 index 000000000..ed3657c2e --- /dev/null +++ b/Desktop/components/User/UserCard.js @@ -0,0 +1,30 @@ +import "./UserCard.css" +import React, {useEffect} from 'react'; +import {Button, Card, CardContent, CardMedia, Typography} from "@mui/material"; +import pic from "./../../images/superalgos.png" + +const UserCard = ({name, id,followCallback}) => { + + useEffect(() => { + console.log(`created user with id ${id}`) + }, [id]); + + return ( + + + + {name} + + + + ); +}; + +export default UserCard; diff --git a/Desktop/components/UsersSidebar/UsersSidebar.css b/Desktop/components/UsersSidebar/UsersSidebar.css new file mode 100644 index 000000000..5cd540978 --- /dev/null +++ b/Desktop/components/UsersSidebar/UsersSidebar.css @@ -0,0 +1,4 @@ +.showMore { + width: 100%; + text-align: center; +} diff --git a/Desktop/components/UsersSidebar/UsersSidebar.js b/Desktop/components/UsersSidebar/UsersSidebar.js new file mode 100644 index 000000000..afd23ed51 --- /dev/null +++ b/Desktop/components/UsersSidebar/UsersSidebar.js @@ -0,0 +1,23 @@ +import './UsersSidebar.css'; +import {Stack} from "@mui/material"; +import SearchBox from "../searchBox/SearchBox"; +import SuggestedUsers from "../suggestedUsers/SuggestedUsers"; + + +const UsersSidebar = () => { + + const showMoreCallback = () => console.log("clicked show more"); + return ( + + + + + + ); +} + +export default UsersSidebar; diff --git a/Desktop/components/feed/Feed.css b/Desktop/components/feed/Feed.css new file mode 100644 index 000000000..7724e2fb7 --- /dev/null +++ b/Desktop/components/feed/Feed.css @@ -0,0 +1,11 @@ +.feed { + width: 40rem; + height: 95vh; + overflow: auto; + -ms-overflow-style: none; /* Hide scrollbar for IE and Edge */ + scrollbar-width: none; /* Hide scrollbar for Firefox */ +} + +.feed::-webkit-scrollbar { /* Hide scrollbar for Chrome, Safari and Opera */ + display: none; +} \ No newline at end of file diff --git a/Desktop/components/feed/Feed.js b/Desktop/components/feed/Feed.js new file mode 100644 index 000000000..e731d6d2f --- /dev/null +++ b/Desktop/components/feed/Feed.js @@ -0,0 +1,14 @@ +import './Feed.css'; +import PostPlaceholder from "../postPlaceholder/PostPlaceholder"; +import PostsFeed from "../postsFeed/PostsFeed"; + +const Feed = () => { + return ( +
+ + +
+ ); +} + +export default Feed; diff --git a/Desktop/components/home/App.css b/Desktop/components/home/App.css new file mode 100644 index 000000000..a255b898a --- /dev/null +++ b/Desktop/components/home/App.css @@ -0,0 +1,7 @@ +.app { + height: 100%; +} + +.middleSection{ + width: 40rem; +} \ No newline at end of file diff --git a/Desktop/components/home/App.js b/Desktop/components/home/App.js new file mode 100644 index 000000000..156b4ae3d --- /dev/null +++ b/Desktop/components/home/App.js @@ -0,0 +1,23 @@ +import './App.css'; +import Sidebar from "../sidebar/Sidebar"; +import UsersSidebar from "../UsersSidebar/UsersSidebar"; +import {Stack} from "@mui/material"; +import {Outlet} from "react-router-dom"; + +function App() { + return ( +
+ + + + + + + +
+ ); +} + +export default App; diff --git a/Desktop/components/logo/Logo.css b/Desktop/components/logo/Logo.css new file mode 100644 index 000000000..f35b42bc0 --- /dev/null +++ b/Desktop/components/logo/Logo.css @@ -0,0 +1,10 @@ +/*noinspection CssInvalidPropertyValue*/ +.logo { + display: inline-flex; + align-items: center; + height: 3rem; + width: 100%; +} +.icon { + margin: 0 0.5rem; +} \ No newline at end of file diff --git a/Desktop/components/logo/Logo.js b/Desktop/components/logo/Logo.js new file mode 100644 index 000000000..dcf4ba457 --- /dev/null +++ b/Desktop/components/logo/Logo.js @@ -0,0 +1,17 @@ +import './Logo.css'; +import React from 'react'; +import {Avatar, Stack} from "@mui/material"; +import pic from "./../../images/superalgos.png" + + +const Logo = props => { + /* TODO add on click redirect to / */ + return ( + + +
SuperAlgos
+
+ ); +}; + +export default Logo; diff --git a/Desktop/components/notFound/NotFound.js b/Desktop/components/notFound/NotFound.js new file mode 100644 index 000000000..fc3b64a78 --- /dev/null +++ b/Desktop/components/notFound/NotFound.js @@ -0,0 +1,10 @@ +import React, {useEffect} from 'react'; +import {useNavigate} from "react-router-dom"; + +const NotFound = () => { + let navigate = useNavigate(); + useEffect(() => navigate("/"), [navigate]) + return null; +}; + +export default NotFound; diff --git a/Desktop/components/post/Post.css b/Desktop/components/post/Post.css new file mode 100644 index 000000000..cc9b51675 --- /dev/null +++ b/Desktop/components/post/Post.css @@ -0,0 +1,32 @@ +.post { + min-width: 5rem; /* todo needs to set a minimum width, but overriding from parent*/ + max-width: 100%; + min-height: 5rem; /* todo needs tbd. needed actually? */ + max-height: 100%; /* todo need to be 8rem, but is collapsing without scroll. need fix*/ + padding: 0.5rem; +} + +.postAvatarContainer { + display: flex; + justify-content: center; + align-items: center; + width: 3rem; + height: 3rem; +} +.postBody { + height: 12.5rem; + padding-left: 2.8rem; +} + +.postUserName { + padding: 0.75rem; + justify-content: center; + align-items: center; +} + +.postFooter { + justify-content: space-evenly; + padding: 0.15rem; + width: 100%; + display: flex; +} diff --git a/Desktop/components/post/Post.js b/Desktop/components/post/Post.js new file mode 100644 index 000000000..15096d30b --- /dev/null +++ b/Desktop/components/post/Post.js @@ -0,0 +1,62 @@ +import "./Post.css" +import React from 'react'; +import {Avatar, Card, IconButton, Stack} from "@mui/material"; +import {Autorenew, ThumbDown, ThumbUp} from "@mui/icons-material"; +import pic from "./../../images/superalgos.png" + +const Post = () => { + + const userName = "User Name", + postBody = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; + + function onButtonClick() { + console.log("Clicked the button"); + } + + return ( + + + + + + + {/*use props or local variables*/} + {userName} + + + + + + {/*use props or local variables*/} + {postBody} + + + {/* footer (buttons: like/dislike, repost) */} + { /* TODO remove unnecessary arrow function*/ + onButtonClick() + }} + > + + + {/* TODO remove unnecessary arrow function*/ + + onButtonClick() + }} + > + + + {/* TODO remove unnecessary arrow function*/ + onButtonClick() + }} + > + + + + + ); +}; + +export default Post; diff --git a/Desktop/components/postPlaceholder/PostPlaceholder.css b/Desktop/components/postPlaceholder/PostPlaceholder.css new file mode 100644 index 000000000..eab70d064 --- /dev/null +++ b/Desktop/components/postPlaceholder/PostPlaceholder.css @@ -0,0 +1,47 @@ +.postPlaceholder { + width: 40rem; + padding: 0.5rem; +} + +.postPlaceholderContainer { + min-width: 100%; + max-width: 100%; +} + +.postPlaceholderInputBoxContainer { + +} + +.postPlaceholderAvatar { + display: flex; + justify-content: center; + align-items: center; + width: 3rem; + height: 3rem; +} + +.postPlaceholderTextField { + width: 90%; + border: 5px; +} + +.postPlaceholderInputBox { + width: auto; + padding: 0.5rem; +} + +.postFeedAccountCircle { + +} + +.postPlaceholderButtonStyle { + padding: 0.75rem; + display: flex; + width: auto; + justify-content: flex-end; +} + +.postPlaceholderButton { + height: 1.5rem; + width: 5rem; +} diff --git a/Desktop/components/postPlaceholder/PostPlaceholder.js b/Desktop/components/postPlaceholder/PostPlaceholder.js new file mode 100644 index 000000000..181ec65e9 --- /dev/null +++ b/Desktop/components/postPlaceholder/PostPlaceholder.js @@ -0,0 +1,54 @@ +import "./PostPlaceholder.css" +import React from 'react'; +import {Avatar, Button, Card, Stack, TextField, Typography} from "@mui/material"; +import pic from "./../../images/superalgos.png" + +const PostPlaceholder = () => { + + function onButtonClick() { + console.log("Clicked Post button"); + } + + return ( +
+

Posts

+
+ + + + + + + + + + + + + + + +
+
+ ); +}; + +export default PostPlaceholder; diff --git a/Desktop/components/postsFeed/PostsFeed.css b/Desktop/components/postsFeed/PostsFeed.css new file mode 100644 index 000000000..87203bb43 --- /dev/null +++ b/Desktop/components/postsFeed/PostsFeed.css @@ -0,0 +1,4 @@ +.postFeedContainer { + padding: 0.5rem ; + width: 100%; +} diff --git a/Desktop/components/postsFeed/PostsFeed.js b/Desktop/components/postsFeed/PostsFeed.js new file mode 100644 index 000000000..5eb3bcf30 --- /dev/null +++ b/Desktop/components/postsFeed/PostsFeed.js @@ -0,0 +1,26 @@ +import './PostsFeed.css'; +import React from 'react'; +import {Stack} from "@mui/material"; +import Post from "../post/Post"; + +const PostsFeed = () => { + const postFeed = [1, 2, 3, 4, 5]; + + const posts = postFeed.map( + value => { + return + } + ) + + return ( +
{/* todo margin appearing to the right of the div */} + + + {posts} + +
+ ); +}; + +export default PostsFeed; \ No newline at end of file diff --git a/Desktop/components/searchBox/SearchBox.css b/Desktop/components/searchBox/SearchBox.css new file mode 100644 index 000000000..21b5110d5 --- /dev/null +++ b/Desktop/components/searchBox/SearchBox.css @@ -0,0 +1,3 @@ +.searchIcon { + margin: 1rem 0.5rem; +} \ No newline at end of file diff --git a/Desktop/components/searchBox/SearchBox.js b/Desktop/components/searchBox/SearchBox.js new file mode 100644 index 000000000..2d64998f8 --- /dev/null +++ b/Desktop/components/searchBox/SearchBox.js @@ -0,0 +1,16 @@ +import React from 'react'; +import {Box, TextField} from "@mui/material"; +import {Search} from "@mui/icons-material"; + +const SearchBox = () => { + return ( +
+ + + + +
+ ); +}; + +export default SearchBox; diff --git a/Desktop/components/showMoreUsers/ShowMoreUsers.js b/Desktop/components/showMoreUsers/ShowMoreUsers.js new file mode 100644 index 000000000..ccf4128a5 --- /dev/null +++ b/Desktop/components/showMoreUsers/ShowMoreUsers.js @@ -0,0 +1,16 @@ +import React from 'react'; +import {Link} from "@mui/material"; + +const ShowMoreUsers = ({showMoreCallback}) => { + return ( + + Show more + + ); +}; + + +export default ShowMoreUsers; \ No newline at end of file diff --git a/Desktop/components/sidebar/Sidebar.css b/Desktop/components/sidebar/Sidebar.css new file mode 100644 index 000000000..0f6fac6c2 --- /dev/null +++ b/Desktop/components/sidebar/Sidebar.css @@ -0,0 +1,3 @@ +.sidebar{ + height: 100%; +} \ No newline at end of file diff --git a/Desktop/components/sidebar/Sidebar.js b/Desktop/components/sidebar/Sidebar.js new file mode 100644 index 000000000..63a9bcbe9 --- /dev/null +++ b/Desktop/components/sidebar/Sidebar.js @@ -0,0 +1,42 @@ +import './Sidebar.css'; +import {Divider, Stack} from "@mui/material"; +import SidebarItem from "../sidebarItem/SidebarItem"; +import Logo from "../logo/Logo"; +import HomeIcon from '@mui/icons-material/Home'; +import PostAddIcon from '@mui/icons-material/PostAdd'; +import PersonIcon from '@mui/icons-material/Person'; + +const Sidebar = props => { + const menuOptions = [{name: "Home", icon: HomeIcon}, + {name: "Profile", icon: PersonIcon}, + {name: "Post", icon: PostAddIcon} + /*, "Explore", "Notifications", "Messages", "Bookmarks", "Lists", "More"*/] + + const menuItems = menuOptions.map(option => { + return + }) + + return ( +
+ + + }> + {menuItems} + + + + +
+ ); +} + +export default Sidebar; diff --git a/Desktop/components/sidebarItem/SidebarItem.css b/Desktop/components/sidebarItem/SidebarItem.css new file mode 100644 index 000000000..66d219931 --- /dev/null +++ b/Desktop/components/sidebarItem/SidebarItem.css @@ -0,0 +1,21 @@ + +.sidebarItem { + /*TODO add on hover*/ + /*TODO add breakpoints*/ + width: 15vw; +} + + +.sidebarText { + /*TODO hide when too small*/ + + width: auto; + text-align: center; +} + +.sidebarIcon { + width: auto; + padding: 0 1rem; + +} + diff --git a/Desktop/components/sidebarItem/SidebarItem.js b/Desktop/components/sidebarItem/SidebarItem.js new file mode 100644 index 000000000..40cf0bc6e --- /dev/null +++ b/Desktop/components/sidebarItem/SidebarItem.js @@ -0,0 +1,22 @@ +import './SidebarItem.css'; +import {Stack} from "@mui/material"; +import {useNavigate} from "react-router-dom"; + + +const SidebarItem = ({value, Icon}) => { + let navigate = useNavigate(); + const handleClick = () => { + navigate(`/${value}`) + } + + return ( +
+ + +
{value}
+
+
+ ); +} + +export default SidebarItem; diff --git a/Desktop/components/suggestedUsers/SuggestedUsers.css b/Desktop/components/suggestedUsers/SuggestedUsers.css new file mode 100644 index 000000000..e69de29bb diff --git a/Desktop/components/suggestedUsers/SuggestedUsers.js b/Desktop/components/suggestedUsers/SuggestedUsers.js new file mode 100644 index 000000000..e2cde9d4b --- /dev/null +++ b/Desktop/components/suggestedUsers/SuggestedUsers.js @@ -0,0 +1,32 @@ +import "./SuggestedUsers.css" +import React, {useEffect} from 'react'; +import UserCard from "../User/UserCard"; +import ShowMoreUsers from "../showMoreUsers/ShowMoreUsers"; +import {Stack} from "@mui/material"; + + +const SuggestedUsers = ({showMoreCallback}) => { + const usersIds = [1, 2, 3, 4, 5]; + + + const users = usersIds.map(value => { + let callBack = () => console.log(`Clicked follow on user${value}`); + return + }) + + useEffect(() => { + console.log("SuggestedUsersConstructor called") + }, []); + + + return ( + + {users} + + + ); +}; +export default SuggestedUsers; diff --git a/Desktop/components/userProfile/UserProfile.css b/Desktop/components/userProfile/UserProfile.css new file mode 100644 index 000000000..1ff38e5f2 --- /dev/null +++ b/Desktop/components/userProfile/UserProfile.css @@ -0,0 +1,41 @@ +.userSection { + margin-top: 50px; +} + +.banner { + height: 10rem; +} + +.profileAvatar { + height: 7rem !important; + width: 7rem !important; + border-radius: 50%; +} + +.profilePicBG { + display: flex; + align-items: center; + justify-content: center; + background: none no-repeat scroll 0 0 #fff; + position: relative; + height: 8rem !important; + width: 8rem !important; + border-radius: 50%; +} + +.profileCard { + margin-top: -50px; + display: flex; + flex-direction: row; + height: 8rem; +} + +.profileSection { + width: 100%; + overflow: initial !important; /* TODO check this is needed */ + height: 15rem; +} + +.middleSection { + width: 40rem; +} \ No newline at end of file diff --git a/Desktop/components/userProfile/UserProfile.js b/Desktop/components/userProfile/UserProfile.js new file mode 100644 index 000000000..d6ba38d64 --- /dev/null +++ b/Desktop/components/userProfile/UserProfile.js @@ -0,0 +1,28 @@ +import "./UserProfile.css" +import React from 'react'; +import UserProfileHeader from "../userProfileHeader/UserProfileHeader"; +import {Stack} from "@mui/material"; +import PostsFeed from "../postsFeed/PostsFeed"; + + +const UserProfile = () => { + + /*TODO finish this shit*/ + + let actualUser = 'Loui Molina'; + + return ( + + + + + + ); +}; + + +export default UserProfile; diff --git a/Desktop/components/userProfileHeader/UserProfileHeader.css b/Desktop/components/userProfileHeader/UserProfileHeader.css new file mode 100644 index 000000000..e69de29bb diff --git a/Desktop/components/userProfileHeader/UserProfileHeader.js b/Desktop/components/userProfileHeader/UserProfileHeader.js new file mode 100644 index 000000000..96a06df18 --- /dev/null +++ b/Desktop/components/userProfileHeader/UserProfileHeader.js @@ -0,0 +1,30 @@ +import React from 'react'; +import {Card, CardContent, CardMedia, Typography} from "@mui/material"; +import banner from "../../images/banner.jpg"; +import pfp from "../../images/pfp.png"; + +const UserProfileHeader = ({actualUser}) => { + return ( + + +
+
+ +
+ + {actualUser} + +
+
+ ); +}; + +export default UserProfileHeader; diff --git a/Desktop/config/env.js b/Desktop/config/env.js new file mode 100644 index 000000000..cecdd1e46 --- /dev/null +++ b/Desktop/config/env.js @@ -0,0 +1,106 @@ + + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); + +// Make sure that including paths.js after env.js will read .env variables. +delete require.cache[require.resolve('./paths')]; + +const NODE_ENV = process.env.NODE_ENV; +if (!NODE_ENV) { + throw new Error( + 'The NODE_ENV environment variable is required but was not specified.' + ); +} + +// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use +const dotenvFiles = [ + `${paths.dotenv}.${NODE_ENV}.local`, + // Don't include `.env.local` for `test` environment + // since normally you expect tests to produce the same + // results for everyone + NODE_ENV !== 'test' && `${paths.dotenv}.local`, + `${paths.dotenv}.${NODE_ENV}`, + paths.dotenv, +].filter(Boolean); + +// Load environment variables from .env* files. Suppress warnings using silent +// if this file is missing. dotenv will never modify any environment variables +// that have already been set. Variable expansion is supported in .env files. +// https://github.com/motdotla/dotenv +// https://github.com/motdotla/dotenv-expand +dotenvFiles.forEach(dotenvFile => { + if (fs.existsSync(dotenvFile)) { + require('dotenv-expand')( + require('dotenv').config({ + path: dotenvFile, + }) + ); + } +}); + +// We support resolving modules according to `NODE_PATH`. +// This lets you use absolute paths in imports inside large monorepos: +// https://github.com/facebook/create-react-app/issues/253. +// It works similar to `NODE_PATH` in Node itself: +// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders +// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored. +// Otherwise, we risk importing Node.js core modules into an app instead of webpack shims. +// https://github.com/facebook/create-react-app/issues/1023#issuecomment-265344421 +// We also resolve them to make sure all tools using them work consistently. +const appDirectory = fs.realpathSync(process.cwd()); +process.env.NODE_PATH = (process.env.NODE_PATH || '') + .split(path.delimiter) + .filter(folder => folder && !path.isAbsolute(folder)) + .map(folder => path.resolve(appDirectory, folder)) + .join(path.delimiter); + +// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be +// injected into the application via DefinePlugin in webpack configuration. +const REACT_APP = /^REACT_APP_/i; + +function getClientEnvironment(publicUrl) { + const raw = Object.keys(process.env) + .filter(key => REACT_APP.test(key)) + .reduce( + (env, key) => { + env[key] = process.env[key]; + return env; + }, + { + // Useful for determining whether we’re running in production mode. + // Most importantly, it switches React into the correct mode. + NODE_ENV: process.env.NODE_ENV || 'development', + // Useful for resolving the correct path to static assets in `public`. + // For example, . + // This should only be used as an escape hatch. Normally you would put + // images into the `src` and `import` them in code to get their paths. + PUBLIC_URL: publicUrl, + // We support configuring the sockjs pathname during development. + // These settings let a developer run multiple simultaneous projects. + // They are used as the connection `hostname`, `pathname` and `port` + // in webpackHotDevClient. They are used as the `sockHost`, `sockPath` + // and `sockPort` options in webpack-dev-server. + WDS_SOCKET_HOST: process.env.WDS_SOCKET_HOST, + WDS_SOCKET_PATH: process.env.WDS_SOCKET_PATH, + WDS_SOCKET_PORT: process.env.WDS_SOCKET_PORT, + // Whether or not react-refresh is enabled. + // react-refresh is not 100% stable at this time, + // which is why it's disabled by default. + // It is defined here so it is available in the webpackHotDevClient. + FAST_REFRESH: process.env.FAST_REFRESH !== 'false', + } + ); + // Stringify all values so we can feed into webpack DefinePlugin + const stringified = { + 'process.env': Object.keys(raw).reduce((env, key) => { + env[key] = JSON.stringify(raw[key]); + return env; + }, {}), + }; + + return { raw, stringified }; +} + +module.exports = getClientEnvironment; diff --git a/Desktop/config/getHttpsConfig.js b/Desktop/config/getHttpsConfig.js new file mode 100644 index 000000000..831426f3e --- /dev/null +++ b/Desktop/config/getHttpsConfig.js @@ -0,0 +1,66 @@ + + +const fs = require('fs'); +const path = require('path'); +const crypto = require('crypto'); +const chalk = require('react-dev-utils/chalk'); +const paths = require('./paths'); + +// Ensure the certificate and key provided are valid and if not +// throw an easy to debug error +function validateKeyAndCerts({ cert, key, keyFile, crtFile }) { + let encrypted; + try { + // publicEncrypt will throw an error with an invalid cert + encrypted = crypto.publicEncrypt(cert, Buffer.from('test')); + } catch (err) { + throw new Error( + `The certificate "${chalk.yellow(crtFile)}" is invalid.\n${err.message}` + ); + } + + try { + // privateDecrypt will throw an error with an invalid key + crypto.privateDecrypt(key, encrypted); + } catch (err) { + throw new Error( + `The certificate key "${chalk.yellow(keyFile)}" is invalid.\n${ + err.message + }` + ); + } +} + +// Read file and throw an error if it doesn't exist +function readEnvFile(file, type) { + if (!fs.existsSync(file)) { + throw new Error( + `You specified ${chalk.cyan( + type + )} in your env, but the file "${chalk.yellow(file)}" can't be found.` + ); + } + return fs.readFileSync(file); +} + +// Get the https config +// Return cert files if provided in env, otherwise just true or false +function getHttpsConfig() { + const { SSL_CRT_FILE, SSL_KEY_FILE, HTTPS } = process.env; + const isHttps = HTTPS === 'true'; + + if (isHttps && SSL_CRT_FILE && SSL_KEY_FILE) { + const crtFile = path.resolve(paths.appPath, SSL_CRT_FILE); + const keyFile = path.resolve(paths.appPath, SSL_KEY_FILE); + const config = { + cert: readEnvFile(crtFile, 'SSL_CRT_FILE'), + key: readEnvFile(keyFile, 'SSL_KEY_FILE'), + }; + + validateKeyAndCerts({ ...config, keyFile, crtFile }); + return config; + } + return isHttps; +} + +module.exports = getHttpsConfig; diff --git a/Desktop/config/modules.js b/Desktop/config/modules.js new file mode 100644 index 000000000..52da19ac2 --- /dev/null +++ b/Desktop/config/modules.js @@ -0,0 +1,134 @@ + + +const fs = require('fs'); +const path = require('path'); +const paths = require('./paths'); +const chalk = require('react-dev-utils/chalk'); +const resolve = require('resolve'); + +/** + * Get additional module paths based on the baseUrl of a compilerOptions object. + * + * @param {Object} options + */ +function getAdditionalModulePaths(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return ''; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + // We don't need to do anything if `baseUrl` is set to `node_modules`. This is + // the default behavior. + if (path.relative(paths.appNodeModules, baseUrlResolved) === '') { + return null; + } + + // Allow the user set the `baseUrl` to `appSrc`. + if (path.relative(paths.appSrc, baseUrlResolved) === '') { + return [paths.appSrc]; + } + + // If the path is equal to the root directory we ignore it here. + // We don't want to allow importing from the root directly as source files are + // not transpiled outside of `src`. We do allow importing them with the + // absolute path (e.g. `src/Components/Button.js`) but we set that up with + // an alias. + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return null; + } + + // Otherwise, throw an error. + throw new Error( + chalk.red.bold( + "Your project's `baseUrl` can only be set to `src` or `node_modules`." + + ' Create React App does not support other values at this time.' + ) + ); +} + +/** + * Get webpack aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getWebpackAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + src: paths.appSrc, + }; + } +} + +/** + * Get jest aliases based on the baseUrl of a compilerOptions object. + * + * @param {*} options + */ +function getJestAliases(options = {}) { + const baseUrl = options.baseUrl; + + if (!baseUrl) { + return {}; + } + + const baseUrlResolved = path.resolve(paths.appPath, baseUrl); + + if (path.relative(paths.appPath, baseUrlResolved) === '') { + return { + '^src/(.*)$': '/src/$1', + }; + } +} + +function getModules() { + // Check if TypeScript is setup + const hasTsConfig = fs.existsSync(paths.appTsConfig); + const hasJsConfig = fs.existsSync(paths.appJsConfig); + + if (hasTsConfig && hasJsConfig) { + throw new Error( + 'You have both a tsconfig.json and a jsconfig.json. If you are using TypeScript please remove your jsconfig.json file.' + ); + } + + let config; + + // If there's a tsconfig.json we assume it's a + // TypeScript project and set up the config + // based on tsconfig.json + if (hasTsConfig) { + const ts = require(resolve.sync('typescript', { + basedir: paths.appNodeModules, + })); + config = ts.readConfigFile(paths.appTsConfig, ts.sys.readFile).config; + // Otherwise we'll check if there is jsconfig.json + // for non TS projects. + } else if (hasJsConfig) { + config = require(paths.appJsConfig); + } + + config = config || {}; + const options = config.compilerOptions || {}; + + const additionalModulePaths = getAdditionalModulePaths(options); + + return { + additionalModulePaths: additionalModulePaths, + webpackAliases: getWebpackAliases(options), + jestAliases: getJestAliases(options), + hasTsConfig, + }; +} + +module.exports = getModules(); diff --git a/Desktop/config/paths.js b/Desktop/config/paths.js new file mode 100644 index 000000000..fa9e0bf67 --- /dev/null +++ b/Desktop/config/paths.js @@ -0,0 +1,76 @@ + + +const path = require('path'); +const fs = require('fs'); +const getPublicUrlOrPath = require('react-dev-utils/getPublicUrlOrPath'); +const {appPublic} = require("./paths"); + +// Make sure any symlinks in the project folder are resolved: +// https://github.com/facebook/create-react-app/issues/637 +const appDirectory = fs.realpathSync(process.cwd()); +const resolveApp = relativePath => path.resolve(appDirectory, relativePath); + +// We use `PUBLIC_URL` environment variable or "homepage" field to infer +// "public path" at which the app is served. +// webpack needs to know it to put the right