Sha256: 5a2283406ff4123b2aa9bfb6551cf5b888f530d57af55ba0568bf7c59538d763
Contents?: true
Size: 1.95 KB
Versions: 66
Compression:
Stored size: 1.95 KB
Contents
# 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 ShowMoreButtonComponent < Ariadne::Component DEFAULT_TAG = :div TAG_OPTIONS = [DEFAULT_TAG].freeze DEFAULT_CLASSES = { wrapper: "ariadne-group", button: "ariadne-px-2 ariadne-py-0" } DEFAULT_ATTRIBUTES = { wrapper: { "data-controller": "toggleable", }, button: { "data-action": "click->toggleable#toggle", }, } renders_many :hiddens # @example Default # # <%= render(Ariadne::ShowMoreButtonComponent.new) { "Example" } %> # # @param tag [Symbol, String] The rendered tag name. # @param classes [String] <%= link_to_classes_docs %> # @param attributes [Hash] <%= link_to_attributes_docs %> def initialize(tag: DEFAULT_TAG, classes: "", button_text: "...", outlet: nil, attributes: {}) raise ArgumentError, "An 'aria-label' attribute is required to use the Show More Button. Include as much detail as you can about the content to be shown to assist screen readers." if attributes.blank? || attributes["aria-label"].blank? raise ArgumentError, "An 'outlet' attribute is required to use the Show More Button. This will ensure controllers can correctly identify states to update." if outlet.blank? @outlet = outlet @tag = check_incoming_tag(DEFAULT_TAG, tag) @classes = merge_class_names(DEFAULT_CLASSES[:wrapper], classes) @attributes = DEFAULT_ATTRIBUTES[:wrapper] .merge({ "data-toggleable-toggleable-outlet": "[data-toggleable-outlet=#{@outlet}]" }) .merge(attributes) @button_classes = merge_class_names(DEFAULT_CLASSES[:button], classes) @button_attributes = DEFAULT_ATTRIBUTES[:button].merge(attributes) @button_text = button_text end end end
Version data entries
66 entries across 66 versions & 1 rubygems