mirror of
https://github.com/phfroidmont/scalive.git
synced 2025-12-25 05:26:59 +01:00
Add home liveview
This commit is contained in:
parent
a036e3cbb3
commit
0b067aa7e1
3 changed files with 43 additions and 4 deletions
|
|
@ -25,6 +25,10 @@ object Example extends ZIOAppDefault:
|
|||
LiveRouter(
|
||||
RootLayout(_),
|
||||
List(
|
||||
LiveRoute(
|
||||
Root,
|
||||
(_, _) => HomeLiveView()
|
||||
),
|
||||
LiveRoute(
|
||||
Root / "counter",
|
||||
(_, _) => CounterLiveView()
|
||||
|
|
|
|||
29
example/src/HomeLiveView.scala
Normal file
29
example/src/HomeLiveView.scala
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
import scalive.*
|
||||
import zio.*
|
||||
import zio.stream.ZStream
|
||||
|
||||
class HomeLiveView() extends LiveView[String, Unit]:
|
||||
val links = List(
|
||||
"/counter" -> "Counter",
|
||||
"/list" -> "List"
|
||||
)
|
||||
|
||||
def init = ZIO.succeed(())
|
||||
|
||||
def update(model: Unit) = _ => ZIO.succeed(model)
|
||||
|
||||
def view(model: Dyn[Unit]) =
|
||||
ul(
|
||||
cls := "space-y-2",
|
||||
links.map((path, name) =>
|
||||
li(
|
||||
a(
|
||||
href := path,
|
||||
cls := "block px-4 py-2 rounded-lg text-gray-700 hover:bg-gray-100 hover:text-gray-900 font-medium transition",
|
||||
name
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def subscriptions(model: Unit) = ZStream.empty
|
||||
Loading…
Add table
Add a link
Reference in a new issue