Sha256: 6ca7f4a08e3092c8acab19640aab64706823754a6ccbb77af7a52b7f429e7128

Contents?: true

Size: 1.23 KB

Versions: 12

Compression:

Stored size: 1.23 KB

Contents

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

12 entries across 12 versions & 1 rubygems

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