Sha256: 0af91f43a4a3769a87f68837188829e99a8bae345d8589656ae9eb42afd40562

Contents?: true

Size: 1.2 KB

Versions: 60

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module Ariadne
  # Simple button with X icon to close models and such
  class CloseButtonComponent < Ariadne::Component
    DEFAULT_TAG = :button
    TAG_OPTIONS = [DEFAULT_TAG].freeze

    DEFAULT_CLASSES = "ariadne-border-none ariadne-bg-transparent ariadne-shadow-none hover:ariadne-bg-transparent"

    # @example Default
    #
    #   <%= render(Ariadne::CloseButtonComponent.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: "", icon_classes: "", size: :xs, aria_label: nil, scheme: :none, attributes: {})
      raise ArgumentError, "An 'aria_label' argument is required to use a Close Button. Include as much detail as you can about what the button will be closing." if aria_label.blank?

      @tag = check_incoming_tag(DEFAULT_TAG, tag)
      @attributes = { "aria-label": aria_label }.merge(attributes)
      @classes = merge_class_names(
        DEFAULT_CLASSES,
        classes,
      )

      @scheme = scheme
      @size = size
      @icon_classses = icon_classes
    end
  end
end

Version data entries

60 entries across 60 versions & 1 rubygems

Version Path
ariadne_view_components-0.0.52 app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.52-x64-mingw-ucrt app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.51-x64-mingw-ucrt app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.51-x86_64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.51-arm64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.51-aarch64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.51 app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.51-x86_64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.50 app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.50-arm64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.50-x64-mingw-ucrt app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.50-x86_64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.50-x86_64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.50-aarch64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.49-aarch64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.49-x86_64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.49-x86_64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.49-arm64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.49-x64-mingw-ucrt app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.49 app/components/ariadne/close_button_component.rb