-
Notifications
You must be signed in to change notification settings - Fork 0
/
DefaultItem.tsx
50 lines (46 loc) · 1.66 KB
/
DefaultItem.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
import React from 'react'
interface Props {
item: any
margin: number
sortKey: string | null
}
const Item = (props: Props) => {
const item = props.item
const fontSize = (props.item.width - props.margin) / 14
const sortKeySize = props.item.height / 7
return (<a href={'https://calil.jp/book/' + props.item.isbn} target="_blank" style={{
display: 'inline-block',
width: '100%',
height: '100%',
}}>
{item.cover ? (
<img src={item.cover}
alt={item.title}
data-aspect={item.properties.aspect}
/>
) : (
<div className="nocover">
<div className="bg"></div>
<div className="textCover">
{item.height > 100 ? (
<React.Fragment>
<div className="title" style={{ fontSize: fontSize + 'px' }}>{item.title}</div>
<div className="author" style={{ fontSize: fontSize * 0.7 + 'px' }}>{item.author}</div>
</React.Fragment>
) : null}
</div>
</div>
)}
{props.sortKey && item[props.sortKey] > 0 && item.height > 100 ? (
<span className="sortKey" style={{
opacity: item[props.sortKey] / 2 + 0.1,
fontSize: fontSize + 'px',
width: sortKeySize + 'px',
height: sortKeySize + 'px',
right: sortKeySize / 4,
bottom: sortKeySize / 4,
}}>{item[props.sortKey]}</span>
) : null}
</a>)
}
export default Item