base/src/sqwl/cms/layout/Navbar.scala
changeset 12 e7512f9dc903
parent 8 8e0809dad9f7
child 31 5c4364d6e726
--- a/base/src/sqwl/cms/layout/Navbar.scala	Thu Dec 06 14:03:54 2018 +0100
+++ b/base/src/sqwl/cms/layout/Navbar.scala	Thu Dec 06 15:19:41 2018 +0100
@@ -2,7 +2,7 @@
 
 import scalatags.Text.TypedTag
 import scalatags.Text.all._
-import sqwl.cms.{ViewState, config, iContent}
+import sqwl.cms._
 
 object Navbar extends config {
 
@@ -14,9 +14,18 @@
     )
     */
 
+    def activeCls(c: iCategory): String = {
+      st match {
+        case ViewCategory(v) if v == c => "active"
+        case ViewArticle(v) if v.category contains(c) => "active"
+        case _ => ""
+      }
+    }
+
     val navSections = ul(cls:="nav navbar-nav navbar-section", width:="100%",
       cnt.categories map(c =>
-        li(cls:="text-center", a(href:=s"/${http.prefix}/${c.pathSegment}", c.name))
+        li(cls:=s"text-center ${activeCls(c)}",
+          a(href:=s"/${http.prefix}/${c.pathSegment}", c.name))
       )
     )
 
@@ -32,12 +41,13 @@
               span(cls:="icon-bar"),
               span(cls:="icon-bar")
             ),
-            a(href:="#", cls:="navbar-brand", paddingTop:=4, paddingBottom:=4,
+            a(href:=s"/${http.prefix}", cls:="navbar-brand",
+              paddingTop:=4, paddingBottom:=4,
               img(src:=s"/${http.prefix}/public/${cnt.icon._1}",
                 alt:=cnt.appTitleShort, width:=40, height:=40)),
-            a(href:="#", cls:="navbar-brand visible-xs",
+            a(href:=s"/${http.prefix}", cls:="navbar-brand visible-xs",
               span(cnt.appTitleShort)),
-            a(href:="#", cls:="navbar-brand hidden-xs",
+            a(href:=s"/${http.prefix}", cls:="navbar-brand hidden-xs",
               span(cnt.appTitle))
           )
           //tag("nav")(cls:="hidden-xs", navMenu)