Class: Primer::OpenProject::Fieldset
- Defined in:
- app/components/primer/open_project/fieldset.rb
Overview
A low-level component for building fieldsets with unopinionated styling.
This component is not designed to be used directly, but rather a primitive for authors of other components and form controls.
Defined Under Namespace
Classes: LegendComponent
Constant Summary
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
-
#legend_text ⇒ Object
readonly
Returns the value of attribute legend_text.
Instance Method Summary collapse
-
#initialize(legend_text: nil, visually_hide_legend: false, **system_arguments) ⇒ Fieldset
constructor
A new instance of Fieldset.
- #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(legend_text: nil, visually_hide_legend: false, **system_arguments) ⇒ Fieldset
Returns a new instance of Fieldset.
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'app/components/primer/open_project/fieldset.rb', line 21 def initialize(legend_text: nil, visually_hide_legend: false, **system_arguments) # rubocop:disable Lint/MissingSuper @legend_text = legend_text @visually_hide_legend = visually_hide_legend @system_arguments = deny_tag_argument(**system_arguments) @system_arguments[:tag] = :fieldset deny_aria_key( :label, "instead of `aria-label`, include `legend_text` and set `visually_hide_legend` to `true` on the component initializer.", **@system_arguments ) end |
Instance Attribute Details
#legend_text ⇒ Object (readonly)
Returns the value of attribute legend_text.
12 13 14 |
# File 'app/components/primer/open_project/fieldset.rb', line 12 def legend_text @legend_text end |
Instance Method Details
#render? ⇒ Boolean
34 35 36 |
# File 'app/components/primer/open_project/fieldset.rb', line 34 def render? content? && (legend_text.present? || legend?) end |