Skip to content

Commit

Permalink
Laminar 15.x, waypoint 6.x (keynmol#118)
Browse files Browse the repository at this point in the history
* Laminar 15.x, waypoint 6.x

* chore: format build.sbt
  • Loading branch information
keynmol authored Mar 5, 2023
1 parent 8999878 commit 175f095
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 30 deletions.
40 changes: 21 additions & 19 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,25 @@ import smithy4s.codegen.Smithy4sCodegenPlugin
Global / onChangedBuildSource := ReloadOnSourceChanges

val Versions = new {
val http4sBlaze = "0.23.13"
val http4s = "0.23.18"
val Scala = "3.2.2"
val skunk = "0.5.1"
val upickle = "2.0.0"
val scribe = "3.11.1"
val http4sDom = "0.2.7"
val jwt = "9.2.0"
val Flyway = "9.15.1"
val Postgres = "42.5.4"
val TestContainers = "0.40.12"
val Weaver = "0.8.1"
val WeaverPlaywright = "0.0.5"
val Laminar = "0.14.5"
val waypoint = "0.5.0"
val scalacss = "1.0.0"
val monocle = "3.2.0"
val circe = "0.14.5"
val http4sBlaze = "0.23.13"
val http4s = "0.23.18"
val Scala = "3.2.2"
val skunk = "0.5.1"
val upickle = "2.0.0"
val scribe = "3.11.1"
val http4sDom = "0.2.7"
val jwt = "9.2.0"
val Flyway = "9.15.1"
val Postgres = "42.5.4"
val TestContainers = "0.40.12"
val Weaver = "0.8.1"
val WeaverPlaywright = "0.0.5"
val Laminar = "15.0.0-M7"
val waypoint = "6.0.0-M5"
val scalacss = "1.0.0"
val monocle = "3.2.0"
val circe = "0.14.5"
val macroTaskExecutor = "1.1.1"
}

val Config = new {
Expand Down Expand Up @@ -176,7 +177,8 @@ lazy val frontend = projectMatrix
"com.lihaoyi" %%% "upickle" % Versions.upickle,
"io.circe" %%% "circe-core" % Versions.circe,
"io.circe" %%% "circe-parser" % Versions.circe,
"org.http4s" %%% "http4s-dom" % Versions.http4sDom
"org.http4s" %%% "http4s-dom" % Versions.http4sDom,
"org.scala-js" %%% "scala-js-macrotask-executor" % Versions.macroTaskExecutor
)
)

Expand Down
1 change: 1 addition & 0 deletions modules/frontend/src/main/scala/api.client.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class Api private (
val jobs: JobService[IO],
val users: UserService[IO]
):
import org.scalajs.macrotaskexecutor.MacrotaskExecutor.Implicits.*
def future[A](a: Api => IO[A]): Future[A] =
a(this).unsafeToFuture()

Expand Down
20 changes: 11 additions & 9 deletions modules/frontend/src/main/scala/app.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ object Main:
def renderPage(using
router: Router[Page]
)(using state: AppState, api: Api): Signal[HtmlElement] =
SplitRender[Page, HtmlElement](router.$currentPage)
SplitRender[Page, HtmlElement](router.currentPageSignal)
.collectStatic(Page.Login)(pages.login)
.collectStatic(Page.Logout)(pages.logout)
.collectStatic(Page.LatestJobs)(pages.latest_jobs)
Expand All @@ -32,7 +32,7 @@ object Main:
.collectStatic(Page.Profile)(pages.profile)
.collectSignal[Page.CompanyPage](pages.company)
.collectSignal[Page.JobPage](pages.job)
.$view
.signal

def main(args: Array[String]): Unit =
given state: AppState = AppState.init
Expand All @@ -45,7 +45,7 @@ object Main:

val app = div(
Styles.container,
header(
headerTag(
Styles.headerContainer,
div(
a(Styles.logo, "Jobby", navigateTo(Page.LatestJobs)),
Expand All @@ -72,14 +72,16 @@ object Main:
)
)

documentEvents.onDomContentLoaded.foreach { _ =>
import scalacss.ProdDefaults.*
renderOnDomContentLoaded(
dom.document.getElementById("appContainer"), {
import scalacss.ProdDefaults.*

val sty = styleTag(Styles.render[String], `type` := "text/css")
dom.document.querySelector("head").appendChild(sty.ref)
val sty = styleTag(Styles.render[String], `type` := "text/css")
dom.document.querySelector("head").appendChild(sty.ref)

render(dom.document.getElementById("appContainer"), app)
}(unsafeWindowOwner)
app
}
)
end main
end Main

Expand Down
2 changes: 1 addition & 1 deletion modules/frontend/src/main/scala/app.state.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ object AppState:
def init: AppState =
AppState(
_authToken = Var(None),
events = EventBus[AuthEvent]
events = EventBus[AuthEvent]()
)

end AppState
2 changes: 1 addition & 1 deletion modules/frontend/src/main/scala/routes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ object Page:
deserializePage = str =>
io.circe.scalajs.decodeJs[Page](JSON.parse(str)).fold(throw _, identity)
)(
$popStateEvent = L.windowEvents.onPopState,
popStateEvents = windowEvents(_.onPopState),
owner = L.unsafeWindowOwner
)
end Page
Expand Down

0 comments on commit 175f095

Please sign in to comment.