article grid updated

This commit is contained in:
tmshv committed 2020-02-22 01:35:43 +03:00
1 parent 5730505fca
commit 89203b2b12
2 files changed
+36 -23

No files matched your search

+10 -7
View File
@@ -1,14 +1,17 @@
import * as React from 'react' import { dateFormat } from 'src/lib/date'
import { dateFormat } from '../../lib/date'
export const Date: React.FC<{ children: string }> = ({ children }) => ( export type DateProps = {
<p> style?: React.CSSProperties
children: string | Date
}
export const Date: React.FC<DateProps> = props => (
<p style={props.style}>
<style jsx>{` <style jsx>{`
p { p {
color: #ccc; color: var(--color-text-second);
font-size: small; font-size: var(--font-size-second);
} }
`}</style> `}</style>
{dateFormat(children)} {dateFormat(props.children)}
</p> </p>
) )
+26 -16
View File
@@ -1,16 +1,18 @@
import { IArticle } from 'src/types'
import { Pager } from '../Pager' import { Pager } from '../Pager'
import { CardGrid } from '../CardGrid' import { CardGrid } from '../CardGrid'
import { IArticle } from 'src/types'
import { Card, CardLayout } from '../Card' import { Card, CardLayout } from '../Card'
import { Date } from './Date' import { Date } from './Date'
import { Block } from '../Block'
import { Spacer } from '../Spacer'
export interface IArticleGridProps { export type ArticleGridProps = {
articles: IArticle[] articles: IArticle[]
nextPage: number | null nextPage: number | null
prevPage: number | null prevPage: number | null
} }
export const ArticleGrid: React.FC<IArticleGridProps> = ({ articles, nextPage, prevPage, ...props }) => ( export const ArticleGrid: React.FC<ArticleGridProps> = ({ articles, nextPage, prevPage, ...props }) => (
<> <>
<CardGrid <CardGrid
style={{ style={{
@@ -22,6 +24,26 @@ export const ArticleGrid: React.FC<IArticleGridProps> = ({ articles, nextPage, p
const layout: CardLayout = article.featured ? 'featured' : 'simple' const layout: CardLayout = article.featured ? 'featured' : 'simple'
const srcSet = article.preview.set.map(({ url, density }) => `${url} ${density}x`).join(' ') const srcSet = article.preview.set.map(({ url, density }) => `${url} ${density}x`).join(' ')
const content = article.featured
? (
<h2 style={{
margin: 0,
fontSize: '18pt'
}}>
{article.title}
</h2>
) : (
<Block
direction={'vertical'}
>
{article.title}
<Spacer />
<Date style={{
marginTop: 'var(--size-m)',
}}>{article.date}</Date>
</Block>
)
return ( return (
<Card <Card
key={i} key={i}
@@ -36,19 +58,7 @@ export const ArticleGrid: React.FC<IArticleGridProps> = ({ articles, nextPage, p
gridColumn, gridColumn,
}} }}
> >
<div style={{ {content}
minHeight: '5em',
}}>
<h2 style={{
// margin: '0 0 var(--size-s)',
margin: 0,
fontSize: '18pt'
}}>
{article.title}
</h2>
{/* <Date>{article.date}</Date> */}
</div>
</Card> </Card>
) )
})} })}