{{ $chapter->name }}
-{{ $chapter->getExcerpt() }}
-@icon('caret-right') @icon('page') {{ trans_choice('entities.x_pages', $chapter->pages->count()) }}
-{{ $page->name }}
- {{ $slot ?? '' }} -{{ $chapter->name }}
+{{ $chapter->getExcerpt() }}
diff --git a/app/Entities/Chapter.php b/app/Entities/Chapter.php index 079105ba9..bdacb7c9d 100644 --- a/app/Entities/Chapter.php +++ b/app/Entities/Chapter.php @@ -53,9 +53,9 @@ class Chapter extends Entity * @param int $length * @return string */ - public function getExcerpt($length = 100) + public function getExcerpt(int $length = 100) { - $description = $this->description; + $description = $this->text ?? $this->description; return strlen($description) > $length ? substr($description, 0, $length-3) . '...' : $description; } @@ -67,4 +67,13 @@ class Chapter extends Entity { return "'BookStack\\\\Chapter' as entity_type, id, id as entity_id, slug, name, {$this->textField} as text, '' as html, book_id, priority, '0' as chapter_id, '0' as draft, created_by, updated_by, updated_at, created_at"; } + + /** + * Check if this chapter has any child pages. + * @return bool + */ + public function hasChildren() + { + return count($this->pages) > 0; + } } diff --git a/resources/assets/sass/_colors.scss b/resources/assets/sass/_colors.scss index d2ee13837..644b6b8af 100644 --- a/resources/assets/sass/_colors.scss +++ b/resources/assets/sass/_colors.scss @@ -102,6 +102,9 @@ p.secondary, p .secondary, span.secondary, .text-secondary { .bg-book { background-color: $color-book; } +.bg-chapter { + background-color: $color-chapter; +} .bg-shelf { background-color: $color-bookshelf; } \ No newline at end of file diff --git a/resources/assets/sass/_lists.scss b/resources/assets/sass/_lists.scss index db057532d..8b7027ef2 100644 --- a/resources/assets/sass/_lists.scss +++ b/resources/assets/sass/_lists.scss @@ -1,7 +1,11 @@ .book-contents .entity-list-item { .icon { - margin-top: $-xs; + width: 30px; + border-radius: 4px; + justify-self: stretch; + align-self: stretch; + height: auto; } p { margin-bottom: 0; @@ -10,8 +14,60 @@ padding-top: 0; padding-bottom: 0; } - .inset-list { - display: none; +} + +.entity-list-item + .chapter-expansion { + display: flex; + padding: 0 $-m $-m $-m; + align-items: center; + border: 0; + width: 100%; + position: relative; + > .icon { + width: 30px; + height: auto; + border-radius: 0 0 4px 4px; + align-self: stretch; + flex-shrink: 0; + &:before { + position: absolute; + top: 0; + left: 0; + width: 100%; + height: 1px; + background-color: currentColor; + content: ''; + opacity: 0.2; + } + } + > .content { + flex: 1; + } + .chapter-expansion-toggle { + border-radius: 0 4px 4px 0; + padding: $-xs $-m; + } + .chapter-expansion-toggle:hover { + background-color: rgba(0, 0, 0, 0.06); + } + +} + +.entity-list-item.has-children { + padding-bottom: 0; + > .icon { + border-radius: 4px 4px 0 0; + } +} + +.inset-list { + display: none; + .entity-list-item-name { + font-size: 1rem; + } + .entity-list-item-children { + padding-top: 0; + padding-bottom: 0; } } @@ -355,7 +411,7 @@ ul.pagination { .svg-icon { color: #FFF; fill: #FFF; - font-size: 2rem; + font-size: 1.66rem; margin-right: 0; position: absolute; bottom: $-xs; @@ -367,6 +423,10 @@ ul.pagination { } } +.chapter > .entity-list-item-image { + width: 60px; +} + .entity-list.compact { font-size: 0.6 * $fs-m; h4, a { diff --git a/resources/assets/sass/_pages.scss b/resources/assets/sass/_pages.scss index 1b1193079..427b98c26 100755 --- a/resources/assets/sass/_pages.scss +++ b/resources/assets/sass/_pages.scss @@ -363,7 +363,7 @@ } } -.entity-list-item > span:first-child, .icon-list-item > span:first-child { +.entity-list-item > span:first-child, .icon-list-item > span:first-child, .chapter-expansion > .icon { font-size: 0.8rem; width: 1.88em; height: 1.88em; diff --git a/resources/views/books/show.blade.php b/resources/views/books/show.blade.php index 28983b22c..3a4a2c192 100644 --- a/resources/views/books/show.blade.php +++ b/resources/views/books/show.blade.php @@ -49,7 +49,7 @@ {{--TODO--}}
{{ $chapter->getExcerpt() }}
-@icon('caret-right') @icon('page') {{ trans_choice('entities.x_pages', $chapter->pages->count()) }}
-{{ $chapter->getExcerpt() }}