-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
576 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
/.idea/ | ||
coverage/ | ||
package-lock.json | ||
dist/ |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import axios from 'axios'; | ||
|
||
function getArticles(event,page=1) { | ||
|
||
axios.get('https://ah-backend-prime-staging.herokuapp.com/api/v1/articles/?format=json&page_size='+page) | ||
.then(function (response) { | ||
const articles = response.data.results; | ||
console.log(articles) | ||
return articles | ||
}) | ||
.catch(function (error) { | ||
return error | ||
}); | ||
} | ||
|
||
export default getArticles; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import React from 'react' | ||
import PropTypes from 'prop-types' | ||
import AppBar from '@material-ui/core/AppBar' | ||
import Toolbar from '@material-ui/core/Toolbar' | ||
import IconButton from '@material-ui/core/IconButton' | ||
import Typography from '@material-ui/core/Typography' | ||
import InputBase from '@material-ui/core/InputBase' | ||
import { fade } from '@material-ui/core/styles/colorManipulator' | ||
import { withStyles } from '@material-ui/core/styles' | ||
import AccountCircle from '@material-ui/icons/AccountCircle' | ||
import SearchIcon from '@material-ui/icons/Search' | ||
import { Button } from '@material-ui/core'; | ||
|
||
const styles = theme => ({ | ||
root: { | ||
width: '100%', | ||
}, | ||
grow: { | ||
flexGrow: 1, | ||
}, | ||
menu: { | ||
marginLeft: -12, | ||
marginRight: 20, | ||
}, | ||
title: { | ||
display: 'none', | ||
[theme.breakpoints.up('sm')]: { | ||
display: 'block', | ||
}, | ||
}, | ||
inputRoot: { | ||
color: 'inherit', | ||
width: '100%', | ||
}, | ||
inputInput: { | ||
paddingTop: theme.spacing.unit, | ||
paddingRight: theme.spacing.unit, | ||
paddingBottom: theme.spacing.unit, | ||
paddingLeft: theme.spacing.unit * 9, | ||
transition: theme.transitions.create('width'), | ||
width: '100%', | ||
[theme.breakpoints.up('sm')]: { | ||
width: 118, | ||
'&:focus': { | ||
width: 180, | ||
}, | ||
}, | ||
}, | ||
searchIcon: { | ||
width: theme.spacing.unit * 8, | ||
height: '100%', | ||
position: 'absolute', | ||
pointerEvents: 'none', | ||
display: 'flex', | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
|
||
search: { | ||
position: 'relative', | ||
borderRadius: theme.shape.borderRadius, | ||
backgroundColor: fade(theme.palette.common.white, 0.18), | ||
'&:hover': { | ||
backgroundColor: fade(theme.palette.common.white, 0.29), | ||
}, | ||
marginLeft: 0, | ||
width: '100%', | ||
[theme.breakpoints.up('sm')]: { | ||
marginLeft: theme.spacing.unit, | ||
width: 'auto', | ||
}, | ||
}, | ||
|
||
}); | ||
|
||
function TopAppBar(props) { | ||
const { classes } = props; | ||
return ( | ||
<div className={classes.root}> | ||
<AppBar className="topbar"> | ||
<Toolbar> | ||
<Typography className={classes.title} variant="h6" color="inherit" noWrap> | ||
Authors Haven | ||
</Typography> | ||
<div className={classes.grow} /> | ||
|
||
<div className={classes.search}> | ||
|
||
<div className={classes.searchIcon}> | ||
<SearchIcon /> | ||
</div> | ||
<InputBase | ||
placeholder="Search…" | ||
classes={{ | ||
root: classes.inputRoot, | ||
input: classes.inputInput, | ||
}} | ||
/> | ||
|
||
</div> | ||
<div> | ||
<a href="login" className="nav-links">Sign In</a> | | ||
<Button className="nav-links top-button">Get Started</Button> | ||
</div> | ||
</Toolbar> | ||
</AppBar> | ||
</div> | ||
); | ||
} | ||
|
||
TopAppBar.propTypes = { | ||
classes: PropTypes.object.isRequired, | ||
}; | ||
|
||
export default withStyles(styles)(TopAppBar); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,75 @@ | ||
import React from 'react'; | ||
import '../styles/app.scss'; | ||
|
||
const Home = () => { | ||
return ( | ||
<div> | ||
<h2>Welcome to Authors Haven</h2> | ||
</div> | ||
) | ||
import React, { Component } from 'react' | ||
import '../styles/app.scss' | ||
import axios from 'axios' | ||
import TopAppBar from "../components/header" | ||
import moment from 'moment' | ||
|
||
|
||
|
||
class Home extends Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
articles: [] | ||
} | ||
} | ||
|
||
componentDidMount(){ | ||
axios.get( | ||
'https://ah-backend-prime-staging.herokuapp.com'+ | ||
'/api/v1/articles/?format=json&page_size=1' | ||
).then(response => { | ||
this.setState({ | ||
articles: response.data.results | ||
}) | ||
}) | ||
} | ||
render(){ | ||
const articles = this.state.articles; | ||
const articleList = articles.length ? ( | ||
articles.map(article =>{ | ||
|
||
const time = moment(article.createdAt).format('HH:mm') | ||
const date = moment(article.createdAt).format('ddd D MMMM YYYY') | ||
const image = "http://allpicts.in/download/22916/2018/03/Natural_"+ | ||
"Images_HD_1080p_Download_with_Waterfall_in_Tollymore_Forest_Park-1440x900.jpg/" | ||
|
||
return ( | ||
<div className="article" key={article.id}> | ||
<div className="article-card"> | ||
<h3>{article.title}</h3> | ||
<p>{article.body.substring(0, 60)} ...</p> | ||
<span>Author: <b> {article.author.username}</b></span> | ||
<span className="card-date"> | ||
Created on {date} at {time} | ||
</span> | ||
|
||
</div> | ||
<div> | ||
<img src={image} className="img-tile" /> | ||
</div> | ||
</div> | ||
) | ||
}) | ||
) : ( | ||
<div > | ||
No Articles in Authors Haven Yet | ||
</div> | ||
) | ||
return ( | ||
<div className="big-container"> | ||
<TopAppBar /> | ||
<div className="heading"> | ||
<h1>Featured Articles</h1> | ||
</div> | ||
|
||
<div className="articles"> | ||
{articleList} | ||
</div> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
|
||
export default Home; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,83 @@ | ||
h2 { | ||
color: #1b7999; | ||
color: .1b7999; | ||
text-align: center; | ||
} | ||
div { | ||
font-family: Quantico; | ||
} | ||
.card-title{ | ||
text-align: center | ||
} | ||
.cart-author{ | ||
float: left; | ||
text-align: left | ||
} | ||
.card-content{ | ||
text-align: right | ||
} | ||
.card-date{ | ||
float: left; | ||
text-align: left; | ||
font-style: italic | ||
} | ||
.article-card{ | ||
text-align: left; | ||
float: left; | ||
width: 70%; | ||
margin: 0.5% | ||
} | ||
.big-container{ | ||
position: absolute; | ||
left: 0%; | ||
top:0%; | ||
right: 0%; | ||
text-align: center; | ||
|
||
} | ||
.links{ | ||
text-decoration: none; | ||
color: whitesmoke; | ||
} | ||
|
||
.img-tile{ | ||
float: right; | ||
width: 28%; | ||
margin: 0.5%; | ||
} | ||
.articles{ | ||
width: 100%; | ||
text-align: center; | ||
height: 100% | ||
} | ||
.heading{ | ||
width:100%; | ||
margin-top: 100px | ||
} | ||
.tile{ | ||
height: 300px | ||
} | ||
.topbar{ | ||
background-color: #003153 | ||
} | ||
.nav-links{ | ||
color: white; | ||
} | ||
.article{ | ||
width: 30%; | ||
float: left; | ||
margin:5px; | ||
} | ||
a{ | ||
text-decoration: none; | ||
margin-left: 10%; | ||
margin-right: 3%; | ||
|
||
} | ||
.top-button{ | ||
border-block-end-color: white | ||
} | ||
@media only screen and (max-width: 600px){ | ||
.article{ | ||
width: 50%; | ||
} | ||
} |
Oops, something went wrong.