[www] added ArticleCard on Home
This commit is contained in:
1 parent
047c934953
commit
d918d98b17
8 files changed
+220
-2
No files matched your search
@@ -0,0 +1,39 @@
|
||||
const React = require('react')
|
||||
const dateFormat = require('../lib/date').dateFormat
|
||||
|
||||
const Date = ({children}) => (
|
||||
<p className="date">{dateFormat(children)}</p>
|
||||
)
|
||||
|
||||
const Image = ({data, alt}) => (
|
||||
<picture>
|
||||
<img
|
||||
className="opa"
|
||||
alt={alt}
|
||||
src={data.src}
|
||||
srcSet={data.set.map(({url, density}) => `${url} ${density}x`)}
|
||||
/>
|
||||
</picture>
|
||||
)
|
||||
|
||||
const ArticleCard = ({article}) => (
|
||||
<article className="ArticleCard">
|
||||
<a className="invisible" href={article.url}>
|
||||
<div className="ArticleCard-image">
|
||||
{!article.preview ? null : (
|
||||
<Image data={article.preview} alt={article.title}/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="ArticleCard-body">
|
||||
{article.title}
|
||||
|
||||
{!article.date ? null : (
|
||||
<Date>{article.date}</Date>
|
||||
)}
|
||||
</div>
|
||||
</a>
|
||||
</article>
|
||||
)
|
||||
|
||||
module.exports = ArticleCard
|
||||
@@ -0,0 +1,26 @@
|
||||
const React = require('react')
|
||||
const Paginator = require('./Paginator')
|
||||
const ArticleCard = require('./ArticleCard')
|
||||
|
||||
const ArticleCardList = ({articles, nextPage, prevPage}) => (
|
||||
<div className="ArticleCardList">
|
||||
{!prevPage ? null : (
|
||||
<Paginator url={`/articles/${prevPage}`} type="top"/>
|
||||
)}
|
||||
|
||||
<div className="ArticleCardList-body">
|
||||
{articles.map((article, i) => (
|
||||
<ArticleCard
|
||||
key={i}
|
||||
article={article}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{!nextPage ? null : (
|
||||
<Paginator url={`/articles/${nextPage}`} type="bottom"/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
module.exports = ArticleCardList
|
||||
Reference in new issue
Block a user