packages feed

panda-0.0.0.3: Panda/View/Theme/BluePrint/Template/Body.hs

module Panda.View.Theme.BluePrint.Template.Body where

-- env
import Panda.Helper.Env
import Prelude hiding ((.), (/), id, span)
import Panda.Config.Global as Config
import qualified Panda.Type.State as State
import Text.XHtml.Strict

-- view
import Panda.View.Theme.BluePrint.Template.Sidebar
import Panda.View.Theme.BluePrint.Template.Footer


html_body state x = body << container << 
  [ body_header state
  , div_id "page" << [ body_content x, html_sidebar state ]
  , html_footer
  ]

container   = div_class "container"

body_header state = toHtml
  [ div_class_id "column span-12 first" "header" << 
    [ search_form
    , site_name
    ]
  , div_class_id "column span-12 first large" "nav" << navigation state
  ]

-- search_form = spaceHtml
search_form = 
  div_id "search" << form ! [action "/search", method "get"] << thediv << 
    textfield "s" -- ! [strAttr "onFocus" "clearInput('s', 'Search')", strAttr "onBlur" "clearInput('s', 'Search')"]
  
site_name = toHtml $
  [ toHtml $ hotlink "/" ! [theclass "logo"] << ""
  , h1 << Config.blog_title
  , div_class "description" << Config.blog_subtitle
  ]

navigation state = div_class "content" <<
  ulist << 
  [ li ! [theclass ("first" ++ current_home)] << home_link
  , li ! [theclass ("page_item page-item-2" ++ current_about)] << about
  ]
  where
    nav           = state.State.nav_location
    current       = " current_page_item"
    current_home  = at State.Home
    current_about = at State.About
    at x          = if nav == x then current else ""


home_link   = hotlink "/" << "Home"
about       = hotlink "/static/about" << "About"


body_content x = div_class_id "column span-9 first" "maincontent" <<
  div_class "content" << x