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
|
package reading.component
import rx._
import Ctx.Owner.Unsafe._
import scalatags.JsDom.all._
import scalacss.Defaults._
import scalacss.ScalatagsCss._
import reading.component.style.{Index => IndexStyle}
import reading.component.index.{FiltersMenu, Filters, Books}
import reading.models.{Book, Filter}
import reading.utils.RxAttr
object Index {
def apply(): Frag = {
val filters: Var[Seq[Filter]] = Var(Nil)
val books: Rx[Seq[Book]] = Rx {
if(filters().isEmpty) Book.all else Book.filter(Book.all, 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),
Books(books)
)
)
)
}
}
|