diff options
author | Yorhel <git@yorhel.nl> | 2019-12-06 13:37:24 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-12-06 13:37:24 +0100 |
commit | cd57e89ecfadbdc49b02fc0d19c043cdf7229a66 (patch) | |
tree | bd8bd260f79c51221bca1ae1ee24f7b9753009fc /elm/Lib/TextPreview.elm | |
parent | 6487d1e89b14a4c85bb47c03fbe4d7e2f37e73d3 (diff) |
Add link to d9#3 to quick reply box + allow customizing TextPreview header
Diffstat (limited to 'elm/Lib/TextPreview.elm')
-rw-r--r-- | elm/Lib/TextPreview.elm | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/elm/Lib/TextPreview.elm b/elm/Lib/TextPreview.elm index 2d565e5f..fba61ff3 100644 --- a/elm/Lib/TextPreview.elm +++ b/elm/Lib/TextPreview.elm @@ -66,23 +66,26 @@ update msg model = HandlePreview r -> ({ model | state = Api.Error r }, Cmd.none) -view : String -> Model -> (Msg -> m) -> Int -> List (Attribute m) -> Html m -view name model cmdmap width attr = +view : String -> Model -> (Msg -> m) -> Int -> List (Attribute m) -> List (Html m) -> Html m +view name model cmdmap width attr header = let display = model.display && model.preview /= "" in div [ class "textpreview", style "width" (String.fromInt width ++ "px") ] - [ p (class "head" :: (if model.data == "" then [class "invisible"] else [])) - [ case model.state of - Api.Loading -> span [ class "spinner" ] [] - Api.Error _ -> b [ class "grayedout" ] [ text "Error loading preview. " ] - Api.Normal -> text "" - , if display - then a [ onClickN (cmdmap TextArea) ] [ text "Edit" ] - else i [] [text "Edit"] - , if display - then i [] [text "Preview"] - else a [ onClickN (cmdmap Preview) ] [ text "Preview" ] + [ span [] + [ p [] header + , p [ class "right", classList [("invisible", model.data == "")] ] + [ case model.state of + Api.Loading -> span [ class "spinner" ] [] + Api.Error _ -> b [ class "grayedout" ] [ text "Error loading preview. " ] + Api.Normal -> text "" + , if display + then a [ onClickN (cmdmap TextArea) ] [ text "Edit" ] + else i [] [text "Edit"] + , if display + then i [] [text "Preview"] + else a [ onClickN (cmdmap Preview) ] [ text "Preview" ] + ] ] , inputTextArea name model.data (cmdmap << Edit) (class (if display then "hidden" else "") :: attr) , if not display then text "" |