aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/reading/component/widget/Modal.scala
blob: fe10d1fea497d5a7a83eb776f95a033b14f0eb50 (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
package reading.component.widget

import rx._
import Ctx.Owner.Unsafe._

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

import reading.component.widget.style.{ Modal => ModalStyle }
import reading.utils.{ RxAttr }

object Modal {
  def apply(onClose: => Unit)(content: HtmlTag): HtmlTag = {
    div(
      ModalStyle.render,
      ModalStyle.modal,

      div(
        ModalStyle.curtain,
        RxAttr(onclick, Rx(() => onClose))
      ),

      div(
        ModalStyle.content,
        content,
        button(
          ModalStyle.close,
          RxAttr(onclick, Rx(() => onClose)),
          "Fermer"
        )
      )
    )
  }
}