1
0
mirror of https://github.com/jhillyerd/inbucket.git synced 2025-12-18 10:07:02 +00:00

ui: Add greeting.html to Home

This commit is contained in:
James Hillyerd
2018-11-12 20:21:37 -08:00
parent d1954cdd6f
commit 2bbcef072a
6 changed files with 61 additions and 29 deletions

View File

@@ -36,8 +36,11 @@ init sessionValue location =
session =
Session.init location (Session.decodeValueWithDefault sessionValue)
( subModel, _ ) =
Home.init
model =
{ page = Home Home.init
{ page = Home subModel
, session = session
, mailboxName = ""
}
@@ -182,8 +185,12 @@ setRoute route model =
( model, Cmd.none, Session.SetFlash ("Unknown route requested: " ++ hash) )
Route.Home ->
( { model | page = Home Home.init }
, Ports.windowTitle "Inbucket"
let
( subModel, subCmd ) =
Home.init
in
( { model | page = Home subModel }
, Cmd.map HomeMsg subCmd
, Session.none
)

View File

@@ -3,18 +3,33 @@ module Page.Home exposing (Model, Msg, init, update, view)
import Data.Session as Session exposing (Session)
import Html exposing (..)
import Html.Attributes exposing (..)
import Http
import HttpUtil
import Json.Encode as Encode
import Ports
-- MODEL --
type alias Model =
{}
{ greeting : String }
init : Model
init : ( Model, Cmd Msg )
init =
{}
( Model ""
, Cmd.batch
[ Ports.windowTitle "Inbucket"
, cmdGreeting
]
)
cmdGreeting : Cmd Msg
cmdGreeting =
Http.send GreetingResult <|
Http.getString "/serve/greeting"
@@ -22,12 +37,17 @@ init =
type Msg
= Msg
= GreetingResult (Result Http.Error String)
update : Session -> Msg -> Model -> ( Model, Cmd Msg, Session.Msg )
update session msg model =
( model, Cmd.none, Session.none )
case msg of
GreetingResult (Ok greeting) ->
( Model greeting, Cmd.none, Session.none )
GreetingResult (Err err) ->
( model, Cmd.none, Session.SetFlash (HttpUtil.errorString err) )
@@ -37,6 +57,9 @@ update session msg model =
view : Session -> Model -> Html Msg
view session model =
div [ id "page" ]
[ h1 [] [ text "Inbucket" ]
, text "This is the home page"
[ div
[ class "greeting"
, property "innerHTML" (Encode.string model.greeting)
]
[]
]

View File

@@ -30,6 +30,11 @@ time, mark, audio, video {
vertical-align: baseline;
}
::placeholder {
color: var(--placeholder-color);
opacity: 1;
}
a {
color: #337ab7;
text-decoration: none;
@@ -46,9 +51,8 @@ body, input, table {
color: var(--primary-color);
}
::placeholder {
color: var(--placeholder-color);
opacity: 1;
h1, h2, h3, h4, h5, h6, p {
margin-bottom: 10px;
}
/** SHARED */
@@ -129,6 +133,10 @@ h1 {
font-weight: 500;
}
.greeting {
max-width: 1000px;
}
/** NAV BAR */
.navbar,