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

82 lines
2.2 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-30 19:08:53 +03:00
import Nri.Ui.BannerAlert.V5 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.V5"
2019-03-21 23:50:59 +03:00
, category = Messaging
, content =
[ if state.show then
div
[]
[ h3 [] [ text "alert" ]
2019-05-30 19:08:53 +03:00
, BannerAlert.alert (BannerAlert.Plain "This is a dismissable alert message!") (Just Dismiss)
]
else
div
[]
[ h3 [] [ text "success" ]
2019-05-30 19:08:53 +03:00
, BannerAlert.success (BannerAlert.Plain "The alert message was dismissed. 👍") Nothing
]
2019-05-22 21:23:50 +03:00
, h3 [] [ text "error" ]
2019-05-30 19:08:53 +03:00
, BannerAlert.error (BannerAlert.Plain "This is an error message!") Nothing
, h3 [] [ text "error with link" ]
, BannerAlert.error
(BannerAlert.WithLink
{ prefixText = "Click "
, linkText = "here"
, linkUrl = "http://www.noredink.com"
, postfixText = " to check out NoRedInk."
2019-05-30 19:08:53 +03:00
, target = BannerAlert.Blank
}
)
Nothing
2019-03-21 23:50:59 +03:00
, h3 [] [ text "neutral" ]
2019-05-30 19:08:53 +03:00
, BannerAlert.neutral (BannerAlert.Plain "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-05-30 19:08:53 +03:00
(BannerAlert.Plain """This is a success message!
2019-03-21 23:50:59 +03:00
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-30 19:08:53 +03:00
""")
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 }