Sha256: d11209c9f13d2cd3ec0da441d6638b11e98dfbfe162ff53ebe06728a9206cb0d

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

module Voom
  module Presenters
    module DSL
      module Components
        class Drawer < Base
          include Mixins::Common
          include Mixins::Attaches

          attr_accessor :title, :subtitle, :components

          def initialize(**attribs_, &block)
            super(type: :drawer, **attribs_, &block)
            self.title(attribs.delete(:title)) if attribs.fetch(:title){nil}
            @components = []

            expand!
          end

          def menu(**attribs, &block)
            return @menu if locked?
            @menu = Menu.new(parent: self,
                             **attribs, &block)
          end

          def attach(presenter, **params, &block)
            pom = super
            @menu = pom.components.select {|i| i.type == :menu}.first
          end

          def title(*text, **attribs, &block)
            return @title if locked?
            @title = Components::Typography.new(parent: self, type: :text, text: text, **attribs, &block)
          end


          def subtitle(*text, **attribs, &block)
            return @subtitle if locked?
            @subtitle = Components::Typography.new(parent: self, type: :text, text: text, **attribs, &block)
          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/drawer.rb
voom-presenters-2.1.0 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-2.0.3 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-2.0.2 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-2.0.1 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-2.0.0 lib/voom/presenters/dsl/components/drawer.rb