Class: KozenetUi::HeaderComponent::ActionButtonComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/kozenet_ui/header_component/action_button_component.rb

Overview

ActionButton section for the HeaderComponent Renders an action button (icon or text) in the header

"/cart", icon: :shopping_cart, label: "Cart") %>

Examples:

<%= render KozenetUi::HeaderComponent::ActionButtonComponent.new(href:

Constant Summary collapse

PLACEMENTS =
%i[start end].freeze
PLACEMENT_ALIASES =
{
  before: :start,
  left: :start,
  right: :end,
  after: :end
}.freeze
VISIBILITIES =
%i[always desktop mobile].freeze
VISIBILITY_ALIASES =
{
  all: :always,
  both: :always
}.freeze

Constants inherited from BaseComponent

BaseComponent::UNSET

Instance Attribute Summary collapse

Attributes inherited from BaseComponent

#html_options, #size, #variant

Instance Method Summary collapse

Constructor Details

#initialize(href: "#", icon: nil, text: nil, label: nil, placement: :end, position: nil, visible_on: :desktop, **html_options) ⇒ ActionButtonComponent

Returns a new instance of ActionButtonComponent.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'app/components/kozenet_ui/header_component/action_button_component.rb', line 27

def initialize(
  href: "#",
  icon: nil,
  text: nil,
  label: nil,
  placement: :end,
  position: nil,
  visible_on: :desktop,
  **html_options
)
  super(**html_options)
  @href = href
  @icon = icon
  @text = text
  @label = label
  @placement = normalize_placement(position || placement)
  @visible_on = normalize_visibility(visible_on)
end

Instance Attribute Details

#placementObject (readonly)

Returns the value of attribute placement.



25
26
27
# File 'app/components/kozenet_ui/header_component/action_button_component.rb', line 25

def placement
  @placement
end

#visible_onObject (readonly)

Returns the value of attribute visible_on.



25
26
27
# File 'app/components/kozenet_ui/header_component/action_button_component.rb', line 25

def visible_on
  @visible_on
end