Class: Ariadne::Dropdown::MenuComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/ariadne/dropdown/menu_component.rb

Overview

This component is part of DropdownComponent and should not be used as a standalone component.

Defined Under Namespace

Classes: Item

Constant Summary collapse

DEFAULT_AS_OPTION =
:default
VALID_AS_OPTIONS =
[DEFAULT_AS_OPTION, :list].freeze
DEFAULT_DIRECTION =
:se
VALID_DIRECTIONS =
[DEFAULT_DIRECTION, :sw, :w, :e, :ne, :s].freeze
DEFAULT_HEADER_CLASSES =
"ariadne-text-sm ariadne-font-medium ariadne-text-gray-900"
DEFAULT_TAG =
:"details-menu"
TAG_OPTIONS =
[DEFAULT_TAG].freeze
DEFAULT_CLASSES =
""

Constants inherited from Component

Component::BASE_HIDDEN_CLASS, Component::BASE_MAIN_CLASSES, Component::BASE_WRAPPER_CLASSES, Component::INVALID_ARIA_LABEL_TAGS

Constants included from ActionViewExtensions::FormHelper

ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE

Instance Method Summary collapse

Methods included from ActionViewExtensions::FormHelper

#ariadne_form_with

Methods included from ClassNameHelper

#class_names

Methods included from LoggerHelper

#logger, #silence_deprecations?, #silence_warnings?

Methods included from FetchOrFallbackHelper

#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer

Constructor Details

#initialize(as: DEFAULT_AS_OPTION, direction: VALID_DIRECTIONS, classes: "", attributes: {}) ⇒ MenuComponent

Returns a new instance of MenuComponent.

Parameters:

  • (defaults to: DEFAULT_AS_OPTION)

    When as is :list, wraps the menu in a ‘<ul>` with a `<li>` for each item.

  • (defaults to: VALID_DIRECTIONS)

    <%= one_of(Ariadne::Dropdown::MenuComponent::VALID_DIRECTIONS) %>.

  • (defaults to: "")

    <%= link_to_classes_docs %>

  • (defaults to: {})

    <%= link_to_attributes_docs %>



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'app/components/ariadne/dropdown/menu_component.rb', line 39

def initialize(as: DEFAULT_AS_OPTION, direction: VALID_DIRECTIONS, classes: "", attributes: {})
  @tag = DEFAULT_TAG
  @classes = class_names(
    DEFAULT_CLASSES,
    classes,
  )

  @attributes = attributes

  @direction = direction
  @as = fetch_or_raise(VALID_AS_OPTIONS, as)

  @attributes[:role] = "menu"
end