2019-07-09 13:29:25 +02:00
|
|
|
//@flow
|
|
|
|
|
import * as React from "react";
|
|
|
|
|
import injectSheet from "react-jss";
|
|
|
|
|
import classNames from "classnames";
|
|
|
|
|
|
|
|
|
|
import { Link } from "react-router-dom";
|
|
|
|
|
|
|
|
|
|
const styles = {
|
|
|
|
|
inner: {
|
|
|
|
|
position: "relative",
|
|
|
|
|
pointerEvents: "none",
|
|
|
|
|
zIndex: 1
|
|
|
|
|
},
|
|
|
|
|
innerLink: {
|
|
|
|
|
pointerEvents: "all"
|
|
|
|
|
},
|
|
|
|
|
centerImage: {
|
|
|
|
|
marginTop: "0.8em",
|
|
|
|
|
marginLeft: "1em !important"
|
|
|
|
|
},
|
|
|
|
|
flexFullHeight: {
|
|
|
|
|
display: "flex",
|
|
|
|
|
flexDirection: "column",
|
|
|
|
|
alignSelf: "stretch"
|
|
|
|
|
},
|
|
|
|
|
content: {
|
|
|
|
|
display: "flex",
|
2019-07-31 15:40:35 +02:00
|
|
|
flexGrow: 1,
|
|
|
|
|
alignItems: "center",
|
|
|
|
|
justifyContent: "space-between"
|
2019-07-09 13:29:25 +02:00
|
|
|
},
|
|
|
|
|
footer: {
|
|
|
|
|
display: "flex",
|
|
|
|
|
marginTop: "auto",
|
|
|
|
|
paddingBottom: "1.5rem"
|
2019-07-31 15:40:35 +02:00
|
|
|
},
|
|
|
|
|
noBottomMargin: {
|
|
|
|
|
marginBottom: "0 !important"
|
2019-07-09 13:29:25 +02:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
title: string,
|
|
|
|
|
description: string,
|
|
|
|
|
avatar: React.Node,
|
2019-07-31 15:40:35 +02:00
|
|
|
contentRight?: React.Node,
|
2019-07-09 13:29:25 +02:00
|
|
|
footerLeft: React.Node,
|
|
|
|
|
footerRight: React.Node,
|
2019-08-21 15:42:03 +02:00
|
|
|
link?: string,
|
|
|
|
|
action?: () => void,
|
2019-09-16 15:31:02 +02:00
|
|
|
className?: string,
|
2019-07-31 15:40:35 +02:00
|
|
|
|
2019-07-09 13:29:25 +02:00
|
|
|
// context props
|
|
|
|
|
classes: any
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class CardColumn extends React.Component<Props> {
|
|
|
|
|
createLink = () => {
|
2019-08-21 15:42:03 +02:00
|
|
|
const { link, action } = this.props;
|
2019-07-09 13:29:25 +02:00
|
|
|
if (link) {
|
|
|
|
|
return <Link className="overlay-column" to={link} />;
|
2019-08-21 15:42:03 +02:00
|
|
|
} else if (action) {
|
|
|
|
|
return <a className="overlay-column" onClick={e => {e.preventDefault(); action();}} href="#" />;
|
2019-07-09 13:29:25 +02:00
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
2019-07-31 15:40:35 +02:00
|
|
|
const {
|
|
|
|
|
avatar,
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
contentRight,
|
|
|
|
|
footerLeft,
|
|
|
|
|
footerRight,
|
2019-09-16 15:31:02 +02:00
|
|
|
classes,
|
|
|
|
|
className
|
2019-07-31 15:40:35 +02:00
|
|
|
} = this.props;
|
2019-07-09 13:29:25 +02:00
|
|
|
const link = this.createLink();
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{link}
|
2019-09-16 15:31:02 +02:00
|
|
|
<article className={classNames("media", className, classes.inner)}>
|
2019-07-09 13:29:25 +02:00
|
|
|
<figure className={classNames(classes.centerImage, "media-left")}>
|
|
|
|
|
{avatar}
|
|
|
|
|
</figure>
|
2019-07-31 15:40:35 +02:00
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
"media-content",
|
|
|
|
|
"text-box",
|
|
|
|
|
classes.flexFullHeight
|
|
|
|
|
)}
|
|
|
|
|
>
|
2019-07-09 13:29:25 +02:00
|
|
|
<div className={classes.content}>
|
2019-07-31 15:40:35 +02:00
|
|
|
<div
|
|
|
|
|
className={classNames(
|
|
|
|
|
"content",
|
|
|
|
|
"shorten-text",
|
|
|
|
|
classes.noBottomMargin
|
|
|
|
|
)}
|
|
|
|
|
>
|
2019-07-09 13:29:25 +02:00
|
|
|
<p className="is-marginless">
|
|
|
|
|
<strong>{title}</strong>
|
|
|
|
|
</p>
|
|
|
|
|
<p className="shorten-text">{description}</p>
|
|
|
|
|
</div>
|
2019-07-31 15:40:35 +02:00
|
|
|
{contentRight && contentRight}
|
2019-07-09 13:29:25 +02:00
|
|
|
</div>
|
2019-07-31 15:40:35 +02:00
|
|
|
<div className={classNames("level", classes.footer)}>
|
2019-07-09 13:29:25 +02:00
|
|
|
<div className="level-left is-hidden-mobile">{footerLeft}</div>
|
|
|
|
|
<div className="level-right is-mobile">{footerRight}</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</article>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default injectSheet(styles)(CardColumn);
|