# frozen_string_literal: true module Ariadne module Dropdown # This component is part of `DropdownComponent` and should not be # used as a standalone component. class MenuComponent < Ariadne::Component 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" # @param classes [String] <%= link_to_classes_docs %> # @param attributes [Hash] <%= link_to_attributes_docs %> renders_one :header, lambda { |classes: "", attributes: {}| actual_classes = class_names(DEFAULT_HEADER_CLASSES, classes) Ariadne::BaseComponent.new(tag: :span, classes: actual_classes, attributes: attributes) } # @param tag [Boolean] <%= one_of(Ariadne::Dropdown::MenuComponent::Item::VALID_TAGS) %>. # @param divider [Boolean] Whether the item is a divider without any function. # @param classes [String] <%= link_to_classes_docs %> # @param attributes [Hash] <%= link_to_attributes_docs %> renders_many :items, lambda { |tag: Ariadne::Dropdown::MenuComponent::Item::DEFAULT_TAG, divider: false, classes: "", attributes: {}| Ariadne::Dropdown::MenuComponent::Item.new(tag: tag, as: @as, divider: divider, classes: classes, attributes: attributes) } DEFAULT_TAG = :"details-menu" TAG_OPTIONS = [DEFAULT_TAG].freeze DEFAULT_CLASSES = "" # @param as [Symbol] When `as` is `:list`, wraps the menu in a `