Initial commit

This commit is contained in:
MrFry 2020-03-07 08:09:01 +01:00
commit d0a48513e9
28 changed files with 724 additions and 0 deletions

118
src/pages/Home.css Normal file
View file

@ -0,0 +1,118 @@
body {
font: normal 14px Verdana;
color: #999999;
}
.link {
margin: 20px;
font-size: 20px;
}
.sidebarLink {
color: var(--text-color);
text-decoration: none;
}
.sidebar {
margin: 0;
padding: 0;
width: 200px;
background-color: #212127;
position: fixed;
height: 100%;
overflow: auto;
}
.sidebar a {
display: block;
color: black;
padding: 16px;
text-decoration: none;
color: var(--bright-color);
}
.sidebar a.active {
background-color: var(--text-color);
color: black;
}
.sidebar a:hover:not(.active) {
background-color: #555;
color: white;
}
div.content {
margin-left: 200px;
padding: 1px 16px;
}
.menuicon div {
height: 5px;
background-color: var(--bright-color);
margin: 0px 0;
display: none;
width: 30px;
}
.sidebarheader {
font-size: 40px;
color: var(--bright-color);
display: flex;
text-align: center;
}
.headercontainer {
display: flex;
flex-direction: row;
align-items: center;
flex-wrap: nowrap;
position: relative;
margin: 10px;
}
@media screen and (max-width: 700px) {
.sidebar {
width: 100%;
height: auto;
position: relative;
}
.sidebar a {float: left;}
div.content {margin-left: 0;}
}
@media screen and (max-width: 700px) {
.menuicon div {
display: block;
margin: 6px 0;
}
.sidebar a {
text-align: center;
float: none;
}
.menuicon {
display: inline;
}
.sidebaritemsconainer {
display: inline;
}
.sidebarheader {
position: absolute;
left: 50%;
top: 50%;
transform: translateX(-50%) translateY(-50%);
}
.codecontainer {
margin-left: 0px;
margin-right: 0px;
}
.sitedescription {
width: 100%;
margin: 0 auto;
}
}

127
src/pages/Home.js Normal file
View file

@ -0,0 +1,127 @@
import React, { PureComponent } from 'react'
import AllQuestions from '../../components/AllQuestions'
import Manual from '../../components/Manual'
import HomeTab from '../../components/HomeTab'
import UserQuestions from '../../components/UserQuestions'
import Feedback from '../../components/Feedback'
import constants from '../../constants.json'
import './Home.css'
// TODO: css remove unnecesarry stuff
// TODO: home to separate component
// TODO: resizing test
// TODO: fetch data only once?
const tabs = {
home: {
text: 'Home',
component: HomeTab
},
allq: {
text: 'All questions',
component: AllQuestions
},
manual: {
text: 'Manual',
component: Manual
},
userq: {
text: 'User Questions',
component: UserQuestions
},
feedback: {
text: 'Feedback',
component: Feedback
}
}
class Home extends PureComponent {
constructor (props) {
super(props)
this.state = {
menuShowing: window.innerWidth > constants.mobileWindowWidth,
currentTab: 'home'
}
}
closeMenu () {
this.setState((oldState) => {
return {
menuShowing: !oldState.menuShowing
}
})
}
setActiveTab (name) {
this.setState({
currentTab: name
})
if (window.innerWidth < constants.mobileWindowWidth) {
this.setState({
menuShowing: false
})
}
}
renderSideBar () {
const { currentTab, menuShowing } = this.state
return (
<div className='sidebar'>
<div className='headercontainer'>
<span onClick={this.closeMenu.bind(this)} className='menuicon'>
<div />
<div />
<div />
</span>
<div className='sidebarheader' >
Frylabs
</div>
</div>
{
menuShowing
? <div className='sidebaritemsconainer'>
{Object.keys(tabs).map((key) => {
let tab = tabs[key]
return (
<a
key={key}
className={currentTab === key ? 'active' : ''}
href={'#' + key}
onClick={() => { this.setActiveTab(key) }}
>{tab.text}</a>
)
})}
</div>
: null
}
</div>
)
}
renderContents () {
const { currentTab } = this.state
let ContentComponent = tabs[currentTab].component
return (
<ContentComponent />
)
}
render () {
return (
<div>
{this.renderSideBar()}
<div className='content'>
{this.renderContents()}
</div>
</div>
)
}
}
export default Home