summaryrefslogtreecommitdiffstats
path: root/src/Pages
diff options
context:
space:
mode:
authorJan Tuomi <jan.tuomi@valuemotive.com>2021-10-29 16:52:15 +0300
committerJan Tuomi <jan.tuomi@valuemotive.com>2021-10-29 16:52:15 +0300
commite500394ed975055657fde19d3cd1c106888734b5 (patch)
tree56990da5fd026bc6321fef3bba113b0e486cc216 /src/Pages
parenta972058d20b773f4488df51babb40156c5a335e1 (diff)
Implement stuff
Diffstat (limited to 'src/Pages')
-rw-r--r--src/Pages/Feed.elm57
1 files changed, 35 insertions, 22 deletions
diff --git a/src/Pages/Feed.elm b/src/Pages/Feed.elm
index a848200..583c097 100644
--- a/src/Pages/Feed.elm
+++ b/src/Pages/Feed.elm
@@ -3,10 +3,10 @@ module Pages.Feed exposing (..)
import Css exposing (..)
import DateFormat.Relative exposing (relativeTime)
import Html.Styled exposing (..)
-import Html.Styled.Attributes exposing (css)
-import Html.Styled.Events exposing (onClick)
+import Html.Styled.Attributes exposing (css, placeholder, type_, value)
+import Html.Styled.Events exposing (onClick, onInput, onSubmit)
import Time exposing (now)
-import Types exposing (DisplayableError(..), Model, Msg(..), Post)
+import Types exposing (Model, Msg(..), Post)
styles =
@@ -19,6 +19,7 @@ styles =
css
[ padding2 (px 15) (px 20)
, backgroundColor (hex "#eee")
+ , marginBottom (px 10)
]
, postTitle =
css
@@ -28,25 +29,18 @@ styles =
[ marginRight (px 5)
, cursor pointer
]
+ , composeForm =
+ css
+ [ displayFlex
+ , flexFlow2 row wrap
+ ]
+ , composeInput =
+ css
+ [ flex (int 1)
+ ]
}
-derrorToHtml : DisplayableError -> Html Msg
-derrorToHtml derror =
- case derror of
- DNoError ->
- text ""
-
- DHttpError httpErr ->
- text <| Debug.toString httpErr
-
-
-derrorDiv : Model -> Html Msg
-derrorDiv model =
- div []
- [ derrorToHtml model.displayError ]
-
-
postDiv : Time.Posix -> Post -> Html Msg
postDiv now post =
div [ styles.post ]
@@ -64,7 +58,26 @@ postDiv now post =
postsDiv : Model -> Html Msg
postsDiv model =
- div [] <| List.map (postDiv model.now) model.posts
+ case model.posts of
+ Just posts ->
+ div [] <| List.map (postDiv model.now) posts
+
+ Nothing ->
+ div [] [ text "Loading posts..." ]
+
+
+composeDiv : Model -> Html Msg
+composeDiv model =
+ form [ styles.composeForm, onSubmit ComposePost ]
+ [ input
+ [ styles.composeInput
+ , placeholder "Type a new post..."
+ , onInput ComposeInputChanged
+ , value model.composeInputValue
+ ]
+ []
+ , button [ type_ "submit" ] [ text "➡️" ]
+ ]
headerSection : Model -> Html msg
@@ -77,8 +90,8 @@ headerSection _ =
mainSection : Model -> Html Msg
mainSection model =
main_ [] <|
- [ derrorDiv model
- , postsDiv model
+ [ postsDiv model
+ , composeDiv model
]