package sqwl.cms.layout
import scalatags.Text.TypedTag
import scalatags.Text.all._
import sqwl.cms._
object Navbar extends config {
def apply(cnt: iContent, st: ViewState): TypedTag[String] = {
/*
val navMenu = ul(cls:="nav navbar-nav navbar-right",
li(a(href:="#about", "O aplikaci"))
)
*/
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:=s"text-center ${activeCls(c)}",
a(href:=s"/${http.prefix}/${c.pathSegment}", c.name))
)
)
header(cls:="navbar navbar-default navbar-fixed-top",
div(cls:="navbar-inner",
div(cls:="container",
div(cls:="navbar-header",
button(`type`:="button", cls:="navbar-toggle collapsed",
attr("data-toggle"):="collapse",
attr("data-target"):="#navbar1",
span(cls:="sr-only", "Navigation"),
span(cls:="icon-bar"),
span(cls:="icon-bar"),
span(cls:="icon-bar")
),
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:=s"/${http.prefix}", cls:="navbar-brand visible-xs",
span(cnt.appTitleShort)),
a(href:=s"/${http.prefix}", cls:="navbar-brand hidden-xs",
span(cnt.appTitle))
)
//tag("nav")(cls:="hidden-xs", navMenu)
)
),
div(cls:="collapse navbar-collapse", id:="navbar1",
div(cls:="container", navSections))
)
}
}