Sha256: 65488ad3ea4cf49918d7f0a3ce5010328d6e6b9f07f9d6b5f5ea306077ff5794

Contents?: true

Size: 1.43 KB

Versions: 25

Compression:

Stored size: 1.43 KB

Contents

# frozen_string_literal: true

module Primer
  module Alpha
    # 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::Alpha::TabNav) %>.
    #
    # This component requires javascript.
    class TabContainer < Primer::Component
      # @example Default
      #   <%= render(Primer::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 %>
      #
      # @param system_arguments [Hash] <%= link_to_system_arguments_docs %>
      def initialize(**system_arguments)
        @system_arguments = deny_tag_argument(**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
end

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
openproject-primer_view_components-0.6.3 app/components/primer/alpha/tab_container.rb
primer_view_components-0.6.0 app/components/primer/alpha/tab_container.rb
primer_view_components-0.5.1 app/components/primer/alpha/tab_container.rb
primer_view_components-0.5.0 app/components/primer/alpha/tab_container.rb
primer_view_components-0.4.0 app/components/primer/alpha/tab_container.rb
primer_view_components-0.3.1 app/components/primer/alpha/tab_container.rb
primer_view_components-0.3.0 app/components/primer/alpha/tab_container.rb
primer_view_components-0.2.0 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.9 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.8 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.7 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.6 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.5 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.4 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.3 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.2 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.1 app/components/primer/alpha/tab_container.rb
primer_view_components-0.1.0 app/components/primer/alpha/tab_container.rb
primer_view_components-0.0.123 app/components/primer/alpha/tab_container.rb
primer_view_components-0.0.122 app/components/primer/alpha/tab_container.rb