-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
ReferredBlock.js
51 lines (47 loc) · 1.4 KB
/
ReferredBlock.js
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
/** @jsx jsx */
import React from 'react';
import { LinkToStacked } from './CustomLinkToStacked';
import { Link } from 'gatsby';
import { Styled, jsx, Heading } from 'theme-ui';
import useWindowWidth from '../utils/useWindowWidth';
export default ({ references }) => {
const [width] = useWindowWidth();
if (references.length > 0) {
const RefLink = width < 768 ? Link : LinkToStacked;
return (
<>
<Heading as="h4" color="text-light">
Referred in
</Heading>
<div sx={{ mb: 2 }}>
{references.map((reference) => {
return (
<RefLink
sx={{
textDecoration: 'none',
color: 'text-light',
':hover': {
color: 'text',
},
}}
to={`/${reference.slug}`}
key={reference.slug}
>
<div sx={{ py: 2 }}>
<Styled.p sx={{ fontSize: 2, m: 0, color: 'text-light' }}>
{reference.title}
</Styled.p>
<Styled.p sx={{ fontSize: 1, m: 0, color: 'text-light' }}>
{reference.childMdx.excerpt}
</Styled.p>
</div>
</RefLink>
);
})}
</div>
<hr sx={{ mx: 'auto', width: 64 }} />
</>
);
}
return null;
};