Skip to content

Commit

Permalink
wip(home): refactor home css and move page witch to controller
Browse files Browse the repository at this point in the history
  • Loading branch information
luigi-borriello00 committed Sep 6, 2023
1 parent cf6568e commit 8ad6604
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 19 deletions.
17 changes: 12 additions & 5 deletions src/main/scala/scatan/controllers/home/HomeController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@ package scatan.controllers.home

import scatan.mvc.lib.Controller
import scatan.views.home.HomeView
import scatan.example.model.CounterAppState
import scatan.Pages
import scatan.mvc.lib.application.NavigableApplication
import scatan.mvc.lib.NavigableApplicationManager

trait HomeController extends Controller
trait HomeController extends Controller:
def goToSetup(): Unit
def goToAbout(): Unit

class HomeControllerImpl(requirements: Controller.Requirements[HomeView, CounterAppState]) extends HomeController:
def start(): Unit =
print("Hello, world!")
class HomeControllerImpl(requirements: Controller.Requirements[HomeView, ?]) extends HomeController:
override def goToSetup(): Unit =
NavigableApplicationManager.navigateTo[Pages](Pages.Setup)

override def goToAbout(): Unit =
NavigableApplicationManager.navigateTo[Pages](Pages.About)
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ package scatan.controllers.setup

import scatan.mvc.lib.Controller
import scatan.views.setup.SetUpView
import scatan.mvc.lib.Model
import scatan.example.model.CounterAppState

trait SetUpController extends Controller

class SetUpControllerImpl(dependencies: Controller.Requirements[SetUpView, CounterAppState]) extends SetUpController
class SetUpControllerImpl(dependencies: Controller.Requirements[SetUpView, ?]) extends SetUpController
4 changes: 2 additions & 2 deletions src/main/scala/scatan/views/home/ScalaJsHomeView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ class ScalaJsHomeView(requirements: View.Requirements[HomeController], container
cls := "home-menu",
button(
cls := "home-menu-button",
onClick.mapTo(Pages.Setup) --> NavigableApplicationManager.navigateTo,
onClick --> (_ => controller.goToSetup()),
"Play"
),
button(
cls := "home-menu-button",
onClick.mapTo(Pages.About) --> NavigableApplicationManager.navigateTo,
onClick --> (_ => controller.goToAbout()),
"About"
)
)
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/scatan/views/setup/ScalaJsSetUpView.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class ScalaJsSetUpView(requirements: View.Requirements[SetUpController], contain
extends SetUpView
with View.Dependencies(requirements)
with ScalaJSView(container):
val users: Int = 4
val numberOfUsers: Int = 3

def start(): Unit =
print("Hello, world!")
Expand All @@ -29,7 +29,7 @@ class ScalaJsSetUpView(requirements: View.Requirements[SetUpController], contain
// Menu view with 3 buttons, play, settings and about, dispose them vertically
div(
cls := "setup-menu",
for i <- 1 to users
for i <- 1 to numberOfUsers
yield div(
cls := "setup-menu-textbox-container",
input(
Expand Down
16 changes: 9 additions & 7 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ body {
}

.home-title{
background-position-x: center;
background-image: url("res/img/logo.png");
background-size: contain;
background-repeat: no-repeat;
width: 100%;
padding: auto;
height: 20em;
}
/* Home
Expand All @@ -33,14 +33,16 @@ display all menu item vertically
.home-menu{
margin-top: 1em;
margin-bottom: 1em;
margin-left: auto;
margin-right: auto;
display: flex;
width: 70%;
height: auto;
flex-direction: column;
gap: 1em;
}

.home-menu-button{
margin-bottom: 1em;
width: 30em;
height: 5em;
display: block;
flex-grow: 1;
font-size: large;
font-weight: bold;
height: 3em;
}

0 comments on commit 8ad6604

Please sign in to comment.