Class: Ariadne::CloseButtonComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/ariadne/close_button_component.rb

Overview

Simple button with X icon to close models and such

Constant Summary collapse

DEFAULT_TAG =
:button
TAG_OPTIONS =
[DEFAULT_TAG].freeze
DEFAULT_CLASSES =
"ariadne-border-none ariadne-bg-transparent ariadne-shadow-none hover:ariadne-bg-transparent"

Constants inherited from Component

Ariadne::Component::BASE_HIDDEN_CLASS, Ariadne::Component::BASE_MAIN_CLASSES, Ariadne::Component::BASE_WRAPPER_CLASSES, Ariadne::Component::INVALID_ARIA_LABEL_TAGS

Constants included from ActionViewExtensions::FormHelper

ActionViewExtensions::FormHelper::DEFAULT_FORM_CLASSES

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::INTEGER_TYPES, FetchOrFallbackHelper::InvalidValueError, FetchOrFallbackHelper::TRUE_OR_FALSE

Instance Method Summary collapse

Methods included from ActionViewExtensions::FormHelper

#ariadne_form_with

Methods included from ClassNameHelper

#merge_class_names

Methods included from LoggerHelper

#logger, #silence_deprecations?, #silence_warnings?

Methods included from FetchOrFallbackHelper

#check_incoming_attribute, #check_incoming_tag, #check_incoming_value, #fetch_or_raise, #fetch_or_raise_boolean, #fetch_or_raise_integer

Constructor Details

#initialize(tag: DEFAULT_TAG, classes: "", icon_classes: "", size: :xs, aria_label: nil, scheme: :none, attributes: {}) ⇒ CloseButtonComponent

Returns a new instance of CloseButtonComponent.

Examples:

Default


<%= render(Ariadne::CloseButtonComponent.new) { "Example" } %>

Parameters:

  • tag (Symbol, String) (defaults to: DEFAULT_TAG)

    The rendered tag name.

  • classes (String) (defaults to: "")

    <%= link_to_classes_docs %>

  • attributes (Hash) (defaults to: {})

    <%= link_to_attributes_docs %>

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/ariadne/close_button_component.rb', line 18

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