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.59-x64-mingw-ucrt app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.59-aarch64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.59-x86_64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.59-x86_64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.59-arm64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.59 app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.58-x86_64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.58-aarch64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.58-arm64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.58-x64-mingw-ucrt app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.58 app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.58-x86_64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.57-arm64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.57-aarch64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.57-x86_64-darwin app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.57-x86_64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.57-x64-mingw-ucrt app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.57 app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.55-x86_64-linux app/components/ariadne/close_button_component.rb
ariadne_view_components-0.0.55-arm64-darwin app/components/ariadne/close_button_component.rb