Sha256: ca6efad6dd5b98410cdeb78743d31d244c87828630e831b12d2b9b0317b9a83d

Contents?: true

Size: 1.33 KB

Versions: 16

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

16 entries across 16 versions & 1 rubygems

Version Path
primer_view_components-0.0.54 app/components/primer/tab_container_component.rb
primer_view_components-0.0.53 app/components/primer/tab_container_component.rb
primer_view_components-0.0.52 app/components/primer/tab_container_component.rb
primer_view_components-0.0.51 app/components/primer/tab_container_component.rb
primer_view_components-0.0.50 app/components/primer/tab_container_component.rb
primer_view_components-0.0.49 app/components/primer/tab_container_component.rb
primer_view_components-0.0.48 app/components/primer/tab_container_component.rb
primer_view_components-0.0.47 app/components/primer/tab_container_component.rb
primer_view_components-0.0.46 app/components/primer/tab_container_component.rb
primer_view_components-0.0.45 app/components/primer/tab_container_component.rb
primer_view_components-0.0.44 app/components/primer/tab_container_component.rb
primer_view_components-0.0.43 app/components/primer/tab_container_component.rb
primer_view_components-0.0.42 app/components/primer/tab_container_component.rb
primer_view_components-0.0.41 app/components/primer/tab_container_component.rb
primer_view_components-0.0.40 app/components/primer/tab_container_component.rb
primer_view_components-0.0.39 app/components/primer/tab_container_component.rb