Class: LightningUiKit::DescriptionListComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- LightningUiKit::DescriptionListComponent
- Defined in:
- app/components/lightning_ui_kit/description_list_component.rb
Instance Method Summary collapse
-
#__with_item_slot ⇒ Object
ViewComponent funnels slot blocks through Rails'
capture, which discards non-String return values (Integers, Dates, ...), rendering blank values. - #classes ⇒ Object
- #data ⇒ Object
-
#initialize(**options) ⇒ DescriptionListComponent
constructor
A new instance of DescriptionListComponent.
- #with_item(label:, value: nil, **options, &block) ⇒ Object
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 = end |
Instance Method Details
#__with_item_slot ⇒ Object
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 |
#classes ⇒ Object
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 |
#data ⇒ Object
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, **, &block) __with_item_slot(label: label, value: value, body: block, **) end |