git.iko.soy/horeca-productions/landing
on master help sign in
97 lines 1.9 kB history raw
1module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
3import BackendTask exposing (BackendTask)
4import Effect exposing (Effect)
5import Element exposing (layout)
6import FatalError exposing (FatalError)
7import Html exposing (Html)
8import Pages.Flags
9import Pages.PageUrl exposing (PageUrl)
10import Route exposing (Route)
11import SharedTemplate exposing (SharedTemplate)
12import UrlPath exposing (UrlPath)
13import View exposing (View)
16template : SharedTemplate Msg Model Data msg
17template =
18 { init = init
19 , update = update
20 , view = view
21 , data = data
22 , subscriptions = subscriptions
23 , onPageChange = Nothing
24 }
27type Msg
28 = SharedMsg SharedMsg
29 | MenuClicked
32type alias Data =
33 ()
36type SharedMsg
37 = NoOp
40type alias Model =
41 { showMenu : Bool
42 }
45init :
46 Pages.Flags.Flags
47 ->
48 Maybe
49 { path :
50 { path : UrlPath
51 , query : Maybe String
52 , fragment : Maybe String
53 }
54 , metadata : route
55 , pageUrl : Maybe PageUrl
56 }
57 -> ( Model, Effect Msg )
58init flags maybePagePath =
59 ( { showMenu = False }
60 , Effect.none
61 )
64update : Msg -> Model -> ( Model, Effect Msg )
65update msg model =
66 case msg of
67 SharedMsg globalMsg ->
68 ( model, Effect.none )
70 MenuClicked ->
71 ( { model | showMenu = not model.showMenu }, Effect.none )
74subscriptions : UrlPath -> Model -> Sub Msg
75subscriptions _ _ =
76 Sub.none
79data : BackendTask FatalError Data
80data =
81 BackendTask.succeed ()
84view :
85 Data
86 ->
87 { path : UrlPath
88 , route : Maybe Route
89 }
90 -> Model
91 -> (Msg -> msg)
92 -> View msg
93 -> { body : List (Html msg), title : String }
94view sharedData page model toMsg pageView =
95 { body = [ layout [] pageView.body ]
96 , title = pageView.title
97 }