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
|
package reading.component.index
import rx._
import scalacss.Defaults._
import scalacss.ScalatagsCss._
import scalatags.JsDom.all._
import reading.component.index.style.{ Header => HeaderStyle }
import reading.component.widget.Input
import reading.models.{ Book, Filter }
import reading.utils.RxUtils._
object Header {
def apply(
books: Rx[Seq[Book]],
filters: Var[Seq[Filter]],
detail: Var[Option[Book]],
search: Var[String],
showFiltersMenu: Var[Boolean]
)(
implicit
ctx: Ctx.Owner
): Frag = {
val booksCount: Rx[Int] = books.map(_.length)
div(
HeaderStyle.render,
HeaderStyle.header,
Filters(filters, detail, search, showFiltersMenu),
div(
HeaderStyle.searchAndCount,
Input(HeaderStyle.search, search, "Rechercher", maxLength = Some(25)),
Rx {
div(
HeaderStyle.count,
span(s"${booksCount()} livre${if (booksCount() > 1) "s" else ""}")
)
}
)
)
}
}
|