noredink-ui/styleguide-app/Examples/BannerAlert.elm

71 lines
1.7 KiB
Elm
Raw Normal View History

2019-05-23 00:38:11 +03:00
module Examples.BannerAlert exposing (example, State, init, Msg, update)
2019-03-21 23:50:59 +03:00
{-|
2019-05-23 00:38:11 +03:00
@docs example, State, init, Msg, update
2019-03-21 23:50:59 +03:00
-}
import Html.Styled exposing (div, h3, text)
2019-03-21 23:50:59 +03:00
import ModuleExample as ModuleExample exposing (Category(..), ModuleExample)
2019-05-22 21:23:50 +03:00
import Nri.Ui.BannerAlert.V4 as BannerAlert
2019-03-21 23:50:59 +03:00
2019-05-23 00:38:11 +03:00
example : (Msg -> msg) -> State -> ModuleExample msg
example parentMsg state =
{ name = "Nri.Ui.BannerAlert.V4"
2019-03-21 23:50:59 +03:00
, category = Messaging
, content =
[ if state.show then
div
[]
[ h3 [] [ text "alert" ]
, BannerAlert.alert "This is a dismissable alert message!" (Just Dismiss)
]
else
div
[]
[ h3 [] [ text "success" ]
2019-05-24 00:29:03 +03:00
, BannerAlert.success "The alert message was dismissed. 👍" Nothing
]
2019-05-22 21:23:50 +03:00
, h3 [] [ text "error" ]
2019-05-23 00:38:11 +03:00
, BannerAlert.error "This is an error message!" Nothing
2019-03-21 23:50:59 +03:00
, h3 [] [ text "neutral" ]
2019-05-23 00:38:11 +03:00
, BannerAlert.neutral "This is a neutral message!" Nothing
2019-03-21 23:50:59 +03:00
, h3 [] [ text "success" ]
2019-03-28 23:48:30 +03:00
, BannerAlert.success
2019-03-21 23:50:59 +03:00
"""This is a success message!
Let's see what happens if there is a very long message!
Wow, how successful! You're the biggest success I've ever seen!
You should feel great about yourself! Give yourself a very big round of applause!
"""
2019-05-23 00:38:11 +03:00
Nothing
2019-03-21 23:50:59 +03:00
]
2019-05-23 00:38:11 +03:00
|> List.map (Html.Styled.map parentMsg)
2019-03-21 23:50:59 +03:00
}
2019-05-23 00:38:11 +03:00
type alias State =
{ show : Bool }
2019-05-23 00:38:11 +03:00
init : State
init =
{ show = True }
2019-05-23 00:38:11 +03:00
type Msg
= NoOp
| Dismiss
2019-05-23 00:38:11 +03:00
update : Msg -> State -> State
update msg state =
case msg of
NoOp ->
state
Dismiss ->
{ state | show = False }