Skip to content

Commit 230a892

Browse files
committed
Render children in book index page; add image automatically
1 parent 0deab67 commit 230a892

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

src/app/components/elements/Book.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import { BookPage } from "./BookPage";
1010
import { skipToken } from "@reduxjs/toolkit/query";
1111
import { ShowLoadingQuery } from "../handlers/ShowLoadingQuery";
1212
import { TeacherNotes } from "./TeacherNotes";
13+
import { IsaacContentValueOrChildren } from "../content/IsaacContentValueOrChildren";
14+
import { ContentDTO } from "../../../IsaacApiTypes";
1315

1416
interface BookProps {
1517
match: { params: { bookId: string } };
@@ -63,12 +65,25 @@ export const Book = ({match: {params: {bookId}}}: BookProps) => {
6365
/>
6466
: <>
6567
<TeacherNotes notes={definedBookIndexPage.teacherNotes} />
66-
<div>
67-
<div className="book-image-container mx-3 float-end">
68+
{definedBookIndexPage.value && <div>
69+
<div className="book-image-container book-height-lg d-none d-sm-block mx-3 float-end">
6870
<img src={definedBookIndexPage.coverImage?.src} alt={definedBookIndexPage.title} />
6971
</div>
7072
<Markup className="d-contents" trusted-markup-encoding={"markdown"}>{definedBookIndexPage.value}</Markup>
71-
</div>
73+
</div>}
74+
{definedBookIndexPage.children?.length && <>
75+
<div className="d-flex">
76+
<div className="flex-grow-1">
77+
<IsaacContentValueOrChildren {...definedBookIndexPage.children[0] as ContentDTO} />
78+
</div>
79+
<div className="book-image-container book-height-lg d-none d-sm-block mx-3 float-end">
80+
<img src={definedBookIndexPage.coverImage?.src} alt={definedBookIndexPage.title} />
81+
</div>
82+
</div>
83+
<IsaacContentValueOrChildren>
84+
{definedBookIndexPage.children.slice(1)}
85+
</IsaacContentValueOrChildren>
86+
</>}
7287
</>
7388
}
7489
</MainContent>

src/scss/phy/books.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ svg.book-page-icon {
105105
max-height: 215px;
106106
border-radius: 3px;
107107
}
108+
109+
&.book-height-lg > img {
110+
max-height: 315px;
111+
}
108112
}
109113

110114
.chapter-title {

0 commit comments

Comments
 (0)