app/helpers/coco/app_helper.rb in coveragebook_components-0.7.3 vs app/helpers/coco/app_helper.rb in coveragebook_components-0.7.4
- old
+ new
@@ -14,16 +14,18 @@
kwargs[:data] = kwargs.fetch(:data, {}).merge(turbo_data)
kwargs.delete(:frame)
end
link = Coco::App::Elements::Link.new(href: href, **kwargs)
- link = link.with_content(content) unless block
+ link = link.with_content(content) if !block && content.present?
render(link, &block)
end
- def coco_button(href = nil, **kwargs, &block)
+ def coco_button(*args, **kwargs, &block)
+ href, content = args[0..2].reverse!
+
button = if kwargs.key?(:action) || kwargs.key?(:method) || kwargs.key?(:params)
"ButtonTo"
else
"Button"
end
@@ -41,10 +43,12 @@
kwargs[:button_element][:data] = kwargs[:button_element].fetch(:data, {}).merge(turbo_data)
kwargs.delete(:frame)
end
component = "Coco::App::Elements::#{button}".constantize.new(href: href, **kwargs)
- render component, &block
+ component = component.with_content(content) if !block && content.present?
+
+ render(component, &block)
end
def coco_menu_button(**, &block)
render Coco::App::Elements::MenuButton.new(**), &block
end