-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathFeaturedBooks.tsx
More file actions
70 lines (64 loc) · 2 KB
/
FeaturedBooks.tsx
File metadata and controls
70 lines (64 loc) · 2 KB
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
import Link from 'next/link';
import React from 'react';
import { Button, Col, Row } from 'react-bootstrap';
import BookCard, { Book } from './BookCard';
import { ContentContainer } from './Layout';
interface FeaturedBooksProps {
books: Book[];
title?: string;
subtitle?: string;
showViewAll?: boolean;
viewAllLink?: string;
viewAllText?: string;
}
const FeaturedBooks: React.FC<FeaturedBooksProps> = ({
books,
title = '精选图书',
subtitle = '社区成员推荐的优质读物,涵盖技术、设计、创业等多个领域',
showViewAll = true,
viewAllLink = '/open-library/books',
viewAllText = '查看全部图书',
}) => (
<section className="py-5 bg-light">
<ContentContainer>
<div className="text-center mb-5">
<h2 className="display-5 fw-bold text-dark mb-3 position-relative">
{title}
<div className="position-absolute start-50 translate-middle-x mt-2">
<div
className="bg-success rounded-pill"
style={{ width: '60px', height: '3px' }}
/>
</div>
</h2>
<p className="lead text-muted mx-auto" style={{ maxWidth: '600px' }}>
{subtitle}
</p>
</div>
<Row xs={1} sm={2} lg={3} xl={4} className="g-4 justify-content-center">
{books.slice(0, 8).map(book => (
<Col key={book.id}>
<BookCard book={book} variant="featured" />
</Col>
))}
</Row>
{showViewAll && (
<div className="text-center mt-5">
<Link href={viewAllLink} passHref legacyBehavior>
<Button
variant="outline-success"
size="lg"
as="a"
className="rounded-pill px-4 fw-semibold"
>
<i className="bi bi-collection me-2" />
{viewAllText}
<i className="bi bi-arrow-right ms-2" />
</Button>
</Link>
</div>
)}
</ContentContainer>
</section>
);
export default FeaturedBooks;