Sha256: afdfc3a239e665709dfa515de3dbec6a793ef49b3d629440601812afd4af3e8e

Contents?: true

Size: 1.33 KB

Versions: 12

Compression:

Stored size: 1.33 KB

Contents

module Coprl
  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

12 entries across 12 versions & 1 rubygems

Version Path
coprl-3.0.0.beta.12 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.11 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.10 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.9 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.8 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.7 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.6 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.5 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.4 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.3 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.2 lib/coprl/presenters/dsl/components/tab_bar.rb
coprl-3.0.0.beta.1 lib/coprl/presenters/dsl/components/tab_bar.rb