Class: Primer::Beta::Details
- 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
- ARIA_LABEL_OPEN_DEFAULT =
"Collapse"
- ARIA_LABEL_CLOSED_DEFAULT =
"Expand"
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Status::Dsl
Constants included from ViewHelper
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
-
#disabled ⇒ Object
(also: #disabled?)
readonly
Returns the value of attribute disabled.
-
#open ⇒ Object
(also: #open?)
readonly
Returns the value of attribute open.
Instance Method Summary collapse
-
#initialize(overlay: NO_OVERLAY, reset: false, disabled: false, **system_arguments) ⇒ Details
constructor
A new instance of Details.
- #render? ⇒ Boolean
Methods inherited from Component
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(overlay: NO_OVERLAY, reset: false, disabled: false, **system_arguments) ⇒ Details
Returns a new instance of Details.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'app/components/primer/beta/details.rb', line 85 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, , NO_OVERLAY)], "details-reset" => reset ) @system_arguments[:data] = merge_data( @system_arguments, { data: { target: "details-toggle.detailsTarget", } } ) # https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details#open @open = !!@system_arguments[:open] @disabled = disabled @summary_info = nil end |
Instance Attribute Details
#disabled ⇒ Object (readonly) Also known as: disabled?
Returns the value of attribute disabled.
20 21 22 |
# File 'app/components/primer/beta/details.rb', line 20 def disabled @disabled end |
#open ⇒ Object (readonly) Also known as: open?
Returns the value of attribute open.
23 24 25 |
# File 'app/components/primer/beta/details.rb', line 23 def open @open end |
Instance Method Details
#render? ⇒ Boolean
106 107 108 |
# File 'app/components/primer/beta/details.rb', line 106 def render? summary.present? && body.present? end |