diff --git a/elm.json b/elm.json index c815c74f..0aaf3d32 100644 --- a/elm.json +++ b/elm.json @@ -12,6 +12,7 @@ "Nri.Ui.AssetPath", "Nri.Ui.AssignmentIcon.V2", "Nri.Ui.Balloon.V1", + "Nri.Ui.Block.V1", "Nri.Ui.BreadCrumbs.V2", "Nri.Ui.Button.V10", "Nri.Ui.Carousel.V1", diff --git a/src/Nri/Ui/Block/V1.elm b/src/Nri/Ui/Block/V1.elm new file mode 100644 index 00000000..a3b8b1dc --- /dev/null +++ b/src/Nri/Ui/Block/V1.elm @@ -0,0 +1,65 @@ +module Nri.Ui.Block.V1 exposing + ( view, Attribute + , plaintext + ) + +{-| + +@docs view, Attribute + + +## Customization + +@docs plaintext + +-} + +import Accessibility.Styled exposing (..) + + +{-| + + Block.view [ Block.plaintext "Hello, world!" ] + +-} +view : List (Attribute msg) -> Html msg +view attributes = + attributes + |> List.foldl (\(Attribute attribute) b -> attribute b) defaultConfig + |> render + + + +-- Attributes + + +{-| Provide the main content of the block as a plain-text string. +-} +plaintext : String -> Attribute msg +plaintext content = + Attribute <| \config -> { config | content = [ text content ] } + + + +-- Internals + + +{-| -} +type Attribute msg + = Attribute (Config msg -> Config msg) + + +defaultConfig : Config msg +defaultConfig = + { content = [] + } + + +type alias Config msg = + { content : List (Html msg) + } + + +render : Config msg -> Html msg +render config = + span [] config.content