Sha256: 74f59657b1599381f943161baeef70d7a0010e5731b366cfebefd297c7c2e785

Contents?: true

Size: 1.98 KB

Versions: 12

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

module Primer
  module Alpha
    # @label TabNav
    class TabNavPreview < ViewComponent::Preview
      # @label Playground
      #
      # @param number_of_tabs [Integer] number
      # @param with_icons [Boolean] toggle
      # @param with_counters [Boolean] toggle
      def playground(number_of_tabs: 3, with_icons: false, with_counters: false)
        render(Primer::Alpha::TabNav.new(label: "label")) do |component|
          Array.new(number_of_tabs || 3) do |i|
            component.with_tab(selected: i.zero?, href: "##{i + 1}") do |tab|
              tab.with_icon(icon: :star) if with_icons
              tab.with_text { "Tab #{i + 1}" }
              tab.with_counter(count: 10) if with_counters
            end
          end
        end
      end

      # @label Default
      def default
        render(Primer::Alpha::TabNav.new(label: "Default")) do |component|
          component.with_tab(selected: true, href: "#") { "Tab 1" }
          component.with_tab(href: "#") { "Tab 2" }
          component.with_tab(href: "#") { "Tab 3" }
        end
      end

      # @label With icons and counters
      def with_icons_and_counters
        render(Primer::Alpha::TabNav.new(label: "With icons and counters")) do |component|
          component.with_tab(href: "#1", selected: true) do |tab|
            tab.with_icon(icon: :star)
            tab.with_text { "Stars" }
            tab.with_counter(count: 10)
          end
          component.with_tab(href: "#2") do |tab|
            tab.with_icon(icon: :heart)
            tab.with_text { "Sponsors" }
            tab.with_counter(count: 14)
          end
          component.with_tab(href: "#3") do |tab|
            tab.with_icon(icon: :bookmark)
            tab.with_text { "Bookmarks" }
            tab.with_counter(count: 7)
          end
        end
      end

      # @param align [Symbol] select [left, right]
      def with_extra(align: :right)
        render_with_template(locals: { align: align })
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
primer_view_components-0.3.1 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.3.0 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.2.0 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.9 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.8 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.7 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.6 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.5 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.4 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.3 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.2 previews/primer/alpha/tab_nav_preview.rb
primer_view_components-0.1.1 previews/primer/alpha/tab_nav_preview.rb