From 3bbc27274386a0cd921b708a391d55fd75dedf0b Mon Sep 17 00:00:00 2001 From: Sorrel Bri Date: Thu, 16 Jan 2020 15:21:23 -0800 Subject: [PATCH] stub styling of side and main content --- .../public/stylesheets/partials/_mixins.scss | 11 ++++ .../stylesheets/partials/_variables.scss | 17 +++++ play-node-go/src/App.js | 64 ++++++++----------- play-node-go/src/components/Login/Login.js | 26 +++++++- .../src/components/MainWrapper/MainWrapper.js | 49 ++++++++++++++ .../components/MainWrapper/MainWrapper.scss | 38 +++++++++++ .../src/components/Sidebar/Sidebar.js | 11 ++-- play-node-go/src/components/Signup/Signup.js | 6 +- play-node-go/src/index.scss | 43 ++++++++++++- play-node-go/src/pages/Game/GameSidebar.js | 10 --- play-node-go/src/pages/Home/Home.js | 7 +- play-node-go/src/pages/Home/HomeSidebar.js | 4 +- 12 files changed, 221 insertions(+), 65 deletions(-) create mode 100644 play-node-go/public/stylesheets/partials/_mixins.scss create mode 100644 play-node-go/public/stylesheets/partials/_variables.scss create mode 100644 play-node-go/src/components/MainWrapper/MainWrapper.js create mode 100644 play-node-go/src/components/MainWrapper/MainWrapper.scss delete mode 100644 play-node-go/src/pages/Game/GameSidebar.js diff --git a/play-node-go/public/stylesheets/partials/_mixins.scss b/play-node-go/public/stylesheets/partials/_mixins.scss new file mode 100644 index 0000000..a727465 --- /dev/null +++ b/play-node-go/public/stylesheets/partials/_mixins.scss @@ -0,0 +1,11 @@ +@mixin fullspan { + height: 100%; + width: 100%; +} + +@mixin flexAround($direction) { + display: flex; + flex-direction: $direction; + align-items: center; + justify-content: space-around; +} \ No newline at end of file diff --git a/play-node-go/public/stylesheets/partials/_variables.scss b/play-node-go/public/stylesheets/partials/_variables.scss new file mode 100644 index 0000000..e140c0e --- /dev/null +++ b/play-node-go/public/stylesheets/partials/_variables.scss @@ -0,0 +1,17 @@ +$dev-colors: ( + "a": #34dc90, + "b": #9034dc, + "c": #dc9034, + "d": #dc34dc, + "e": #34dcdc, + "f": #dcdc34 +); + +/* Responsive Design */ +$break-points: ( + "500": "only screen and (min-width: 500px)", + "570": "only screen and (min-width: 570px)", + "590": "only screen and (min-width: 590px)", + "700": "only screen and (min-width: 700px)", + "900": "only screen and (min-width: 900px)" +) \ No newline at end of file diff --git a/play-node-go/src/App.js b/play-node-go/src/App.js index 0ead4f4..8edaeda 100644 --- a/play-node-go/src/App.js +++ b/play-node-go/src/App.js @@ -6,13 +6,7 @@ import { Switch, Route, BrowserRouter as Router } from 'react-router-dom'; import socketIOClient from 'socket.io-client'; -import Sidebar from './components/Sidebar/Sidebar'; - -import Account from './pages/Account/Account'; -import Game from './pages/Game/Game'; -import Home from './pages/Home/Home'; -import News from './pages/News/News'; -import Room from './pages/Room/Room'; +import MainWrapper from './components/MainWrapper/MainWrapper'; import { stateReducer } from './reducers/stateReducer'; import { initState } from './reducers/init/stateReducer.init'; @@ -47,41 +41,35 @@ function App() { return ( -
+
+ + + + + + + + + + + + + + + + + + + + {/* Add ternary for login */} + + + +

React Boilerplate

{fetchData ?

{fetchData}

: <>} {socketData ?

{socketData}

: <>} {error ? error.map(err =>

{err}

): <>} - - - - - - - - - - - - - - - - - - - - - - - - - - {/* Add ternary for login */} - - - -
); diff --git a/play-node-go/src/components/Login/Login.js b/play-node-go/src/components/Login/Login.js index 6da8db3..0264d17 100644 --- a/play-node-go/src/components/Login/Login.js +++ b/play-node-go/src/components/Login/Login.js @@ -1,15 +1,37 @@ import React, { useState } from 'react'; import './Login.scss'; -const Login = () => { +const Login = (props) => { const [username, setUsername] = useState(''); const [password, setPassword] = useState(''); return (
+
+ + setUsername(e.target.value)} + default="username" + /> + + + setPassword(e.target.value)} + default="" + /> + + + +
); } - + export default Login; \ No newline at end of file diff --git a/play-node-go/src/components/MainWrapper/MainWrapper.js b/play-node-go/src/components/MainWrapper/MainWrapper.js new file mode 100644 index 0000000..37ca5b7 --- /dev/null +++ b/play-node-go/src/components/MainWrapper/MainWrapper.js @@ -0,0 +1,49 @@ +import React, { useState } from 'react'; +import './MainWrapper.scss'; + +import Sidebar from '../Sidebar/Sidebar'; +import Account from '../../pages/Account/Account'; +import Game from '../../pages/Game/Game'; +import Home from '../../pages/Home/Home'; +import News from '../../pages/News/News'; +import Room from '../../pages/Room/Room'; + +const MainWrapper = (props) => { + + const setWrapperWithSidebarAndPage = props => { + if (props.page === 'game') return selectPage(props) + return ( +
+ +
+ {selectPage(props)} +
+
+ ) + } + + const selectPage = props =>{ + switch (props.page) { + case 'account': + return + case 'game': + return + case 'home': + return + case 'news': + return + case 'room': + return + default: + return <> + } + } + + return ( + <> + { setWrapperWithSidebarAndPage(props) } + + ); +} + +export default MainWrapper; \ No newline at end of file diff --git a/play-node-go/src/components/MainWrapper/MainWrapper.scss b/play-node-go/src/components/MainWrapper/MainWrapper.scss new file mode 100644 index 0000000..2f4d07c --- /dev/null +++ b/play-node-go/src/components/MainWrapper/MainWrapper.scss @@ -0,0 +1,38 @@ +@import '../../../public/stylesheets/partials/mixins'; + +div.main-wrapper { + display: flex; + justify-content: flex-start; + @include fullspan; + + aside { + display: flex; + flex-direction: column; + flex-grow: 1; + a { + display: block; + } + } + + main { + display: flex; + justify-content: center; + align-items: center; + flex-grow: 4; + } +} + +div.Game { + display: flex; + justify-content: space-between; + @include fullspan; + aside { + @include flexAround(column); + flex-grow: 1; + } + + div.game-area { + @include flexAround(column); + flex-grow: 2; + } +} \ No newline at end of file diff --git a/play-node-go/src/components/Sidebar/Sidebar.js b/play-node-go/src/components/Sidebar/Sidebar.js index 30b3df1..8fd7bbd 100644 --- a/play-node-go/src/components/Sidebar/Sidebar.js +++ b/play-node-go/src/components/Sidebar/Sidebar.js @@ -2,7 +2,6 @@ import React, { useState } from 'react'; import './Sidebar.scss'; import AccountSidebar from '../../pages/Account/AccountSidebar'; -import GameSidebar from '../../pages/Game/GameSidebar'; import HomeSidebar from '../../pages/Home/HomeSidebar'; import NewsSidebar from '../../pages/News/NewsSidebar'; import RoomSidebar from '../../pages/Room/RoomSidebar'; @@ -12,15 +11,13 @@ const Sidebar = (props) => { const displayComponent = props =>{ switch (props.page) { case 'account': - return - case 'game': - return + return case 'home': - return + return case 'news': - return + return case 'room': - return + return default: return <> } diff --git a/play-node-go/src/components/Signup/Signup.js b/play-node-go/src/components/Signup/Signup.js index b1bccb8..f6a6361 100644 --- a/play-node-go/src/components/Signup/Signup.js +++ b/play-node-go/src/components/Signup/Signup.js @@ -1,7 +1,7 @@ import React, { useState } from 'react'; import './Signup.scss'; -const Signup = () => { +const Signup = (props) => { const [ username, setUsername ] = useState(''); const [ password, setPassword ] = useState(''); const [ confirmPassword, setConfirmPassword ] = useState(''); @@ -28,7 +28,7 @@ const Signup = () => { default="" /> - + { default="" /> + +
); diff --git a/play-node-go/src/index.scss b/play-node-go/src/index.scss index abe6d10..066e123 100644 --- a/play-node-go/src/index.scss +++ b/play-node-go/src/index.scss @@ -1,7 +1,46 @@ -* { - box-sizing: border-box; +@import '../public/stylesheets/partials/_variables'; +@import '../public/stylesheets/partials/_mixins'; + +html * { + margin: 0; + + @media #{map-get($break-points, "500")} { + font-size: 14px; + } } body { margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + box-sizing: border-box; + height: 100vh; + width: 100vw; + + div#root { + @include fullspan; + } + + div.App { + @include fullspan; + // ! dev settings + background-color: map-get($dev-colors, "f"); + } + + // ! dev settings + aside { + background-color: map-get($dev-colors, "e"); + } + + main { + background-color: map-get($dev-colors, "d"); + } +} + +code { + font-family: source-code-pro, Menlo, Monaco, Consolas, "Courier New", + monospace; } diff --git a/play-node-go/src/pages/Game/GameSidebar.js b/play-node-go/src/pages/Game/GameSidebar.js deleted file mode 100644 index a0d38fa..0000000 --- a/play-node-go/src/pages/Game/GameSidebar.js +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; - -const GameSidebar = () => { - return ( - <> - - ); -} - -export default GameSidebar; \ No newline at end of file diff --git a/play-node-go/src/pages/Home/Home.js b/play-node-go/src/pages/Home/Home.js index 4bebd90..139e770 100644 --- a/play-node-go/src/pages/Home/Home.js +++ b/play-node-go/src/pages/Home/Home.js @@ -3,8 +3,11 @@ import './Home.scss'; const Home = () => { return ( -
-

Home

+
+ +
+

Home

+
); } diff --git a/play-node-go/src/pages/Home/HomeSidebar.js b/play-node-go/src/pages/Home/HomeSidebar.js index cad7d11..3679643 100644 --- a/play-node-go/src/pages/Home/HomeSidebar.js +++ b/play-node-go/src/pages/Home/HomeSidebar.js @@ -10,10 +10,10 @@ const HomeSidebar = (props) => { ); }