Class: LightningUiKit::DescriptionListComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/lightning_ui_kit/description_list_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ DescriptionListComponent

Returns a new instance of DescriptionListComponent.



15
16
17
# File 'app/components/lightning_ui_kit/description_list_component.rb', line 15

def initialize(**options)
  @options = options
end

Instance Method Details

#__with_item_slotObject

ViewComponent funnels slot blocks through Rails' capture, which discards non-String return values (Integers, Dates, ...), rendering blank values. Route the block around that wrapper via the body: argument so the item can evaluate it instead.



10
# File 'app/components/lightning_ui_kit/description_list_component.rb', line 10

alias_method :__with_item_slot, :with_item

#classesObject



19
20
21
22
23
24
# File 'app/components/lightning_ui_kit/description_list_component.rb', line 19

def classes
  merge_classes([
    "lui:grid lui:grid-cols-1 lui:text-base/6 lui:sm:grid-cols-[min(50%,--spacing(80))_minmax(0,auto)] lui:sm:text-sm/6",
    @options[:class]
  ].compact.join(" "))
end

#dataObject



26
27
28
# File 'app/components/lightning_ui_kit/description_list_component.rb', line 26

def data
  @options[:data] || {}
end

#with_item(label:, value: nil, **options, &block) ⇒ Object



11
12
13
# File 'app/components/lightning_ui_kit/description_list_component.rb', line 11

def with_item(label:, value: nil, **options, &block)
  __with_item_slot(label: label, value: value, body: block, **options)
end