Utilities for building CSS class names based on BEM conventions, for Svg nodes.
Class attribute for unmodified block
Bem.init "my-block" |> Bem.block
-- class "my-block"Class attribute for unmodified element
Bem.init "my-block" |> .element "my-element" |> Bem.element
-- class "my-block__my-element"Class attribute for "flag" modified block
Bem.init "my-block" |> Bem.blockMod "flagged"
-- class "my-block my-block--flagged"Class attribute for "flag" modified element
Bem.init "my-block" |> .element "my-element" |> Bem.elementMod "flagged"
-- class "my-block__my-element my-block__my-element--flagged"Class attribute for "flag" modified block, based on given boolean flag
Bem.init "my-block" |> Bem.blockIf "flagged" isFlagged
-- class "my-block my-block--flagged" (if isFlagged is True)
-- class "my-block" (if isFlagged is False)Class attribute for "flag" modified element, based on given boolean flag
Bem.init "my-block" |> .element "my-element" |> Bem.elementIf "flagged" isFlagged
-- class "my-block__my-element my-block__my-element--flagged" (if isFlagged is True)
-- class "my-block__my-element" (if isFlagged is False)Class attribute for "flag" modified block, with multiple flags applied. Similar to Html.Attributes.classList for flag-modified blocks.
Bem.init "my-block"
|> Bem.blockList [ ( "flagged", isFlagged ), ( "editable", isEditable ) ]Class attribute for "flag" modified element, with multiple flags applied. Similar to Html.Attributes.classList for flag-modified elements.
Bem.init "my-block"
|> .element "my-element"
|> Bem.elementList [ ( "flagged", isFlagged ), ( "editable", isEditable ) ]Class attribute for "key-value" modified block
Bem.init "my-block" |> Bem.blockOf "type" "foo"
-- class "my-block my-block--type-foo"Class attribute for "key-value" modified element
Bem.init "my-block" |> .element "my-element" |> Bem.elementOf "type" "foo"
-- class "my-block__my-element my-block__my-element--type-foo"Class attribute for "key-value" modified block, with multiple key-value pairs applied.
Bem.init "my-block"
|> Bem.blockOfList [( "type", "foo" ), ( "status", "open" ) ]Class attribute for "key-value" modified element, with multiple key-value pairs applied.
Bem.init "my-block"
|> .element "my-element"
|> Bem.elementOfList [( "type", "foo" ), ( "status", "open" ) ]Element class string, e.g. "my-block__my-element"
Element class string with given flag modifier, e.g. "my-block__my-element--flag"
Element class string with given key-value modifier, e.g. "my-block__my-element--key-value"
Type for building block classes, and constructing elements of blocks.
Type for building element classes.
Construct a top-level Block with given name.
Note an Element can only be constructed through the
.elementof a Block like this: