Class: UI::ItemComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- UI::ItemComponent
- Includes:
- ItemBehavior, SharedAsChildBehavior
- Defined in:
- app/view_components/ui/item_component.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(variant: "default", size: "default", as_child: false, classes: "", **attributes) ⇒ ItemComponent
constructor
A new instance of ItemComponent.
Methods included from SharedAsChildBehavior
Methods included from ItemBehavior
#item_actions_html_attributes, #item_classes, #item_content_html_attributes, #item_content_text_html_attributes, #item_description_html_attributes, #item_html_attributes, #item_media_html_attributes
Constructor Details
#initialize(variant: "default", size: "default", as_child: false, classes: "", **attributes) ⇒ ItemComponent
Returns a new instance of ItemComponent.
7 8 9 10 11 12 13 |
# File 'app/view_components/ui/item_component.rb', line 7 def initialize(variant: "default", size: "default", as_child: false, classes: "", **attributes) @variant = variant @size = size @as_child = as_child @classes = classes @attributes = attributes end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/view_components/ui/item_component.rb', line 15 def call item_attrs = item_html_attributes.merge(@attributes) if @as_child # Yield attributes to block - child element will receive them yield(item_attrs) if block_given? else # Default: render as div content_tag :div, content, **item_attrs end end |