diff --git a/app/decorators/books/decorator.rb b/app/decorators/books/decorator.rb index e122c4f..98d6c44 100644 --- a/app/decorators/books/decorator.rb +++ b/app/decorators/books/decorator.rb @@ -28,7 +28,7 @@ module Adamantium def status_colour case book_status - when "read" + when "read" || "finished" "text-green-100 bg-green-500" when "to-read" "text-blue-100 bg-blue-500" @@ -36,6 +36,17 @@ module Adamantium "text-orange-100 bg-orange-500" end end + + def status_label + case book_status + when "read" || "finished" + "Read" + when "to-read" + "To read" + when "reading" + "Reading" + end + end end end end diff --git a/app/templates/books/index.html.slim b/app/templates/books/index.html.slim index 5cd8e7d..c0d6440 100644 --- a/app/templates/books/index.html.slim +++ b/app/templates/books/index.html.slim @@ -3,39 +3,39 @@ div class="mb-12 prose dark:prose-invert max-w-prose mx-auto text-gray-800 dark:text-gray-200" h1 📚 Bookshelf - div class="mb-12 max-w-prose mx-auto" - table class="prose dark:prose-invert table-auto" - thead - tr - td - td class="p-2" Title - td class="p-2" Author(s) - - reading.each do |book| - tr - td - div class="rounded-md text-xs #{book.status_colour} px-2 w-full text-center" - = book.book_status - td - = book.name - td - = book.authors - - to_read.each do |book| - tr - td - div class="rounded-md text-xs #{book.status_colour} px-2 w-full text-center" - = book.book_status - td - = book.name - td - = book.authors - - read.each do |book| - tr - td - div class="rounded-md text-xs #{book.status_colour} px-2 w-full text-center" - = book.book_status - td - = book.name - td - = book.authors +div class="mb-12 prose dark:prose-invert max-w-prose mx-auto" + table class="text-gray-800 dark:text-white table-auto" + thead + tr + td + td class="p-2" Title + td class="p-2" Author(s) + - reading.each do |book| + tr + td + div class="rounded-md uppercase text-xs #{book.status_colour} px-2 w-full text-center" + = book.status_label + td + = book.name + td + = book.authors + - to_read.each do |book| + tr + td + div class="rounded-md uppercase text-xs #{book.status_colour} px-2 w-full text-center" + = book.status_label + td + = book.name + td + = book.authors + - read.each do |book| + tr + td + div class="rounded-md uppercase text-xs #{book.status_colour} px-2 w-full text-center" + = book.status_label + td + = book.name + td + = book.authors div class="max-w-screen-md mx-auto border-t-4 border-solid border-gray-400 dark:border-gray-600" diff --git a/app/validation/posts/book_contract.rb b/app/validation/posts/book_contract.rb index c4aada7..d648839 100644 --- a/app/validation/posts/book_contract.rb +++ b/app/validation/posts/book_contract.rb @@ -10,7 +10,7 @@ module Adamantium required(:slug).filled(:string) required(:post_type).value(included_in?: %w[book]) required(:book_author).maybe(:string) - required(:book_status).value(included_in?: %w[to-read reading read]) + required(:book_status).value(included_in?: %w[to-read reading read finished]) end end end