Class: Button::BaseComponent
- Inherits:
-
SparkComponents::Component
- Object
- SparkComponents::Component
- Button::BaseComponent
show all
- Defined in:
- app/components/spark/button/base_component.rb
Constant Summary
collapse
- COLORS =
i(blue green yellow red)
- SIZES =
i(small base medium large)
Instance Method Summary
collapse
Instance Method Details
#before_render ⇒ Object
15
16
17
18
19
20
21
|
# File 'app/components/spark/button/base_component.rb', line 15
def before_render
add_class("size-#{size}") if size
add_class("color-#{color}") if color
if (href && (data_attr[:remote] || data_attr[:method]))
root_attr rel: "nofollow"
end
end
|
#button_content ⇒ Object
33
34
35
36
37
38
|
# File 'app/components/spark/button/base_component.rb', line 33
def button_content
capture {
concat component("ui/icon", name: icon) if icon
concat tag.span(text || @yield, class: join_class(:label))
}
end
|
#render ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'app/components/spark/button/base_component.rb', line 23
def render
content_tag(:div, class: join_class("wrapper")) do
if href
link_to(button_content, href, tag_attrs)
else
tag.button(button_content, tag_attrs)
end
end
end
|