2021-06-01 20:36:52 +03:00
|
|
|
module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
|
|
|
|
|
|
|
|
import Browser.Navigation
|
|
|
|
import DataSource
|
|
|
|
import Html exposing (Html)
|
|
|
|
import Pages.Flags
|
|
|
|
import Pages.PageUrl exposing (PageUrl)
|
|
|
|
import Path exposing (Path)
|
2021-07-28 20:29:06 +03:00
|
|
|
import Route exposing (Route)
|
2021-06-01 20:36:52 +03:00
|
|
|
import SharedTemplate exposing (SharedTemplate)
|
|
|
|
import View exposing (View)
|
|
|
|
|
|
|
|
|
2021-07-28 20:29:06 +03:00
|
|
|
template : SharedTemplate Msg Model Data msg
|
2021-06-01 20:36:52 +03:00
|
|
|
template =
|
|
|
|
{ init = init
|
|
|
|
, update = update
|
|
|
|
, view = view
|
|
|
|
, data = data
|
|
|
|
, subscriptions = subscriptions
|
|
|
|
, onPageChange = Just OnPageChange
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type Msg
|
|
|
|
= OnPageChange
|
|
|
|
{ path : Path
|
|
|
|
, query : Maybe String
|
|
|
|
, fragment : Maybe String
|
|
|
|
}
|
|
|
|
| SharedMsg SharedMsg
|
|
|
|
|
|
|
|
|
|
|
|
type alias Data =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
|
|
|
type SharedMsg
|
|
|
|
= NoOp
|
|
|
|
|
|
|
|
|
|
|
|
type alias Model =
|
|
|
|
{ showMobileMenu : Bool
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
init :
|
|
|
|
Maybe Browser.Navigation.Key
|
|
|
|
-> Pages.Flags.Flags
|
|
|
|
->
|
|
|
|
Maybe
|
|
|
|
{ path :
|
|
|
|
{ path : Path
|
|
|
|
, query : Maybe String
|
|
|
|
, fragment : Maybe String
|
|
|
|
}
|
|
|
|
, metadata : route
|
|
|
|
, pageUrl : Maybe PageUrl
|
|
|
|
}
|
|
|
|
-> ( Model, Cmd Msg )
|
|
|
|
init navigationKey flags maybePagePath =
|
|
|
|
( { showMobileMenu = False }
|
|
|
|
, Cmd.none
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
update : Msg -> Model -> ( Model, Cmd Msg )
|
|
|
|
update msg model =
|
|
|
|
case msg of
|
|
|
|
OnPageChange _ ->
|
|
|
|
( { model | showMobileMenu = False }, Cmd.none )
|
|
|
|
|
|
|
|
SharedMsg globalMsg ->
|
|
|
|
( model, Cmd.none )
|
|
|
|
|
|
|
|
|
|
|
|
subscriptions : Path -> Model -> Sub Msg
|
|
|
|
subscriptions _ _ =
|
|
|
|
Sub.none
|
|
|
|
|
|
|
|
|
|
|
|
data : DataSource.DataSource Data
|
|
|
|
data =
|
|
|
|
DataSource.succeed ()
|
|
|
|
|
|
|
|
|
|
|
|
view :
|
|
|
|
Data
|
|
|
|
->
|
|
|
|
{ path : Path
|
2021-07-28 20:29:06 +03:00
|
|
|
, route : Maybe Route
|
2021-06-01 20:36:52 +03:00
|
|
|
}
|
|
|
|
-> Model
|
|
|
|
-> (Msg -> msg)
|
|
|
|
-> View msg
|
|
|
|
-> { body : Html msg, title : String }
|
|
|
|
view sharedData page model toMsg pageView =
|
|
|
|
{ body = Html.div [] pageView.body
|
|
|
|
, title = pageView.title
|
|
|
|
}
|