Adds mostly blank Block module

This commit is contained in:
Tessa Kelly 2022-11-07 14:29:07 -07:00
parent 6cce516934
commit e6521c29a1
2 changed files with 66 additions and 0 deletions

View File

@ -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",

65
src/Nri/Ui/Block/V1.elm Normal file
View File

@ -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