File size: 2,799 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//@flow

import * as React from "react";
import Card from "../Card/Card.react";
import Icon from "../Icon/Icon.react";

type Props = {|
  +children?: React.Node,
  +title?: string,
  +titleUrl?: string,
  +avatarUrl?: string,
  +description?: string,
  +date?: string,
  +imgUrl?: string,
  +iconName?: string,
  +iconHref?: string,
  +authorName?: string,
  +avatarImgSrc?: string,
  +imgSrc?: string,
  +imgAlt?: string,
  +aside?: boolean,
  +postHref?: string,
  +profileHref?: string,
|};

function BlogCard({
  children,
  title,
  description,
  avatarUrl,
  imgUrl,
  imgAlt,
  aside,
  authorName,
  date,
  imgSrc = "",
  avatarImgSrc = "",
  iconName,
  iconHref,
  postHref,
  profileHref,
}: Props): React.Node {
  return !aside ? (
    <Card>
      <a href={postHref}>
        <img className="card-img-top" src={imgSrc} alt={imgAlt} />
      </a>
      <Card.Body className="d-flex flex-column">
        <h4>
          <a href={postHref}>{title}</a>
        </h4>
        <div className="text-muted">{description}</div>
        <div className="d-flex align-items-center pt-5 mt-auto">
          <div
            className="avatar avatar-md mr-3"
            style={{ backgroundImage: `url(${avatarImgSrc}` }}
          />
          <div>
            <a href={profileHref} className="text-default">
              {authorName}
            </a>
            <small className="d-block text-muted">{date}</small>
          </div>
          <div className="ml-auto text-muted">
            <a href={iconHref} className="icon d-none d-md-inline-block ml-3">
              <Icon prefix="fe" name={iconName || "heart"} />
            </a>
          </div>
        </div>
      </Card.Body>
    </Card>
  ) : (
    <Card className="card-aside">
      <a
        href={postHref}
        className="card-aside-column"
        style={{ backgroundImage: `url(${imgSrc})` }}
      >
        {""}
      </a>
      <Card.Body className="d-flex flex-column">
        <h4>
          <a href={postHref}>{title}</a>
        </h4>
        <div className="text-muted">{description}</div>
        <div className="d-flex align-items-center pt-5 mt-auto">
          <div
            className="avatar avatar-md mr-3"
            style={{ backgroundImage: `url(${avatarImgSrc}` }}
          />
          <div>
            <a href={profileHref} className="text-default">
              {authorName}
            </a>
            <small className="d-block text-muted">{date}</small>
          </div>
          <div className="ml-auto text-red">
            <a href={iconHref} className="icon d-none d-md-inline-block ml-3">
              <Icon prefix="fe" name={iconName || "heart"} />
            </a>
          </div>
        </div>
      </Card.Body>
    </Card>
  );
}

/** @component */
export default BlogCard;