Class: Primer::Beta::BaseButton

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

Overview

Use ‘BaseButton` to render an unstyled `<button>` tag that can be customized.

Direct Known Subclasses

ClipboardCopyBaseButton

Constant Summary collapse

DEFAULT_TAG =
:button
TAG_OPTIONS =
[DEFAULT_TAG, :a, :summary, :"clipboard-copy"].freeze
DEFAULT_TYPE =
:button
TYPE_OPTIONS =
[DEFAULT_TYPE, :reset, :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 Attribute Summary collapse

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, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Methods included from ExperimentalSlotHelpers

included

Methods included from ExperimentalRenderHelpers

included

Constructor Details

#initialize(tag: DEFAULT_TAG, type: DEFAULT_TYPE, block: false, disabled: false, inactive: false, **system_arguments) ⇒ BaseButton



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/components/primer/beta/base_button.rb', line 24

def initialize(
  tag: DEFAULT_TAG,
  type: DEFAULT_TYPE,
  block: false,
  disabled: false,
  inactive: false,
  **system_arguments
)
  @system_arguments = system_arguments
  @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, DEFAULT_TAG)

  @system_arguments[:type] = fetch_or_fallback(TYPE_OPTIONS, type, DEFAULT_TYPE) if @system_arguments[:tag] == :button

  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    "btn-block" => block,
    "Button--inactive" => inactive
  )

  @disabled = disabled
  return unless @disabled

  @system_arguments[:tag] = :button
  @system_arguments[:disabled] = ""
end

Instance Attribute Details

#disabledObject (readonly) Also known as: disabled?

Returns the value of attribute disabled.



15
16
17
# File 'app/components/primer/beta/base_button.rb', line 15

def disabled
  @disabled
end

Instance Method Details

#callObject



50
51
52
# File 'app/components/primer/beta/base_button.rb', line 50

def call
  render(Primer::BaseComponent.new(**@system_arguments)) { content }
end