Class: Shadcn::InputGroup::Addon::Component

Inherits:
ApplicationViewComponent show all
Defined in:
app/components/shadcn/input_group/addon/component.rb

Overview

InputGroupAddon. The one part of this family that is not just markup: upstream gives it an onClick that focuses the group's input, unless the click landed on a button. That is the focusControl action.

Constant Summary

Constants inherited from ApplicationViewComponent

ApplicationViewComponent::CONTENTS_STYLE, ApplicationViewComponent::VOID_TAGS

Instance Attribute Summary collapse

Attributes inherited from ApplicationViewComponent

#attributes

Instance Method Summary collapse

Methods inherited from ApplicationViewComponent

#call, #css_classes, default_tag, #merged_style, #render_element, #shadcn_t, slot_name, #tag_name

Constructor Details

#initialize(align: :"inline-start", **attributes) ⇒ Component

Returns a new instance of Component.



46
47
48
49
# File 'app/components/shadcn/input_group/addon/component.rb', line 46

def initialize(align: :"inline-start", **attributes)
  @align = align&.to_sym || :"inline-start"
  super(**attributes)
end

Instance Attribute Details

#alignObject (readonly)

Returns the value of attribute align.



44
45
46
# File 'app/components/shadcn/input_group/addon/component.rb', line 44

def align
  @align
end

Instance Method Details

#element_attributes(**defaults) ⇒ Object



55
56
57
58
59
60
61
# File 'app/components/shadcn/input_group/addon/component.rb', line 55

def element_attributes(**defaults)
  super(**{
    role: "group",
    "data-align" => align,
    "data-action" => "click->shadcn--input-group#focusControl"
  }.merge(defaults))
end

#style_variantsObject



51
52
53
# File 'app/components/shadcn/input_group/addon/component.rb', line 51

def style_variants
  { align: }
end