Class: Primer::OpenProject::CollapsibleSection
- Inherits:
-
Component
- Object
- ViewComponent::Base
- Component
- Primer::OpenProject::CollapsibleSection
- Defined in:
- app/components/primer/open_project/collapsible_section.rb
Overview
A component consisting of a title and collapsible content. Clicking the title will hide the collapsible content
Constant Summary collapse
- TITLE_TAG_FALLBACK =
:h2- TITLE_TAG_OPTIONS =
[:h1, TITLE_TAG_FALLBACK, :h3, :h4, :h5, :h6, :span].freeze
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 Method Summary collapse
-
#initialize(id: self.class.generate_id, collapsed: false, **system_arguments) ⇒ CollapsibleSection
constructor
A new instance of CollapsibleSection.
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(id: self.class.generate_id, collapsed: false, **system_arguments) ⇒ CollapsibleSection
Returns a new instance of CollapsibleSection.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/components/primer/open_project/collapsible_section.rb', line 53 def initialize(id: self.class.generate_id, collapsed: false, **system_arguments) @title_id = "#{id}-title" @content_id = "#{id}-content" @collapsed = collapsed @system_arguments = deny_tag_argument(**system_arguments) @system_arguments[:tag] = "collapsible-section" @system_arguments[:id] = id @system_arguments[:classes] = class_names( @system_arguments[:classes], "CollapsibleSection", "CollapsibleSection--collapsed" => @collapsed ) @system_arguments[:data] ||= {} @system_arguments[:data][:collapsed] = true if @collapsed end |