From bed7ba78d3cb2e9b9abe07de632cce536948afec Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sun, 11 Feb 2018 11:36:51 +0000 Subject: [PATCH] Updated grid view to use CSS grid and flexbox Provides a cleaner height-matched design. Closes #701 --- app/Http/Controllers/BookController.php | 2 +- resources/assets/sass/_grid.scss | 45 +++++++++++++++++++---- resources/assets/sass/_lists.scss | 28 ++++++++------ resources/views/books/grid-item.blade.php | 14 +++---- resources/views/books/index.blade.php | 6 +-- 5 files changed, 64 insertions(+), 31 deletions(-) diff --git a/app/Http/Controllers/BookController.php b/app/Http/Controllers/BookController.php index decdfda49..2c3946239 100644 --- a/app/Http/Controllers/BookController.php +++ b/app/Http/Controllers/BookController.php @@ -36,7 +36,7 @@ class BookController extends Controller */ public function index() { - $books = $this->entityRepo->getAllPaginated('book', 20); + $books = $this->entityRepo->getAllPaginated('book', 18); $recents = $this->signedIn ? $this->entityRepo->getRecentlyViewed('book', 4, 0) : false; $popular = $this->entityRepo->getPopular('book', 4, 0); $new = $this->entityRepo->getRecentlyCreated('book', 4, 0); diff --git a/resources/assets/sass/_grid.scss b/resources/assets/sass/_grid.scss index c145f4280..880c619d1 100644 --- a/resources/assets/sass/_grid.scss +++ b/resources/assets/sass/_grid.scss @@ -175,6 +175,43 @@ div[class^="col-"] img { margin-right: -$-m; } +.grid { + display: grid; + grid-column-gap: $-l; + grid-row-gap: $-l; + &.third { + grid-template-columns: 1fr 1fr 1fr; + } +} + +.grid-card { + display: flex; + flex-direction: column; + border: 1px solid #ddd; + min-width: 100px; + .grid-card-content { + flex: 1; + } + .grid-card-content, .grid-card-footer { + padding: $-l; + } + .grid-card-content + .grid-card-footer { + padding-top: 0; + } +} + +@include smaller-than($m) { + .grid.third { + grid-template-columns: 1fr 1fr; + } +} + +@include smaller-than($s) { + .grid.third { + grid-template-columns: 1fr; + } +} + .float { float: left; &.right { @@ -195,14 +232,6 @@ div[class^="col-"] img { display: inline-block; } -@include larger-than(991px) { - .row.auto-clear .col-md-4:nth-child(3n+1){clear:left;} -} - -@include smaller-than(992px) { - .row.auto-clear .col-xs-6:nth-child(2n+1){clear:left;} -} - .col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12 { position: relative; min-height: 1px; diff --git a/resources/assets/sass/_lists.scss b/resources/assets/sass/_lists.scss index 0496d794e..604334415 100644 --- a/resources/assets/sass/_lists.scss +++ b/resources/assets/sass/_lists.scss @@ -382,13 +382,15 @@ ul.pagination { position: relative; overflow: hidden; background: #F2F2F2; - border: 1px solid #ddd; - border-bottom: 0; + a { + display: block; + } img { display: block; + width: 100%; max-width: 100%; height: auto; - transition: all .5s ease; + transition: all .5s ease-in-out; } img:hover { transform: scale(1.15); @@ -396,31 +398,33 @@ ul.pagination { } } -.book-grid-content { - padding: 30px; - border: 1px solid #ddd; +.book-grid-item .grid-card-content { border-top: 0; border-bottom-width: 2px; h2 { + width: 100%; font-size: 1.5em; margin: 0 0 10px; } h2 a { display: block; + width: 100%; line-height: 1.2; color: #009688;; text-decoration: none; + white-space: pre-wrap; /* css-3 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ } p { font-size: .85em; - margin: 0 0 10px; + margin: 0; line-height: 1.6em; } - p.small { - font-size: .8em; - } } -.book-grid-item { - margin-bottom : 20px; +.book-grid-item .grid-card-footer { + p.small { + font-size: .8em; + margin: 0; + } } diff --git a/resources/views/books/grid-item.blade.php b/resources/views/books/grid-item.blade.php index cb2b447b0..bb1914b90 100644 --- a/resources/views/books/grid-item.blade.php +++ b/resources/views/books/grid-item.blade.php @@ -1,18 +1,18 @@ -
+
-
-

{{$book->getShortName(35)}}

+
+

{{$book->getShortName(35)}}

@if(isset($book->searchSnippet))

{!! $book->searchSnippet !!}

@else

{{ $book->getExcerpt(130) }}

@endif -
- @include('partials.entity-meta', ['entity' => $book]) -
+
+
\ No newline at end of file diff --git a/resources/views/books/index.blade.php b/resources/views/books/index.blade.php index 2ab819327..0d8a5fad9 100644 --- a/resources/views/books/index.blade.php +++ b/resources/views/books/index.blade.php @@ -66,14 +66,14 @@ @endforeach {!! $books->render() !!} @else -
+
@foreach($books as $key => $book) @include('books/grid-item', ['book' => $book]) @endforeach -
+
+
{!! $books->render() !!}
-
@endif @else

{{ trans('entities.books_empty') }}