Class: BetterUi::Dropdown::DropdownComponent

Inherits:
ApplicationComponent show all
Defined in:
app/components/better_ui/dropdown/dropdown_component.rb

Constant Summary collapse

SIZES =
{
  sm: "w-40",
  md: "w-56",
  lg: "w-72"
}.freeze
PLACEMENTS =
{
  bottom_start: "top-full left-0 mt-1",
  bottom_end: "top-full right-0 mt-1",
  top_start: "bottom-full left-0 mb-1",
  top_end: "bottom-full right-0 mb-1"
}.freeze

Constants inherited from ApplicationComponent

ApplicationComponent::SHADOWS, ApplicationComponent::VARIANTS, ApplicationComponent::VARIANT_BODY_DIVIDE, ApplicationComponent::VARIANT_DIVIDE, ApplicationComponent::VARIANT_HEADER_BG, ApplicationComponent::VARIANT_HEADER_TEXT, ApplicationComponent::VARIANT_HIGHLIGHTED, ApplicationComponent::VARIANT_HOVERABLE, ApplicationComponent::VARIANT_RING, ApplicationComponent::VARIANT_SORT_ICON, ApplicationComponent::VARIANT_STRIPED

Instance Method Summary collapse

Constructor Details

#initialize(variant: :default, size: :md, placement: :bottom_start, shadow: :lg, auto_close: true, close_on_item_click: true, container_classes: nil, menu_classes: nil) ⇒ DropdownComponent

Returns a new instance of DropdownComponent.



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/components/better_ui/dropdown/dropdown_component.rb', line 41

def initialize(
  variant: :default,
  size: :md,
  placement: :bottom_start,
  shadow: :lg,
  auto_close: true,
  close_on_item_click: true,
  container_classes: nil,
  menu_classes: nil
)
  @variant = variant
  @size = validate_size(size || :md)
  @placement = validate_placement(placement || :bottom_start)
  @shadow = normalize_shadow(shadow, default: :lg)
  @auto_close = auto_close
  @close_on_item_click = close_on_item_click
  @container_classes = container_classes
  @menu_classes = menu_classes
end