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
|
|
|
|
|
|
|
-}
|
|
|
|
|
2019-10-11 01:44:39 +03:00
|
|
|
import Css
|
2019-05-23 21:53:19 +03:00
|
|
|
import Html.Styled exposing (div, h3, text)
|
2019-10-11 01:44:39 +03:00
|
|
|
import Html.Styled.Attributes as Attributes
|
2019-03-21 23:50:59 +03:00
|
|
|
import ModuleExample as ModuleExample exposing (Category(..), ModuleExample)
|
2019-10-11 01:05:41 +03:00
|
|
|
import Nri.Ui.BannerAlert.V6 as BannerAlert
|
2019-10-11 01:44:39 +03:00
|
|
|
import Nri.Ui.Fonts.V1 as Fonts
|
2019-10-11 01:54:22 +03:00
|
|
|
import Nri.Ui.Svg.V1 as Svg
|
|
|
|
import Nri.Ui.UiIcon.V1 as UiIcon
|
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 =
|
2019-10-11 01:05:41 +03:00
|
|
|
{ name = "Nri.Ui.BannerAlert.V6"
|
2019-03-21 23:50:59 +03:00
|
|
|
, category = Messaging
|
|
|
|
, content =
|
2019-05-23 21:53:19 +03:00
|
|
|
[ if state.show then
|
|
|
|
div
|
|
|
|
[]
|
|
|
|
[ h3 [] [ text "alert" ]
|
2019-10-11 01:44:39 +03:00
|
|
|
, BannerAlert.alert
|
|
|
|
[ Html.Styled.text "This is a dismissable alert message!" ]
|
|
|
|
(Just Dismiss)
|
2019-05-23 21:53:19 +03:00
|
|
|
]
|
|
|
|
|
|
|
|
else
|
|
|
|
div
|
|
|
|
[]
|
|
|
|
[ h3 [] [ text "success" ]
|
2019-10-11 01:44:39 +03:00
|
|
|
, BannerAlert.success
|
|
|
|
[ Html.Styled.text "The alert message was dismissed. 👍" ]
|
|
|
|
Nothing
|
2019-05-23 21:53:19 +03:00
|
|
|
]
|
2019-05-22 21:23:50 +03:00
|
|
|
, h3 [] [ text "error" ]
|
2019-10-11 01:44:39 +03:00
|
|
|
, BannerAlert.error
|
|
|
|
[ Html.Styled.text "This is an error message!" ]
|
|
|
|
Nothing
|
2020-02-18 00:45:59 +03:00
|
|
|
, h3 [] [ text "with link and icon" ]
|
2019-05-30 19:08:53 +03:00
|
|
|
, BannerAlert.error
|
2019-10-11 01:44:39 +03:00
|
|
|
[ Html.Styled.div
|
2020-02-18 00:55:33 +03:00
|
|
|
[]
|
2019-10-11 01:44:39 +03:00
|
|
|
[ Html.Styled.text "Click "
|
|
|
|
, Html.Styled.a
|
|
|
|
[ Attributes.href "http://www.noredink.com"
|
|
|
|
, Attributes.target "_blank"
|
|
|
|
]
|
2020-02-18 00:45:59 +03:00
|
|
|
[ Html.Styled.text "here" ]
|
|
|
|
, Html.Styled.text " "
|
2019-10-11 01:54:22 +03:00
|
|
|
, Html.Styled.div
|
|
|
|
[ Attributes.css
|
|
|
|
[ Css.display Css.inlineBlock
|
|
|
|
, Css.width (Css.px 20)
|
|
|
|
]
|
|
|
|
]
|
|
|
|
[ Svg.toHtml UiIcon.gear ]
|
2019-10-11 01:44:39 +03:00
|
|
|
, Html.Styled.text " to check out NoRedInk."
|
|
|
|
]
|
|
|
|
]
|
2019-05-30 19:08:53 +03:00
|
|
|
Nothing
|
2020-02-18 00:55:33 +03:00
|
|
|
, h3 [] [ text "with multi-line link" ]
|
2020-02-18 00:45:59 +03:00
|
|
|
, BannerAlert.error
|
|
|
|
[ Html.Styled.div
|
2020-02-18 00:55:33 +03:00
|
|
|
[]
|
2020-02-18 00:45:59 +03:00
|
|
|
[ Html.Styled.text "Click "
|
|
|
|
, Html.Styled.a
|
|
|
|
[ Attributes.href "http://www.noredink.com"
|
|
|
|
, Attributes.target "_blank"
|
|
|
|
]
|
|
|
|
[ Html.Styled.text "donec ullamcorper nulla non metus auctor fringilla donec ullamcorper nulla non metus auctor fringilla" ]
|
|
|
|
, Html.Styled.text " to check out NoRedInk."
|
|
|
|
]
|
|
|
|
]
|
|
|
|
Nothing
|
2019-03-21 23:50:59 +03:00
|
|
|
, h3 [] [ text "neutral" ]
|
2019-10-11 01:44:39 +03:00
|
|
|
, BannerAlert.neutral
|
|
|
|
[ Html.Styled.text "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-10-11 01:44:39 +03:00
|
|
|
[ Html.Styled.text """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-10-11 01:44:39 +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 =
|
2019-05-23 21:53:19 +03:00
|
|
|
{ show : Bool }
|
2019-05-23 00:38:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
init : State
|
|
|
|
init =
|
2019-05-23 21:53:19 +03:00
|
|
|
{ show = True }
|
2019-05-23 00:38:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
type Msg
|
|
|
|
= NoOp
|
2019-05-23 21:53:19 +03:00
|
|
|
| Dismiss
|
2019-05-23 00:38:11 +03:00
|
|
|
|
|
|
|
|
|
|
|
update : Msg -> State -> State
|
|
|
|
update msg state =
|
|
|
|
case msg of
|
|
|
|
NoOp ->
|
|
|
|
state
|
2019-05-23 21:53:19 +03:00
|
|
|
|
|
|
|
Dismiss ->
|
|
|
|
{ state | show = False }
|