-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLessThanThree.jsx
64 lines (60 loc) · 1.74 KB
/
LessThanThree.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import React from 'react';
import styled from 'styled-components';
import { Link } from 'gatsby';
import { Image } from '../../../layout/element/Image';
const GridStyles = styled.section`
width: 100%;
display: grid;
grid-template-columns: 1fr 1fr;
column-gap: 2rem;
margin-bottom: 1.4rem;
`;
export const LessThanThree = ({ data, model, user, colorTop, colorBottom }) => (
<>
{data[model].length > 0 ? (
<>
<h2 className="-mb-6 text-2xl text-stone-600/80 capitalize">
{`${model}s`.toUpperCase()}
</h2>
<GridStyles>
{data[model].map((obj) => {
return (
<Link
key={obj.title}
to={`/in/${user}/${model}/${obj.slug}/`}
alt={obj.title}
>
<h2
className={`px-2 bt-2 pb-0 ${colorTop} rounded-none rounded-t-md`}
>
{obj.title.length > 24
? `${obj.title.substring(0, 24)}...`
: obj.title}
</h2>
{obj.image ? (
<figure>
<Image
image={obj.image}
addedModelName={model}
slug={user}
alt={obj.title}
/>
</figure>
) : (
``
)}
<span
className={`inline-block w-full px-2 pt-1 pb-1 text-xs ${colorBottom} rounded-none rounded-b-md`}
>
{new Date(obj.created_on).toDateString()}
</span>
</Link>
);
})}
</GridStyles>
</>
) : (
``
)}
</>
);