Class: SdrViewComponents::TabForm::PaneComponent
- Inherits:
-
BaseComponent
- Object
- ViewComponent::Base
- BaseComponent
- SdrViewComponents::TabForm::PaneComponent
- Defined in:
- app/components/sdr_view_components/tab_form/pane_component.rb
Overview
Component for a tab pane in a SdrViewComponents::TabForm::TabListComponent. Based on https://getbootstrap.com/docs/5.3/components/navs-tabs/#javascript-behavior
Instance Attribute Summary collapse
-
#active_tab_name ⇒ Object
Returns the value of attribute active_tab_name.
-
#help_text ⇒ Object
readonly
Returns the value of attribute help_text.
-
#pane_header_class ⇒ Object
readonly
Returns the value of attribute pane_header_class.
-
#tab_name ⇒ Object
readonly
Returns the value of attribute tab_name.
-
#tooltip ⇒ Object
readonly
Returns the value of attribute tooltip.
Instance Method Summary collapse
- #classes ⇒ Object
- #id ⇒ Object
-
#initialize(tab_name:, label: nil, help_text: nil, tooltip: nil, pane_header_class: 'pane-header', mark_required: false) ⇒ PaneComponent
constructor
rubocop:disable Metrics/ParameterLists.
- #label ⇒ Object
- #mark_required? ⇒ Boolean
- #selected? ⇒ Boolean
- #tab_id ⇒ Object
Methods inherited from BaseComponent
#args_for, #mark_label_required, #merge_actions, #merge_classes
Constructor Details
#initialize(tab_name:, label: nil, help_text: nil, tooltip: nil, pane_header_class: 'pane-header', mark_required: false) ⇒ PaneComponent
rubocop:disable Metrics/ParameterLists
13 14 15 16 17 18 19 20 21 22 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 13 def initialize(tab_name:, label: nil, help_text: nil, tooltip: nil, pane_header_class: 'pane-header', # rubocop:disable Metrics/ParameterLists mark_required: false) @tab_name = tab_name @label = label @help_text = help_text @tooltip = tooltip @pane_header_class = pane_header_class @mark_required = mark_required super() end |
Instance Attribute Details
#active_tab_name ⇒ Object
Returns the value of attribute active_tab_name.
11 12 13 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 11 def active_tab_name @active_tab_name end |
#help_text ⇒ Object (readonly)
Returns the value of attribute help_text.
24 25 26 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 24 def help_text @help_text end |
#pane_header_class ⇒ Object (readonly)
Returns the value of attribute pane_header_class.
24 25 26 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 24 def pane_header_class @pane_header_class end |
#tab_name ⇒ Object (readonly)
Returns the value of attribute tab_name.
24 25 26 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 24 def tab_name @tab_name end |
#tooltip ⇒ Object (readonly)
Returns the value of attribute tooltip.
24 25 26 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 24 def tooltip @tooltip end |
Instance Method Details
#classes ⇒ Object
40 41 42 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 40 def classes merge_classes(%w[tab-pane fade h-100], selected? ? 'show active' : nil) end |
#id ⇒ Object
44 45 46 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 44 def id "#{tab_name}-pane" end |
#label ⇒ Object
34 35 36 37 38 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 34 def label return unless @label mark_label_required(label: @label, mark_required: mark_required?) end |
#mark_required? ⇒ Boolean
30 31 32 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 30 def mark_required? @mark_required end |
#selected? ⇒ Boolean
26 27 28 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 26 def selected? tab_name == active_tab_name end |
#tab_id ⇒ Object
48 49 50 |
# File 'app/components/sdr_view_components/tab_form/pane_component.rb', line 48 def tab_id "#{tab_name}-tab" end |