1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
package reading.component.index
import scalatags.JsDom.all._
import scalacss.Defaults._
import scalacss.ScalatagsCss._
import reading.component.index.style.{ BookDetail => BookStyle }
import reading.models.{ Program, Book }
object BookDetail {
def apply(book: Book): Frag =
div(
BookStyle.render,
BookStyle.detail,
img(
BookStyle.cover,
src := s"cover/${book.title}.jpg",
alt := s"${book.title}, ${book.author}"
),
div(
BookStyle.items,
if (book.programs.nonEmpty) {
item("classe", book.programs.map(Program.grade(_).prettyPrint).distinct.sorted)
},
if (book.programs.nonEmpty) {
item("programme", book.programs.map(p => "« " ++ p.prettyPrint ++ " »").sorted)
},
if (book.themes.nonEmpty) {
item("thème", book.themes.sorted.map(_.prettyPrint))
},
if (book.genres.nonEmpty) {
item("genre", book.genres.sorted.map(_.prettyPrint))
},
book.period.map { period =>
item("période", period.prettyPrint)
},
item("niveau", book.level.prettyPrint)
)
)
private def item(key: String, value: String): Frag = item(key, Seq(value))
private def item(key: String, values: Seq[String]): Frag =
div(
BookStyle.item,
div(BookStyle.itemName, key),
ul(
BookStyle.itemValues,
values.map(value => li(BookStyle.itemValue, value.capitalize))
)
)
}
|