Class: LightningUiKit::DescriptionList::ItemComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::DescriptionList::ItemComponent
- Defined in:
- app/components/lightning_ui_kit/description_list/item_component.rb
Constant Summary collapse
- LABEL_CLASSES =
"lui:col-start-1 lui:min-w-0 lui:break-words lui:border-t lui:border-border-subtle lui:pt-3 lui:text-foreground-muted lui:first:border-none lui:sm:border-t lui:sm:border-border-subtle lui:sm:py-3"- VALUE_CLASSES =
"lui:min-w-0 lui:break-words lui:pt-1 lui:pb-3 lui:text-foreground lui:sm:border-t lui:sm:border-border-subtle lui:sm:py-3 lui:sm:first-of-type:border-none"
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(label:, value: nil, body: nil, **options) ⇒ ItemComponent
constructor
A new instance of ItemComponent.
- #label_classes ⇒ Object
- #value ⇒ Object
- #value_classes ⇒ Object
Constructor Details
#initialize(label:, value: nil, body: nil, **options) ⇒ ItemComponent
Returns a new instance of ItemComponent.
5 6 7 8 9 10 |
# File 'app/components/lightning_ui_kit/description_list/item_component.rb', line 5 def initialize(label:, value: nil, body: nil, **) @label = label @value = value @body = body @options = end |
Instance Method Details
#data ⇒ Object
20 21 22 |
# File 'app/components/lightning_ui_kit/description_list/item_component.rb', line 20 def data @options[:data] || {} end |
#label_classes ⇒ Object
12 13 14 |
# File 'app/components/lightning_ui_kit/description_list/item_component.rb', line 12 def label_classes merge_classes([LABEL_CLASSES, @options[:label_class]].compact.join(" ")) end |
#value ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'app/components/lightning_ui_kit/description_list/item_component.rb', line 24 def value return @value unless @value.nil? return content if @body.nil? # Blocks that build markup write to the output buffer; blocks that just # return a value (an Integer, a Date, ...) leave it empty — keep both. returned = nil buffer = view_context.with_output_buffer { returned = @body.call } buffer.presence || returned end |
#value_classes ⇒ Object
16 17 18 |
# File 'app/components/lightning_ui_kit/description_list/item_component.rb', line 16 def value_classes merge_classes([VALUE_CLASSES, @options[:class]].compact.join(" ")) end |