Sha256: e9c15439fbe54fbd787fbc4cf8a5e8ff51c096a328fa630e8bd935b05f722ca6

Contents?: true

Size: 1.75 KB

Versions: 9

Compression:

Stored size: 1.75 KB

Contents

require_relative 'mixins/common'

module Voom
  module Presenters
    module DSL
      module Components
        class Dialog < Base
          include Mixins::Common
          attr_accessor :width, :height, :buttons, :components, :shows_errors

          def initialize(**attribs_, &block)
            super(type: :dialog, **attribs_, &block)
            @width = attribs.delete(:width)
            @height = attribs.delete(:height)
            @shows_errors = attribs.delete(:shows_errors){true}

            @buttons = []
            @components=[]
            expand!
          end

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

          def heading(*text, **options, &block)
            components << Components::Typography.new(parent: self, type: :heading,
                                                     text: text, context: context,
                                                  **options, &block)
          end

          def body(*text, **options, &block)
            components << Components::Typography.new(parent: self, type: :body,
                                                     text: text, context: context,
                                                     **options, &block)
          end

          def button(text=nil, **attribs, &block)
            @buttons << Button.new(parent: self, text: text,
                                   context: context,
                                   **attribs, &block)
          end
        end
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
voom-presenters-0.1.8 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.7 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.6 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.5 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.4 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.3 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.2 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.1 lib/voom/presenters/dsl/components/dialog.rb
voom-presenters-0.1.0 lib/voom/presenters/dsl/components/dialog.rb