💀 remove mapContent

This commit is contained in:
Tessa Kelly 2020-08-28 13:21:49 -07:00
parent cc6ccd400f
commit e99c085cae
2 changed files with 6 additions and 27 deletions

View File

@ -1,6 +1,6 @@
module Nri.Ui.Message.V2 exposing
( tiny, large, banner
, Theme(..), Content(..), mapContent
, Theme(..), Content(..)
, Attribute
, alert, alertDialog
, onDismiss
@ -12,9 +12,10 @@ module Nri.Ui.Message.V2 exposing
- adds `alert`, `alertDialog` role attributes
- rename BannerAttribute -> Attribute
- accept Attributes on any Message type
- :skull: remove mapContent
@docs tiny, large, banner
@docs Theme, Content, mapContent
@docs Theme, Content
Attributes:
@ -70,21 +71,6 @@ type Content msg
| Html (List (Html msg))
{-| Transform the messages produced by some `Content`.
-}
mapContent : (a -> b) -> Content a -> Content b
mapContent f content =
case content of
Plain string ->
Plain string
Markdown string ->
Markdown string
Html html ->
Html (List.map (Html.map f) html)
{-| PRIVATE
-}
contentToHtml : Content msg -> List (Html msg)

View File

@ -26,7 +26,7 @@ type alias State =
type alias ExampleConfig =
{ size : Message.Theme -> Message.Content Msg -> List (Message.Attribute Msg) -> Html Msg
, theme : Message.Theme
, content : Message.Content Never
, content : Message.Content Msg
, role : Maybe (Message.Attribute Msg)
, dismissable : Maybe (Message.Attribute Msg)
}
@ -134,17 +134,13 @@ controlDismissable =
type Msg
= NoOp
| Dismiss
= Dismiss
| UpdateControl (Control ExampleConfig)
update : Msg -> State -> ( State, Cmd Msg )
update msg state =
case msg of
NoOp ->
( state, Cmd.none )
Dismiss ->
( { state | show = False }, Cmd.none )
@ -167,9 +163,6 @@ example =
{ size, role, theme, dismissable, content } =
Control.currentValue state.control
content_ =
Message.mapContent never content
attributes =
List.filterMap identity [ role, dismissable ]
@ -183,7 +176,7 @@ example =
[ Control.view UpdateControl state.control
|> Html.fromUnstyled
, Heading.h3 [] [ text "Message.view" ]
, orDismiss <| size theme content_ attributes
, orDismiss <| size theme content attributes
, Heading.h3 [] [ text "Message.somethingWentWrong" ]
, Message.somethingWentWrong exampleRailsError
]