136 lines
3.1 KiB
Elm
136 lines
3.1 KiB
Elm
module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
|
|
|
|
import BackendTask exposing (BackendTask)
|
|
import Effect exposing (Effect)
|
|
import FatalError exposing (FatalError)
|
|
import Html exposing (Html)
|
|
import Html.Styled
|
|
import Html.Styled.Events
|
|
import Pages.Flags
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
import UrlPath exposing (UrlPath)
|
|
import Route exposing (Route)
|
|
import SharedTemplate exposing (SharedTemplate)
|
|
import View exposing (View)
|
|
|
|
|
|
template : SharedTemplate Msg Model Data msg
|
|
template =
|
|
{ init = init
|
|
, update = update
|
|
, view = view
|
|
, data = data
|
|
, subscriptions = subscriptions
|
|
, onPageChange = Nothing
|
|
}
|
|
|
|
|
|
type Msg
|
|
= SharedMsg SharedMsg
|
|
| MenuClicked
|
|
|
|
|
|
type alias Data =
|
|
()
|
|
|
|
|
|
type SharedMsg
|
|
= NoOp
|
|
|
|
|
|
type alias Model =
|
|
{ showMenu : Bool
|
|
}
|
|
|
|
|
|
init :
|
|
Pages.Flags.Flags
|
|
->
|
|
Maybe
|
|
{ path :
|
|
{ path : UrlPath
|
|
, query : Maybe String
|
|
, fragment : Maybe String
|
|
}
|
|
, metadata : route
|
|
, pageUrl : Maybe PageUrl
|
|
}
|
|
-> ( Model, Effect Msg )
|
|
init flags maybePagePath =
|
|
( { showMenu = False }
|
|
, Effect.none
|
|
)
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Effect Msg )
|
|
update msg model =
|
|
case msg of
|
|
SharedMsg globalMsg ->
|
|
( model, Effect.none )
|
|
|
|
MenuClicked ->
|
|
( { model | showMenu = not model.showMenu }, Effect.none )
|
|
|
|
|
|
subscriptions : UrlPath -> Model -> Sub Msg
|
|
subscriptions _ _ =
|
|
Sub.none
|
|
|
|
|
|
data : BackendTask FatalError Data
|
|
data =
|
|
BackendTask.succeed ()
|
|
|
|
|
|
view :
|
|
Data
|
|
->
|
|
{ path : UrlPath
|
|
, route : Maybe Route
|
|
}
|
|
-> Model
|
|
-> (Msg -> msg)
|
|
-> View msg
|
|
-> { body : List (Html msg), title : String }
|
|
view tableOfContents page model toMsg pageView =
|
|
{ body =
|
|
[
|
|
-- ((View.Header.view ToggleMobileMenu 123 page.path
|
|
-- |> Html.Styled.map toMsg
|
|
-- )
|
|
-- :: TableOfContents.view model.showMobileMenu False Nothing tableOfContents
|
|
pageView.body
|
|
-- )
|
|
|> Html.Styled.div []
|
|
|> Html.Styled.toUnstyled
|
|
]
|
|
, title = pageView.title
|
|
}
|
|
-- view sharedData page model toMsg pageView =
|
|
-- { body =
|
|
-- [ Html.Styled.nav []
|
|
-- [ Html.Styled.button
|
|
-- [ Html.Styled.Events.onClick MenuClicked ]
|
|
-- [ Html.Styled.text
|
|
-- (if model.showMenu then
|
|
-- "Close Menu"
|
|
|
|
-- else
|
|
-- "Open Menu"
|
|
-- )
|
|
-- ]
|
|
-- , if model.showMenu then
|
|
-- Html.Styled.ul []
|
|
-- [ Html.Styled.li [] [ Html.Styled.text "Menu item 1" ]
|
|
-- , Html.Styled.li [] [ Html.Styled.text "Menu item 2" ]
|
|
-- ]
|
|
|
|
-- else
|
|
-- Html.Styled.text ""
|
|
-- ]
|
|
-- |> Html.Styled.map toMsg
|
|
-- , Html.Styled.main_ [] pageView.body
|
|
-- ]
|
|
-- , title = pageView.title
|
|
-- }
|