Class: StimulusPlumbers::Components::ActionList::Renderer
- Inherits:
-
Plumber::Base
- Object
- Plumber::Base
- StimulusPlumbers::Components::ActionList::Renderer
- Defined in:
- lib/stimulus_plumbers/components/action_list/renderer.rb
Instance Attribute Summary
Attributes inherited from Plumber::Base
Instance Method Summary collapse
- #item(content = nil, url: nil, external: false, active: false, **kwargs, &block) ⇒ Object
- #list(**kwargs, &block) ⇒ Object
- #section(title: nil, **kwargs, &block) ⇒ Object
Methods inherited from Plumber::Base
Methods included from Plumber::HtmlOptions
#merge_html_options, #merge_string_option, #normalize_part
Constructor Details
This class inherits a constructor from StimulusPlumbers::Components::Plumber::Base
Instance Method Details
#item(content = nil, url: nil, external: false, active: false, **kwargs, &block) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/stimulus_plumbers/components/action_list/renderer.rb', line 27 def item(content = nil, url: nil, external: false, active: false, **kwargs, &block) content = template.capture(&block) if block_given? = ( { classes: theme.resolve(:action_list_item, active: active).fetch(:classes, "") }, kwargs ) inner = if url [:target] = "_blank" if external template.content_tag(:a, content, href: url, **) else [:type] ||= "button" template.content_tag(:button, content, **) end template.content_tag(:li, inner) end |
#list(**kwargs, &block) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/stimulus_plumbers/components/action_list/renderer.rb', line 7 def list(**kwargs, &block) = ( { classes: theme.resolve(:action_list).fetch(:classes, "") }, kwargs ) template.content_tag(:div, template.capture(&block), **) end |
#section(title: nil, **kwargs, &block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/stimulus_plumbers/components/action_list/renderer.rb', line 15 def section(title: nil, **kwargs, &block) = (kwargs) template.content_tag(:div, **) do template.safe_join( [ (template.content_tag(:p, title) if title.present?), template.content_tag(:ul, template.capture(&block)) ].compact ) end end |