article, person cards removed; use common component

This commit is contained in:
tmshv committed 2020-02-22 00:42:55 +03:00
1 parent 13c7d473b1
commit 5730505fca
12 files changed
+92 -295

No files matched your search

-43
View File
@@ -1,43 +0,0 @@
import './styles.css'
import cx from 'classnames'
import { Date } from './Date'
import { IImage } from 'src/types'
import Link from 'next/link'
export interface IArticleCardProps {
style?: React.CSSProperties
article: any
preview?: IImage
}
export const ArticleCard: React.FC<IArticleCardProps> = ({ article, ...props }) => (
<div className="ArticleCard" style={props.style}>
<Link href={article.url}>
<a className="invisible">
<div className="ArticleCard-image">
{!props.preview ? null : (
<picture>
<img
className={cx({ opa: false })}
alt={props.preview.alt}
src={props.preview.src}
srcSet={props.preview.srcSet.map(({ url, density }) => `${url} ${density}x`).join(' ')}
/>
</picture >
)}
</div>
<div className="ArticleCard-body">
{article.title}
{!article.date ? null : (
<Date>
{article.date}
</Date>
)}
</div>
</a>
</Link>
</div>
)
-91
View File
@@ -1,91 +0,0 @@
.ArticleCard {
--article-card-image-height: 15em;
display: flex;
flex-direction: column;
border-radius: var(--radius);
box-shadow: var(--shadow);
/* box-shadow: 0 0 0 1px var(--color-shadow); */
overflow: hidden;
transition: box-shadow 150ms;
}
.ArticleCard:hover {
box-shadow: var(--shadow-active);
}
.ArticleCard > a {
display: block;
position: relative;
}
.ArticleCard-image {
overflow: hidden;
position: relative;
width: 100%;
height: var(--article-card-image-height);
}
.ArticleCard-image img {
width: 100%;
height: 100%;
object-fit: cover;
transition: all 150ms ease-out;
position: absolute;
top: 0;
left: 0;
}
.ArticleCard-body {
position: relative;
z-index: 1000;
display: flex;
flex-direction: column;
justify-content: space-between;
align-items: flex-start;
height: 5em;
background-color: white;
padding: 0 var(--size-m) var(--size-m);
}
.ArticleCard-body:before {
position: absolute;
content: '';
background-color: white;
border-radius: var(--radius) var(--radius) 0 0 ;
width: 100%;
height: var(--radius);
top: calc(var(--radius) * -1);
left: 0;
}
.ArticleCard:hover img {
width: 104%;
height: 104%;
top: -2%;
left: -2%;
}
/* Tablet */
@media screen and (min-width: var(--tablet-min-width)) and (max-width: var(--tablet-max-width)) {
.ArticleCard {
--article-card-image-height: 12em;
}
}
/* Mobile */
@media (max-width: 31.25em) {
.ArticleCard {
}
}
-46
View File
@@ -1,46 +0,0 @@
import { ArticleCard } from './ArticleCard'
import { Pager } from './Pager'
import { CardGrid } from './CardGrid'
import { IArticle } from 'src/types'
export interface IArticleCardListProps {
articles: IArticle[]
nextPage: number | null
prevPage: number | null
}
export const ArticleCardList: React.FC<IArticleCardListProps> = ({ articles, nextPage, prevPage, ...props }) => (
<>
<CardGrid
style={{
marginBottom: 'var(--size-m)',
}}
>
{articles.map((article, i) => {
const preview = {
alt: article.title,
src: article.preview.src,
srcSet: article.preview.set,
}
const gridColumn = article.featured ? 'span 2' : 'auto'
return (
<ArticleCard
key={i}
article={article}
preview={preview as any}
style={{
gridColumn
}}
/>
)
})}
</CardGrid>
<Pager
nextHref={nextPage ? `/articles/${nextPage}` : null}
prevHref={prevPage ? `/articles/${prevPage}` : null}
/>
</>
)
File renamed without changes.
+62
View File
@@ -0,0 +1,62 @@
import { Pager } from '../Pager'
import { CardGrid } from '../CardGrid'
import { IArticle } from 'src/types'
import { Card, CardLayout } from '../Card'
import { Date } from './Date'
export interface IArticleGridProps {
articles: IArticle[]
nextPage: number | null
prevPage: number | null
}
export const ArticleGrid: React.FC<IArticleGridProps> = ({ articles, nextPage, prevPage, ...props }) => (
<>
<CardGrid
style={{
marginBottom: 'var(--size-m)',
}}
>
{articles.map((article, i) => {
const gridColumn = article.featured ? 'span 2' : 'auto'
const layout: CardLayout = article.featured ? 'featured' : 'simple'
const srcSet = article.preview.set.map(({ url, density }) => `${url} ${density}x`).join(' ')
return (
<Card
key={i}
href={article.url}
img={{
alt: article.title,
src: article.preview.src,
srcSet,
}}
layout={layout}
style={{
gridColumn,
}}
>
<div style={{
minHeight: '5em',
}}>
<h2 style={{
// margin: '0 0 var(--size-s)',
margin: 0,
fontSize: '18pt'
}}>
{article.title}
</h2>
{/* <Date>{article.date}</Date> */}
</div>
</Card>
)
})}
</CardGrid>
<Pager
nextHref={nextPage ? `/articles/${nextPage}` : null}
prevHref={prevPage ? `/articles/${prevPage}` : null}
/>
</>
)
+1 -1
View File
@@ -3,7 +3,7 @@
display: grid;
/* grid-template-columns: 1fr 1fr 1fr; */
grid-template-columns: repeat(auto-fill, minmax(var(--min-cell-size), 1fr));
grid-auto-rows: 20em;
grid-auto-rows: 25em;
grid-gap: var(--size-xl) var(--size-l);
}
-29
View File
@@ -1,29 +0,0 @@
import './styles.css'
import cx from 'classnames'
import { Image } from '../Image'
export const PersonCard = ({ picture, name, url, profile }) => (
<div className={'personCard'}>
<a className={'invisible'} href={url}>
<div className={'personCard-Picture'}>
<picture>
<img
className={cx({ opa: false })}
alt={''}
src={picture.src}
srcSet={picture.set.map(({ url, density }) => `${url} ${density}x`)}
/>
</picture>
</div>
<div className={'personCard-Title'}>
{name[0]} {name[1]} {name[2]}
</div>
<div className={'personCard-Body'}>
{profile.position}
</div>
</a>
</div>
)
-72
View File
@@ -1,72 +0,0 @@
.personCard {
--person-card-height: 24em;
display: flex;
flex-direction: column;
min-width: 10em;
max-width: 30em;
}
.personCard > a {
display: block;
position: relative;
}
.personCard-Picture {
position: relative;
border-radius: var(--radius);
width: 100%;
height: var(--person-card-height);
overflow: hidden;
}
.personCard-Picture img {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
object-fit: cover;
transition: all 150ms ease-out;
}
.personCard-Title,
.personCard-Body {
position: absolute;
width: 100%;
padding: var(--single-margin);
box-sizing: border-box;
color: white;
text-align: center;
text-shadow: 0 0 3px #000;
}
.personCard-Title {
top: 0;
}
.personCard-Body {
bottom: 0;
}
.personCard:hover img {
width: 105%;
height: 105%;
top: -2.5%;
left: -2.5%;
}
/* Tablet */
@media screen and (min-width: var(--tablet-min-width)) and (max-width: var(--tablet-max-width)) {
.personCard {
--person-card-height: 20em;
}
@media screen and (orientation: portrait) {
}
}