Class: Yattho::Alpha::TabContainer

Inherits:
Component
  • Object
show all
Defined in:
app/components/yattho/alpha/tab_container.rb

Overview

Use ‘TabContainer` to create tabbed content with keyboard support. This component does not add any styles. It only provides the tab functionality. If you want styled Tabs you can look at <%= link_to_component(Yattho::Alpha::TabNav) %>.

This component requires javascript.

Direct Known Subclasses

TabContainerComponent

Constant Summary

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

Instance Method Summary collapse

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

Constructor Details

#initialize(**system_arguments) ⇒ TabContainer

Returns a new instance of TabContainer.

Examples:

Default

<%= render(Yattho::Alpha::TabContainer.new)  do %>
  <div role="tablist">
    <button type="button" role="tab" aria-selected="true">Tab one</button>
    <button type="button" role="tab" tabindex="-1">Tab two</button>
    <button type="button" role="tab" tabindex="-1">Tab three</button>
  </div>
  <div role="tabpanel">
    Panel 1
  </div>
  <div role="tabpanel" hidden>
    Panel 2
  </div>
  <div role="tabpanel" hidden>
    Panel 3
  </div>
<% end %>

Parameters:

  • system_arguments (Hash)

    <%= link_to_system_arguments_docs %>



29
30
31
32
# File 'app/components/yattho/alpha/tab_container.rb', line 29

def initialize(**system_arguments)
  @system_arguments = deny_tag_argument(**system_arguments)
  @system_arguments[:tag] = "tab-container"
end

Instance Method Details

#callObject



34
35
36
# File 'app/components/yattho/alpha/tab_container.rb', line 34

def call
  render(Yattho::BaseComponent.new(**@system_arguments)) { content }
end

#render?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/components/yattho/alpha/tab_container.rb', line 38

def render?
  content.present?
end