aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/reading/component/index/Books.scala
blob: 39c0e6700ecec242cbb2e2a2bbb27de16856a6c1 (plain)
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
package reading.component.index

import rx._

import scalatags.JsDom.all._
import scalacss.Defaults._
import scalacss.ScalatagsCss._

import reading.component.index.style.{Books => BooksStyle}
import reading.models.Book
import reading.utils.RxTag

object Books {
  def apply(books: Rx[Seq[Book]]): Frag =
    div(
      BooksStyle.render,
      BooksStyle.books,

      RxTag { implicit context =>
        div(
          books().sorted.map { book =>
            div(
              BooksStyle.book,
              div(BooksStyle.title, book.title),
              div(BooksStyle.author, book.author),
              div(
                BooksStyle.period,
                s"période: ${book.period}"
              ),
              div(
                BooksStyle.genres,
                s"genre: ${book.genres.mkString(", ")}"
              ),
              div(
                BooksStyle.themes,
                s"thème: ${book.themes.mkString(", ")}"
              ),
              div(
                BooksStyle.pages,
                s"${book.pages} pages"
              )
            )
          }
        )
      }
    )
}