Class: Primer::Beta::CloseButton

Inherits:
Component
  • Object
show all
Defined in:
app/components/primer/beta/close_button.rb

Overview

Use ‘CloseButton` to render an `×` without default button styles.

[0]: primer.style/view-components/system-arguments#html-attributes

Constant Summary collapse

DEFAULT_TYPE =
:button
TYPE_OPTIONS =
[DEFAULT_TYPE, :submit].freeze

Constants inherited from Component

Component::INVALID_ARIA_LABEL_TAGS

Constants included from Status::Dsl

Status::Dsl::STATUSES

Constants included from ViewHelper

ViewHelper::HELPERS

Constants included from TestSelectorHelper

TestSelectorHelper::TEST_SELECTOR_TAG

Constants included from FetchOrFallbackHelper

FetchOrFallbackHelper::InvalidValueError

Constants included from AttributesHelper

AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods inherited from Component

deprecated?, generate_id

Methods included from JoinStyleArgumentsHelper

#join_style_arguments

Methods included from TestSelectorHelper

#add_test_selector

Methods included from FetchOrFallbackHelper

#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?

Methods included from ClassNameHelper

#class_names

Methods included from AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(type: DEFAULT_TYPE, disabled: false, **system_arguments) ⇒ CloseButton

Returns a new instance of CloseButton.

Parameters:

  • type (Symbol) (defaults to: DEFAULT_TYPE)

    <%= one_of(Primer::Beta::CloseButton::TYPE_OPTIONS) %>

  • disabled (Boolean) (defaults to: false)

    Whether or not the button is disabled.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/components/primer/beta/close_button.rb', line 20

def initialize(type: DEFAULT_TYPE, disabled: false, **system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :button
  @system_arguments[:block] = false
  @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE)
  @system_arguments[:classes] = class_names(
    "close-button",
    system_arguments[:classes]
  )
  @system_arguments[:"aria-label"] = aria("label", system_arguments) || "Close"
  @system_arguments[:disabled] = disabled
end

Instance Method Details

#callObject



33
34
35
36
37
# File 'app/components/primer/beta/close_button.rb', line 33

def call
  render(Primer::Beta::BaseButton.new(**@system_arguments)) do
    render(Primer::Beta::Octicon.new("x"))
  end
end