module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template) import BackendTask exposing (BackendTask) import Effect exposing (Effect) import FatalError exposing (FatalError) import Header exposing (header) import Html exposing (Html) import Html.Styled import Html.Styled.Events import Link exposing (Link) import Pages.Flags import Pages.PageUrl exposing (PageUrl) import Route exposing (Route) import SharedTemplate exposing (SharedTemplate) import UrlPath exposing (UrlPath) 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 = [ header |> Html.Styled.toUnstyled -- ((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 -- }