Sha256: 4a98ab0dc97feb1bd2e5bd221771742b151e6466fa24c772a03c0cb6dc36be6a

Contents?: true

Size: 1.33 KB

Versions: 17

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Primer
  # 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(Primer::TabNavComponent) %>.
  #
  # This component requires javascript.
  class TabContainerComponent < Primer::Component
    # @example Default
    #   <%= render(Primer::TabContainerComponent.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 %>
    #
    # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
    def initialize(**system_arguments)
      @system_arguments = system_arguments
      @system_arguments[:tag] = "tab-container"
    end

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

    def render?
      content.present?
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
primer_view_components-0.0.38 app/components/primer/tab_container_component.rb
primer_view_components-0.0.37 app/components/primer/tab_container_component.rb
primer_view_components-0.0.36 app/components/primer/tab_container_component.rb
primer_view_components-0.0.35 app/components/primer/tab_container_component.rb
primer_view_components-0.0.34 app/components/primer/tab_container_component.rb
primer_view_components-0.0.33 app/components/primer/tab_container_component.rb
primer_view_components-0.0.32 app/components/primer/tab_container_component.rb
primer_view_components-0.0.31 app/components/primer/tab_container_component.rb
primer_view_components-0.0.30 app/components/primer/tab_container_component.rb
primer_view_components-0.0.29 app/components/primer/tab_container_component.rb
primer_view_components-0.0.28 app/components/primer/tab_container_component.rb
primer_view_components-0.0.27 app/components/primer/tab_container_component.rb
primer_view_components-0.0.26 app/components/primer/tab_container_component.rb
primer_view_components-0.0.25 app/components/primer/tab_container_component.rb
primer_view_components-0.0.24 app/components/primer/tab_container_component.rb
primer_view_components-0.0.23 app/components/primer/tab_container_component.rb
primer_view_components-0.0.22 app/components/primer/tab_container_component.rb