-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathApp.scala
54 lines (48 loc) · 1.25 KB
/
App.scala
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
48
49
50
51
52
53
54
package per.cyz.wisdomGu.fronted
import calico.*
import calico.html.io.{*, given}
import calico.syntax.*
import calico.unsafe.given
import cats.effect.*
import cats.effect.syntax.all.*
import cats.syntax.all.*
import frontroute.{*, given}
import fs2.*
import fs2.concurrent.*
import fs2.dom.*
import org.scalajs.dom
import org.scalajs.dom.*
import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport
import per.cyz.wisdomGu.fronted.pages.HomePage
import per.cyz.wisdomGu.fronted.stores.GlobalStore
@js.native
@JSImport("styles/index.css", JSImport.Default)
object IndexCss extends js.Object
@js.native
@JSImport("@iconify-json/uil", JSImport.Namespace)
object UilIcons extends js.Object
object App extends IOWebApp {
val indexCss: IndexCss.type = IndexCss
def render: Resource[IO, fs2.dom.HtmlElement[IO]] = {
SignallingRef.of[IO, GlobalStore](GlobalStore.apply()).toResource.flatMap { globalStore =>
routes(
pathEnd {
runEffect {
BrowserNavigation.pushState(url = "/home")
}
},
pathPrefix("home") {
firstMatch(
pathEnd {
HomePage.root(globalStore)
}
)
},
noneMatched {
div("404")
}
)
}
}
}