{-# OPTIONS -fno-monomorphism-restriction #-}

module Panda.View.Widget.Template (page) where

import Panda.View.Widget.Head
import Panda.View.Widget.Body
import Panda.View.Widget.Header
import Panda.View.Widget.Navigation
import Panda.View.Widget.Sidebar
import Panda.View.Widget.Footer
import qualified Text.XHtml.Strict as Html
import qualified Panda.Config.Global as G
import qualified Panda.Type.Theme as T

import Panda.Helper.Env hiding (header, body)
import Prelude hiding ((.), (/), (^), id, span)

-- extension
import Panda.Extension.Analytics.T
import Panda.Type.Extension
import Panda.Helper.StateHelper

body t state x = Html.body << 
  [ div_class (t.T.container) << 
    [ header (t.T.header) state
    , navigation (t.T.navigation) state
    , div_id "page" << [ div_class (t.T.main) << body_content x, sidebar (t.T.sidebar) state ]
    , footer (t.T.footer)
    ]
  , only_for Analytics $ primHtml analytics_snippet
  ]

template t state x = [html_head state, body t state x]

page = template G.theme