-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathClickableCard.tsx
78 lines (70 loc) · 1.74 KB
/
ClickableCard.tsx
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/** @jsxImportSource @emotion/react */
import { Link } from '@datacamp/waffles/link';
import { Paragraph } from '@datacamp/waffles/paragraph';
import { theme } from '@datacamp/waffles/theme';
import { tokens } from '@datacamp/waffles/tokens';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import Html from './Html';
type Props = {
description: string;
extraInfo?: string;
href: string;
id: string | number;
name: string;
};
const clickableCardStyles = css({
borderRadius: tokens.borderRadius.medium,
borderWidth: tokens.borderWidth.medium,
color: theme.text.main,
display: 'flex',
flexDirection: 'column',
padding: '10px 12px',
textDecoration: 'none',
width: '100%',
});
const TitleWrapper = styled.div({
alignItems: 'baseline',
display: 'flex',
justifyContent: 'space-between',
width: '100%',
});
const HTMLWrapper = styled.div({
fontWeight: 'bold',
overflow: 'hidden',
textOverflow: 'ellipsis',
whiteSpace: 'nowrap',
});
const DescriptionWrapper = styled.div({
display: '-webkit-box',
fontSize: tokens.fontSizes.small,
fontWeight: 'normal',
marginTop: tokens.spacing.small,
overflow: 'hidden',
textAlign: 'left',
WebkitBoxOrient: 'vertical',
WebkitLineClamp: 3,
});
export default function ClickableCard({
description,
extraInfo,
href,
id,
name,
}: Props) {
return (
<Link css={clickableCardStyles} href={href} key={id}>
<TitleWrapper>
<HTMLWrapper>
<Html>{name}</Html>
</HTMLWrapper>
<Paragraph css={{ margin: 0 }} size="small" variant="secondary">
{extraInfo}
</Paragraph>
</TitleWrapper>
<DescriptionWrapper>
<Html>{description}</Html>
</DescriptionWrapper>
</Link>
);
}