Skip to content

Commit ca5daa5

Browse files
committed
Horizontal Book Card
1 parent 7610fed commit ca5daa5

2 files changed

Lines changed: 36 additions & 8 deletions

File tree

src/components/BookCard.astro

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface Props {
77
pattern?: "circles" | "grid" | "waves" | "dots";
88
fontStyle?: "serif" | "sans" | "display" | "handwritten";
99
layoutStyle?: "classic" | "minimal" | "modern";
10+
orientation?: "vertical" | "horizontal";
1011
}
1112
1213
const {
@@ -17,11 +18,16 @@ const {
1718
pattern = "circles",
1819
fontStyle = "serif",
1920
layoutStyle = "classic",
21+
orientation = "vertical",
2022
} = Astro.props;
2123
---
2224

23-
<a href={href} class="book-card-link">
24-
<div class="book-card" data-layout={layoutStyle}>
25+
<a href={href} class="book-card-link" data-orientation={orientation}>
26+
<div
27+
class="book-card"
28+
data-layout={layoutStyle}
29+
data-orientation={orientation}
30+
>
2531
<div
2632
class="book-cover"
2733
style={`background: linear-gradient(135deg, ${coverColor}, ${coverColor}dd)`}
@@ -210,10 +216,8 @@ const {
210216
left: 0;
211217
right: 0;
212218
bottom: 0;
213-
background-image: linear-gradient(
214-
rgba(255, 255, 255, 0.05) 1px,
215-
transparent 1px
216-
),
219+
background-image:
220+
linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
217221
linear-gradient(
218222
90deg,
219223
rgba(255, 255, 255, 0.05) 1px,
@@ -235,7 +239,8 @@ const {
235239
left: 0;
236240
right: 0;
237241
bottom: 0;
238-
background: radial-gradient(
242+
background:
243+
radial-gradient(
239244
circle at 100% 100%,
240245
transparent 20%,
241246
rgba(255, 255, 255, 0.05) 21%,
@@ -360,4 +365,23 @@ const {
360365
-webkit-line-clamp: 2; /* Reduce lines on very small cards */
361366
}
362367
}
368+
369+
/* Horizontal Orientation */
370+
.book-card-link[data-orientation="horizontal"] {
371+
max-width: 300px; /* Wider max-width for landscape */
372+
}
373+
374+
.book-card[data-orientation="horizontal"] {
375+
aspect-ratio: 3/2; /* Landscape aspect ratio */
376+
transform: rotateY(-5deg); /* Slightly more angle for width */
377+
}
378+
379+
.book-card[data-orientation="horizontal"] .book-title {
380+
font-size: 8cqw !important; /* Smaller relative font size as width is larger */
381+
}
382+
383+
.book-card[data-orientation="horizontal"] .book-decor {
384+
width: 40cqw;
385+
height: 40cqw;
386+
}
363387
</style>

src/pages/index.astro

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ const posts = (await getCollection("blog"))
8080
</div>
8181
<div class="books-grid">
8282
{bookItems.map((book) => {
83+
const isStats2 = book.slug.includes("stats-2");
84+
8385
return (
8486
<BookCard
8587
title={book.data.title
@@ -91,6 +93,8 @@ const posts = (await getCollection("blog"))
9193
pattern="circles"
9294
fontStyle="serif"
9395
layoutStyle="classic"
96+
97+
orientation="horizontal"
9498
/>
9599
);
96100
})}
@@ -520,7 +524,7 @@ const posts = (await getCollection("blog"))
520524
}
521525

522526
.section-title {
523-
font-size: 2rem;
527+
font-size: 1.5rem;
524528
/* font-family: var(--font-serif); */
525529
font-family: "Playfair Display", serif;
526530
margin-bottom: 0;

0 commit comments

Comments
 (0)