32 lines
1.1 KiB
TypeScript
Raw Normal View History

2020-06-08 16:54:53 +08:00
import * as React from "react"
import { Card } from "./card"
2020-06-10 17:06:10 +08:00
import CardInfo from "./info"
2020-07-23 11:53:37 +08:00
import Highlights from "./highlights"
2020-08-24 13:32:34 +08:00
import { ViewConfigs } from "../../schema-types"
2020-06-08 16:54:53 +08:00
2020-07-01 11:38:25 +08:00
const className = (props: Card.Props) => {
2020-07-17 13:01:29 +08:00
let cn = ["card", "list-card"]
2020-07-01 11:38:25 +08:00
if (props.item.hidden) cn.push("hidden")
return cn.join(" ")
2020-06-08 16:54:53 +08:00
}
2020-07-01 11:38:25 +08:00
const ListCard: React.FunctionComponent<Card.Props> = (props) => (
<div
className={className(props)}
2020-07-23 11:53:37 +08:00
{...Card.bindEventsToProps(props)}
2020-07-01 11:38:25 +08:00
data-iid={props.item._id}
data-is-focusable>
2020-08-24 13:32:34 +08:00
{props.item.thumb && (props.viewConfigs & ViewConfigs.ShowCover) ? (
2020-07-01 11:38:25 +08:00
<div className="head"><img src={props.item.thumb} /></div>
) : null}
<div className="data">
<CardInfo source={props.source} item={props.item} />
2020-08-10 12:17:37 +08:00
<h3 className="title"><Highlights text={props.item.title} filter={props.filter} title /></h3>
2020-08-24 13:32:34 +08:00
{Boolean(props.viewConfigs & ViewConfigs.ShowSnippet) && (
<p className="snippet"><Highlights text={props.item.snippet} filter={props.filter} /></p>
)}
2020-07-01 11:38:25 +08:00
</div>
</div>
)
2020-06-08 16:54:53 +08:00
export default ListCard