Module: Klods::Components::Button
- Included in:
- Builders
- Defined in:
- lib/klods/components/button.rb
Constant Summary collapse
- BUTTON_MODIFIERS =
{ variant: ->(v) { (v && v.to_s != "default") ? "klods-button--#{v}" : nil } }.freeze
Instance Method Summary collapse
Instance Method Details
#button(a = nil, b = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/klods/components/button.rb', line 8 def (a = nil, b = nil) props, children = Core.normalize_args(a, b) str_props = props.transform_keys(&:to_s) if str_props.key?("href") Core.build(tag: "a", base: "klods-button", modifiers: BUTTON_MODIFIERS, props: str_props, children: children) else Core.build( tag: "button", base: "klods-button", modifiers: BUTTON_MODIFIERS, props: {"type" => "button"}.merge(str_props), children: children ) end end |
#button_group(a = nil, b = nil) ⇒ Object
21 22 23 24 |
# File 'lib/klods/components/button.rb', line 21 def (a = nil, b = nil) props, children = Core.normalize_args(a, b) Core.build(tag: "div", base: "klods-button-group", props: props, children: children) end |