Sha256: 07fd6ceaf2ea50e38a9e635763c74d076e91397a095f10b6dd2a45cd2f97bf82

Contents?: true

Size: 685 Bytes

Versions: 2

Compression:

Stored size: 685 Bytes

Contents

module Lookbook
  class Tabs::Component < Lookbook::Component
    renders_many :tabs, ->(**attrs) do
      @tab_counter += 1
      attrs[:name] ||= "tab-#{@tab_counter}"
      attrs[:position] ||= @tab_counter
      attrs[:theme] ||= @theme
      dropdown_tab(**attrs)
      Lookbook::Tabs::Tab::Component.new(**attrs)
    end

    renders_many :dropdown_tabs, ->(name:, **attrs) do
      Lookbook::Tabs::DropdownTab::Component.new(name: "dropdown-#{name}", **attrs)
    end

    def initialize(theme: :toolbar, **html_attrs)
      @theme = theme
      @tab_counter = 0
      super(**html_attrs)
    end

    protected

    def alpine_component
      "tabsComponent"
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lookbook-1.0.0.beta.2 app/components/lookbook/tabs/component.rb
lookbook-1.0.0.beta.1 app/components/lookbook/tabs/component.rb