# frozen_string_literal: true module Ariadne # Add a general description of component here # Add additional usage considerations or best practices that may aid the user to use the component correctly. # @accessibility Add any accessibility considerations class SlideoverComponent < Ariadne::Component DEFAULT_TAG = :div TAG_OPTIONS = [DEFAULT_TAG].freeze DIRECTION_Y_DOWN = :yd DIRECTION_X_LEFT = :xl VALID_DIRECTIONS = [DIRECTION_Y_DOWN, DIRECTION_X_LEFT].freeze DEFAULT_CLASSES = "" DEFAULT_BUTTON_CLASSES = "inline-flex items-center shadow-sm px-4 py-1.5 pb-2 text-sm leading-5 font-medium rounded-full " + Ariadne::ButtonComponent::SCHEME_CLASS_MAPPINGS[:default] renders_one :open_button, lambda { |label:, classes: "", attributes: {}, text_classes: ""| actual_classes = class_names(DEFAULT_BUTTON_CLASSES, classes) attributes[:id] ||= "btnOpen" attributes[:"data-slideover-component-target"] ||= "slidePanel" attributes[:"data-action"] ||= "click->slideover-component#toggle" attributes[:type] ||= "submit" icon = case @direction when DIRECTION_Y_DOWN :"chevron-double-down" end render(Ariadne::BaseComponent.new(tag: :button, classes: actual_classes, attributes: attributes)) do render(Ariadne::HeroiconComponent.new(icon: icon, size: :sm, variant: HeroiconsHelper::Icon::VARIANT_SOLID, attributes: { "data-slideover-component-target" => "slide-panel" }, text_classes: text_classes)) { label } end } renders_one :close_button, lambda { |label:, classes: "", attributes: {}, text_classes: ""| actual_classes = class_names(DEFAULT_BUTTON_CLASSES, classes) attributes[:id] ||= "btnClose" attributes[:"data-slideover-component-target"] ||= "slidePanel" attributes[:"data-action"] ||= "click->slideover-component#toggle" attributes[:type] ||= "submit" icon = case @direction when DIRECTION_Y_DOWN :"chevron-double-up" end render(Ariadne::BaseComponent.new(tag: :button, classes: actual_classes, attributes: attributes)) do render(Ariadne::HeroiconComponent.new(icon: icon, size: :sm, variant: HeroiconsHelper::Icon::VARIANT_SOLID, attributes: { "data-slideover-component-target" => "slide-panel" }, text_classes: text_classes)) { label } end } # @example Default # # <%= render(Ariadne::SlideoverComponent.new(direction: Ariadne::SlideoverComponent::DIRECTION_Y_DOWN)) { "Example" } %> # # @param tag [Symbol, String] The rendered tag name. # @param direction [Symbol] <%= one_of(Ariadne::SlideoverComponent::VALID_DIRECTIONS) %> # @param form_id [String] The ID of any