git.iko.soy/gigawork-coworking/gigawork-coworking.github.io
on master help sign in
110 lines 2.4 kB history raw
1module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
3import BackendTask exposing (BackendTask)
4import Effect exposing (Effect)
5import Element exposing (..)
6import Element.Background as Background
7import FatalError exposing (FatalError)
8import Html exposing (Html)
9import Html.Attributes as Attributes
10import Pages.Flags
11import Pages.PageUrl exposing (PageUrl)
12import Route exposing (Route)
13import SharedTemplate exposing (SharedTemplate)
14import UrlPath exposing (UrlPath)
15import View exposing (View)
18template : SharedTemplate Msg Model Data msg
19template =
20 { init = init
21 , update = update
22 , view = view
23 , data = data
24 , subscriptions = subscriptions
25 , onPageChange = Nothing
26 }
29type Msg
30 = SharedMsg SharedMsg
31 | MenuClicked
34type alias Data =
35 ()
38type SharedMsg
39 = NoOp
42type alias Model =
43 { showMenu : Bool
44 }
47init :
48 Pages.Flags.Flags
49 ->
50 Maybe
51 { path :
52 { path : UrlPath
53 , query : Maybe String
54 , fragment : Maybe String
55 }
56 , metadata : route
57 , pageUrl : Maybe PageUrl
58 }
59 -> ( Model, Effect Msg )
60init flags maybePagePath =
61 ( { showMenu = False }
62 , Effect.none
63 )
66update : Msg -> Model -> ( Model, Effect Msg )
67update msg model =
68 case msg of
69 SharedMsg globalMsg ->
70 ( model, Effect.none )
72 MenuClicked ->
73 ( { model | showMenu = not model.showMenu }, Effect.none )
76subscriptions : UrlPath -> Model -> Sub Msg
77subscriptions _ _ =
78 Sub.none
81data : BackendTask FatalError Data
82data =
83 BackendTask.succeed ()
86view :
87 Data
88 ->
89 { path : UrlPath
90 , route : Maybe Route
91 }
92 -> Model
93 -> (Msg -> msg)
94 -> View msg
95 -> { body : List (Html msg), title : String }
96view sharedData page model toMsg pageView =
97 { body =
98 [ Html.div []
99 [ Html.img
100 [ Attributes.src "https://mc.yandex.ru/watch/99382050"
101 , Attributes.style "position" "absolute"
102 , Attributes.style "left" "-9999px;"
103 , Attributes.alt ""
104 ]
105 []
106 ]
107 , layout [ Background.color (rgb255 243 243 243) ] pageView.body
108 ]
109 , title = pageView.title
110 }