1 package sqwl.cms.layout |
1 package sqwl.cms.layout |
2 |
2 |
3 import scalatags.Text.TypedTag |
3 import scalatags.Text.TypedTag |
4 import scalatags.Text.all._ |
4 import scalatags.Text.all._ |
5 import sqwl.cms.{ViewState, config, iContent} |
5 import sqwl.cms._ |
6 |
6 |
7 object Navbar extends config { |
7 object Navbar extends config { |
8 |
8 |
9 def apply(cnt: iContent, st: ViewState): TypedTag[String] = { |
9 def apply(cnt: iContent, st: ViewState): TypedTag[String] = { |
10 |
10 |
12 val navMenu = ul(cls:="nav navbar-nav navbar-right", |
12 val navMenu = ul(cls:="nav navbar-nav navbar-right", |
13 li(a(href:="#about", "O aplikaci")) |
13 li(a(href:="#about", "O aplikaci")) |
14 ) |
14 ) |
15 */ |
15 */ |
16 |
16 |
|
17 def activeCls(c: iCategory): String = { |
|
18 st match { |
|
19 case ViewCategory(v) if v == c => "active" |
|
20 case ViewArticle(v) if v.category contains(c) => "active" |
|
21 case _ => "" |
|
22 } |
|
23 } |
|
24 |
17 val navSections = ul(cls:="nav navbar-nav navbar-section", width:="100%", |
25 val navSections = ul(cls:="nav navbar-nav navbar-section", width:="100%", |
18 cnt.categories map(c => |
26 cnt.categories map(c => |
19 li(cls:="text-center", a(href:=s"/${http.prefix}/${c.pathSegment}", c.name)) |
27 li(cls:=s"text-center ${activeCls(c)}", |
|
28 a(href:=s"/${http.prefix}/${c.pathSegment}", c.name)) |
20 ) |
29 ) |
21 ) |
30 ) |
22 |
31 |
23 header(cls:="navbar navbar-default navbar-fixed-top", |
32 header(cls:="navbar navbar-default navbar-fixed-top", |
24 div(cls:="navbar-inner", |
33 div(cls:="navbar-inner", |
30 span(cls:="sr-only", "Navigation"), |
39 span(cls:="sr-only", "Navigation"), |
31 span(cls:="icon-bar"), |
40 span(cls:="icon-bar"), |
32 span(cls:="icon-bar"), |
41 span(cls:="icon-bar"), |
33 span(cls:="icon-bar") |
42 span(cls:="icon-bar") |
34 ), |
43 ), |
35 a(href:="#", cls:="navbar-brand", paddingTop:=4, paddingBottom:=4, |
44 a(href:=s"/${http.prefix}", cls:="navbar-brand", |
|
45 paddingTop:=4, paddingBottom:=4, |
36 img(src:=s"/${http.prefix}/public/${cnt.icon._1}", |
46 img(src:=s"/${http.prefix}/public/${cnt.icon._1}", |
37 alt:=cnt.appTitleShort, width:=40, height:=40)), |
47 alt:=cnt.appTitleShort, width:=40, height:=40)), |
38 a(href:="#", cls:="navbar-brand visible-xs", |
48 a(href:=s"/${http.prefix}", cls:="navbar-brand visible-xs", |
39 span(cnt.appTitleShort)), |
49 span(cnt.appTitleShort)), |
40 a(href:="#", cls:="navbar-brand hidden-xs", |
50 a(href:=s"/${http.prefix}", cls:="navbar-brand hidden-xs", |
41 span(cnt.appTitle)) |
51 span(cnt.appTitle)) |
42 ) |
52 ) |
43 //tag("nav")(cls:="hidden-xs", navMenu) |
53 //tag("nav")(cls:="hidden-xs", navMenu) |
44 ) |
54 ) |
45 ), |
55 ), |