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
|
package reading.component
import rx._
import Ctx.Owner.Unsafe._
import scalatags.JsDom.all._
import scalacss.Defaults._
import scalacss.ScalatagsCss._
import reading.Books
import reading.component.style.{ Index => IndexStyle }
import reading.component.index.{ FiltersMenu, Filters, Books => BooksComponent }
import reading.models.{ Book, Filter }
import reading.utils.RxAttr
object Index {
def apply(initialFilters: Seq[Filter]): HtmlTag = {
val filters: Var[Seq[Filter]] = Var(initialFilters)
val books: Rx[Seq[Book]] = Rx {
if (filters().isEmpty) Books() else Book.filter(Books(), filters())
}
div(
IndexStyle.render,
button(
IndexStyle.header,
RxAttr(onclick, Rx(() => filters() = Nil)),
"Conseils de lecture"
),
div(
IndexStyle.page,
FiltersMenu(books, filters),
div(
IndexStyle.main,
Filters(filters),
BooksComponent(books)
)
)
)
}
}
|