Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to see a banner #357

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/Internal/Banner/Implementation.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Internal.Banner.Implementation exposing
, graphic
, graphicTextWrapper
, icon
, open
, stacked
, primaryAction
, secondaryAction
Expand Down Expand Up @@ -44,6 +45,11 @@ fixed =
Options.option (\config -> { config | fixed = True })


open : Property m
open =
modifier "open"


stacked : Property m
stacked =
modifier "mobile-stacked"
Expand Down Expand Up @@ -87,19 +93,31 @@ content options nodes =

graphicTextWrapper : List (Property m) -> List (Html m) -> Html m
graphicTextWrapper options nodes =
styled Html.div
let
({ config } as summary) =
Options.collect defaultConfig options
in
Options.apply summary
Html.div
[ element "graphic-text-wrapper"
]
[]
nodes


graphic : List (Property m) -> List (Html m) -> Html m
graphic options nodes =
styled Html.div
let
({ config } as summary) =
Options.collect defaultConfig options
in
Options.apply summary
Html.div
[ element "graphic"
, role "img"
, Options.attribute (alt "")
]
[]
nodes


Expand All @@ -114,9 +132,15 @@ icon name =

text : List (Property m) -> List (Html m) -> Html m
text options nodes =
styled Html.div
let
({ config } as summary) =
Options.collect defaultConfig options
in
Options.apply summary
Html.div
[ element "text"
]
[]
nodes


Expand Down
14 changes: 13 additions & 1 deletion src/Material/Banner.elm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Material.Banner exposing
, graphicTextWrapper
, graphic
, icon
, open
, stacked
, primaryAction
, secondaryAction
Expand All @@ -25,8 +26,9 @@ module Material.Banner exposing
# Example

import Material.Banner as Banner
import Material.Button as Button

Banner.view []
Banner.view [ Banner.open ]
[ Banner.graphicTextWrapper []
[ Banner.text [] [ text "There was a problem processing a transaction on your credit card." ]
]
Expand All @@ -49,6 +51,7 @@ module Material.Banner exposing
@docs view
@docs graphicTextWrapper
@docs actions
@docs open

# Variants

Expand Down Expand Up @@ -103,6 +106,15 @@ fixed =
Banner.fixed


{-| Make banner visible. No animation is used, and this is currently
the only way to make the banner visible. This property will disappear
in a future version when opening and closing animation will be added.
-}
open : Property m
open =
Banner.open


{-| On mobile view, banners with long text should have their action(s)
be positioned below the text instead of alongside it. It is usually
better to accomplish this with the Sass mixin, see documentation.
Expand Down