Corex. Content
(Corex v0.2.0)
View Source
Content items for components with trigger/content patterns to be used with:
Use Corex.Content.new/1 to build a list of items from maps or keyword lists.
What the items attr accepts
Accordion, DataList and Tabs accept Corex.Content.Item structs only, and this
is the whole contract. A plain map raises with the new/1 call that would have
built it, unlike Corex.List, which coerces: content panels are authored in a
template rather than mapped from a query result, so a wrong shape is a developer
mistake to surface rather than a bad row to skip.
Each item requires :value, :label and :content, with :disabled and
:meta optional. See Corex.Item for the fields shared with Corex.List.Item
and Corex.Tree.Item.
Summary
Functions
Asserts that a component's :items assign holds Item structs.
Creates a list of Content.Item structs from a list of maps or keyword lists.
Functions
Asserts that a component's :items assign holds Item structs.
See Corex.Item.assert_items!/3 for why this raises where Corex.Value
coerces.
@spec new(list()) :: [Corex.Content.Item.t()]
Creates a list of Content.Item structs from a list of maps or keyword lists.
Fields
:label- (required) Text shown in the trigger/header region:content- (required) Content to display in the content area:value- (optional) Unique identifier (item-1,item-2, … when omitted):disabled- (optional) Whether the item is disabled, defaults tofalse:meta- (optional) Additional metadata map for the item
Examples
Corex.Content.new([
%{label: "Lorem ipsum dolor sit amet", content: "Consectetur adipiscing elit."},
%{value: "duis", label: "Duis", content: "Nullam eget vestibulum ligula."},
%{value: "donec", label: "Donec", content: "Congue molestie ipsum gravida a.", disabled: true}
])Raises ArgumentError if items is not a list of maps or keyword lists.