Sha256: e549e3e266684e07d909b8e96b99a09210d27b0a18a920a4082db523124ed40a

Contents?: true

Size: 1.33 KB

Versions: 6

Compression:

Stored size: 1.33 KB

Contents

module Voom
  module Presenters
    module DSL
      module Components
        class TabBar < Base
          attr_reader :tabs

          def initialize(**attribs_, &block)
            super(type: :tab_bar, **attribs_, &block)
            @tabs = []
            expand!
          end

          def tab(label, **attribs, &block)
            @tabs << Tab.new(parent: self, label: label, **attribs, &block)
          end

          class Tab < EventBase
            include Mixins::Common

            attr_accessor :components, :label, :icon, :stacked, :selected

            def initialize(**attribs_, &block)
              super(type: :tab, **attribs_, &block)
              @label = attribs.delete(:label){nil}
              @icon = attribs.delete(:icon) {nil}
              @stacked = attribs.delete(:stacked) {false}
              @selected = attribs.delete(:selected) {false}
              @components = []
              expand!
            end

            def label(text = nil)
              return @label if locked?
              @label = text
            end

            def icon(icon = nil, **attribs, &block)
              return @icon if locked?
              @icon = Components::Icon.new(parent: self, icon: icon,
                                           **attribs, &block)
            end

          end
        end

      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
voom-presenters-2.1.2 lib/voom/presenters/dsl/components/tab_bar.rb
voom-presenters-2.1.0 lib/voom/presenters/dsl/components/tab_bar.rb
voom-presenters-2.0.3 lib/voom/presenters/dsl/components/tab_bar.rb
voom-presenters-2.0.2 lib/voom/presenters/dsl/components/tab_bar.rb
voom-presenters-2.0.1 lib/voom/presenters/dsl/components/tab_bar.rb
voom-presenters-2.0.0 lib/voom/presenters/dsl/components/tab_bar.rb