Sha256: e38ac231974d8b64963fea7e99065e54dff8fcfeae00d28bd1a5a7cce23dbd9c

Contents?: true

Size: 1.13 KB

Versions: 14

Compression:

Stored size: 1.13 KB

Contents

require_relative 'mixins/common'

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

          attr_accessor :title, :components

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

            expand!
          end

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

          def attach(presenter, **params, &block)
            pom = Voom::Presenters::App[presenter].call.expand_child(parent: self, context: context.merge(params), &block)
            @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, context: context, **attribs, &block)
          end

        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
voom-presenters-0.1.13 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.12 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.11 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.10 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.9 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.8 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.7 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.6 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.5 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.4 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.3 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.2 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.1 lib/voom/presenters/dsl/components/drawer.rb
voom-presenters-0.1.0 lib/voom/presenters/dsl/components/drawer.rb