NoRedInk/noredink-ui/21.13.2

NOTE: the latest version is 35.9.3

Nri.Ui.Block.V1

view : List Attribute -> List (Html msg)
Block.view [ Block.plaintext "Hello, world!" ]

Content

plaintext : String -> Attribute

Provide the main content of the block as a plain-text string. You can also use content for more complex cases, including a blank appearing within an emphasis.

Use content for more complex block views, for instance when a blank appears within an emphasis block. Prefer to use plaintext when possible for better readability.

Block.view
    [ Block.emphasize
    , Block.content [ Block.string "Hello, ", Block.blank, Block.string "!" ]
    ]
type Content
phrase : String -> List Content

You will only need to use this helper if you're also using content to construct a more complex Block. For a less complex blank Block, don't include content or plaintext in the list of attributes.

Deprecated

string : String -> Content

DEPRECATED -- prefer phrase.

Content customization

Mark content as emphasized.

label : String -> Attribute
Maybe
{ totalHeight : Float
, arrowHeight : Float
}

Use getLabelHeights to calculate what these values should be.

Visual customization

General attributes

class : String -> Attribute
id : String -> Attribute

Accessors

You will need these helpers if you want to prevent label overlaps. (Which is to say -- anytime you have labels!)

labelId : String -> String
labelContentId : String -> String
List String
-> Dict
String
{ label : Element
, labelContent : Element
}
-> Dict
String
{ totalHeight : Float
, arrowHeight : Float
}
Pass in a list of the Block ids that you care about (use `Block.id` to attach these ids).


- First, we add ids to block with labels with `Block.id`.
- Say we added `Block.id "example-id"`, then we will use `Browser.Dom.getElement (Block.labelId "example-id")` and `Browser.Dom.getElement (Block.labelContentId "example-id")` to construct a record in the shape { label : Dom.Element, labelContent : Dom.Element }. We store this record in a dictionary keyed by ids (e.g., "example-id") with measurements for all other labels.
- Pass a list of all the block ids and the dictionary of measurements to `getLabelHeights`. `getLabelHeights` will return a dictionary of values (keyed by ids) that we will then pass directly to `labelHeight` for positioning.

Modules