Class: Primer::Beta::Details

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

Overview

Use ‘DetailsComponent` to reveal content after clicking a button.

Constant Summary collapse

BODY_TAG_DEFAULT =
:div
BODY_TAG_OPTIONS =
[:ul, :"details-menu", :"details-dialog", BODY_TAG_DEFAULT].freeze
NO_OVERLAY =
:none
OVERLAY_MAPPINGS =
{
  NO_OVERLAY => "",
  :default => "details-overlay",
  :dark => "details-overlay details-overlay-dark"
}.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, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Constructor Details

#initialize(overlay: NO_OVERLAY, reset: false, disabled: false, **system_arguments) ⇒ Details

Returns a new instance of Details.

Parameters:

  • overlay (Symbol) (defaults to: NO_OVERLAY)

    Dictates the type of overlay to render with. <%= one_of(Primer::Beta::Details::OVERLAY_MAPPINGS.keys) %>

  • reset (Boolean) (defaults to: false)

    Defaults to false. If set to true, it will remove the default caret and remove style from the summary element

  • disabled (Boolean) (defaults to: false)

    Whether or not to disable the summary button.

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



52
53
54
55
56
57
58
59
60
61
62
# File 'app/components/primer/beta/details.rb', line 52

def initialize(overlay: NO_OVERLAY, reset: false, disabled: false, **system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = :details
  @system_arguments[:classes] = class_names(
    system_arguments[:classes],
    OVERLAY_MAPPINGS[fetch_or_fallback(OVERLAY_MAPPINGS.keys, overlay, NO_OVERLAY)],
    "details-reset" => reset
  )
  @disabled = disabled
  @summary_info = nil
end

Instance Attribute Details

#disabledObject (readonly) Also known as: disabled?

Returns the value of attribute disabled.



18
19
20
# File 'app/components/primer/beta/details.rb', line 18

def disabled
  @disabled
end

Instance Method Details

#render?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'app/components/primer/beta/details.rb', line 64

def render?
  summary.present? && body.present?
end