Class: ButtonComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- ButtonComponent
- Defined in:
- app/components/ButtonComponent/button_component.rb
Constant Summary collapse
- PRIMARY_CLASSES =
%w[ zenhr-primary-button ].freeze
- OUTLINE_CLASSES =
%w[ zenhr-outline-button ].freeze
- DANGER_CLASSES =
%w[ zenhr-danger-button ].freeze
- BASE_CLASSES =
%w[ cursor-pointer rounded transition text-center whitespace-nowrap font-weight-bold zenhr-button ].freeze
- BUTTON_TYPE_MAPPINGS =
{ primary: PRIMARY_CLASSES, danger: DANGER_CLASSES, outline: OUTLINE_CLASSES }.freeze
Instance Attribute Summary collapse
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #classes ⇒ Object
-
#initialize(options:, classes: '') ⇒ ButtonComponent
constructor
A new instance of ButtonComponent.
Constructor Details
#initialize(options:, classes: '') ⇒ ButtonComponent
Returns a new instance of ButtonComponent.
31 32 33 34 |
# File 'app/components/ButtonComponent/button_component.rb', line 31 def initialize(options:, classes: '') @options = @classes = classes end |
Instance Attribute Details
#type ⇒ Object
Returns the value of attribute type.
4 5 6 |
# File 'app/components/ButtonComponent/button_component.rb', line 4 def type @type end |
Instance Method Details
#classes ⇒ Object
36 37 38 39 40 41 42 |
# File 'app/components/ButtonComponent/button_component.rb', line 36 def classes if @options[:button_type].nil? @options[:button_type] = :primary end (BUTTON_TYPE_MAPPINGS[@options[:button_type]] + BASE_CLASSES).join(' ') + " #{@classes}" end |