mirror of
https://github.com/NoRedInk/noredink-ui.git
synced 2024-09-21 12:19:03 +03:00
Adds mostly blank Block module
This commit is contained in:
parent
6cce516934
commit
e6521c29a1
1
elm.json
1
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",
|
||||
|
65
src/Nri/Ui/Block/V1.elm
Normal file
65
src/Nri/Ui/Block/V1.elm
Normal 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
|
Loading…
Reference in New Issue
Block a user