Class: BackpackUi::ButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BackpackUi::ButtonComponent
- Defined in:
- app/components/backpack_ui/button_component.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(text:, icon:, type: 'button', options: {}) ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
- #size ⇒ Object
- #style ⇒ Object
Constructor Details
#initialize(text:, icon:, type: 'button', options: {}) ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
7 8 9 10 11 12 |
# File 'app/components/backpack_ui/button_component.rb', line 7 def initialize(text:, icon:, type: 'button', options: {}) @text = text @icon = icon @type = type @options = .reverse_merge(defaults) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'app/components/backpack_ui/button_component.rb', line 5 def @options end |
Instance Method Details
#size ⇒ Object
27 28 29 30 31 32 33 |
# File 'app/components/backpack_ui/button_component.rb', line 27 def size { small: "sm-btn-small", medium: "sm-btn-medium", large: "sm-btn-large", } end |
#style ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/components/backpack_ui/button_component.rb', line 14 def style { primary: "sm-btn-primary", secondary: "sm-btn-secondary", tertiary: "sm-btn-tertiary", outline: "sm-btn-outline", outline_dark: "sm-btn-outline-dark", link: "sm-btn-link", delete: "sm-btn-delete", no_outline: "sm-btn-no-outline", }[[:classification].to_sym] + " " + "sm-btn" + " " + size[[:size].to_sym] end |