on master help sign in
x230/src/Shared.elm
113 lines 2.3 kB history raw
1module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
3import Browser.Navigation
4import DataSource
5import Element exposing (..)
6import Element.Background as Background
7import Element.Font as Font
8import Html exposing (Html)
9import Pages.Flags
10import Pages.PageUrl exposing (PageUrl)
11import Path exposing (Path)
12import Route exposing (Route)
13import SharedTemplate exposing (SharedTemplate)
14import View exposing (View)
17template : SharedTemplate Msg Model Data msg
18template =
19 { init = init
20 , update = update
21 , view = view
22 , data = data
23 , subscriptions = subscriptions
24 , onPageChange = Just OnPageChange
25 }
28type Msg
29 = OnPageChange
30 { path : Path
31 , query : Maybe String
32 , fragment : Maybe String
33 }
34 | SharedMsg SharedMsg
37type alias Data =
38 ()
41type SharedMsg
42 = NoOp
45type alias Model =
46 {}
49init :
50 Maybe Browser.Navigation.Key
51 -> Pages.Flags.Flags
52 ->
53 Maybe
54 { path :
55 { path : Path
56 , query : Maybe String
57 , fragment : Maybe String
58 }
59 , metadata : route
60 , pageUrl : Maybe PageUrl
61 }
62 -> ( Model, Cmd Msg )
63init navigationKey flags maybePagePath =
64 ( {}
65 , Cmd.none
66 )
69update : Msg -> Model -> ( Model, Cmd Msg )
70update msg model =
71 case msg of
72 OnPageChange _ ->
73 ( model, Cmd.none )
75 SharedMsg globalMsg ->
76 ( model, Cmd.none )
79subscriptions : Path -> Model -> Sub Msg
80subscriptions _ _ =
81 Sub.none
84data : DataSource.DataSource Data
85data =
86 DataSource.succeed ()
89view :
90 Data
91 ->
92 { path : Path
93 , route : Maybe Route
94 }
95 -> Model
96 -> (Msg -> msg)
97 -> View msg
98 -> { body : Html msg, title : String }
99view sharedData page model toMsg pageView =
100 { body =
101 Element.layout
102 [ padding 16
103 , Background.color (rgb 0 0 0)
104 , Font.color (rgb 0 1 0)
105 , clip
106 , behindContent
107 (image [ height (px 700), alignRight ]
108 { src = "x230.png", description = "Exploded Thinkpad X230" }
109 )
110 ]
111 (el [ width (maximum 800 fill), centerX ] pageView.body)
112 , title = pageView.title
113 }