Class: Primer::Alpha::TabPanels

Inherits:
Component
  • Object
show all
Includes:
TabNavHelper, TabbedComponentHelper
Defined in:
app/components/primer/alpha/tab_panels.rb

Overview

Use ‘TabPanels` for tabs with panel navigation.

Constant Summary collapse

BODY_TAG_DEFAULT =
:ul
TAG_DEFAULT =
:nav
TAG_OPTIONS =
[TAG_DEFAULT, :div].freeze

Constants included from TabNavHelper

TabNavHelper::EXTRA_ALIGN_DEFAULT, TabNavHelper::EXTRA_ALIGN_OPTIONS

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 Primer::AttributesHelper

Primer::AttributesHelper::PLURAL_ARIA_ATTRIBUTES, Primer::AttributesHelper::PLURAL_DATA_ATTRIBUTES

Instance Method Summary collapse

Methods included from TabNavHelper

#tab_nav_body_classes, #tab_nav_classes, #tab_nav_tab_classes

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 Primer::AttributesHelper

#aria, #data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes

Methods included from ExperimentalSlotHelpers

included

Methods included from ExperimentalRenderHelpers

included

Constructor Details

#initialize(label:, body_arguments: {}, wrapper_arguments: {}, **system_arguments) ⇒ TabPanels

Returns a new instance of TabPanels.

Parameters:

  • label (String)

    Sets an ‘aria-label` that helps assistive technology users understand the purpose of the tabs.

  • align (Symbol)

    <%= one_of(Primer::TabNavHelper::EXTRA_ALIGN_OPTIONS) %> - Defaults to <%= Primer::TabNavHelper::EXTRA_ALIGN_DEFAULT %>

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



47
48
49
50
51
52
53
54
# File 'app/components/primer/alpha/tab_panels.rb', line 47

def initialize(label:, body_arguments: {}, wrapper_arguments: {}, **system_arguments)
  @align = EXTRA_ALIGN_DEFAULT

  @system_arguments = { **deny_tag_argument(**system_arguments), **deny_tag_argument(**wrapper_arguments) }
  @system_arguments[:tag] = :"tab-container"
  @system_arguments[:classes] = tab_nav_classes(@system_arguments[:classes])
  @system_arguments[:"aria-label"] = label
end

Instance Method Details

#before_renderObject



56
57
58
59
60
61
# File 'app/components/primer/alpha/tab_panels.rb', line 56

def before_render
  # Eagerly evaluate content to avoid https://github.com/primer/view_components/issues/1790
  content

  super
end