Class: Voom::Presenters::DSL::Components::Dialog

Inherits:
Base
  • Object
show all
Includes:
Mixins::Common
Defined in:
lib/voom/presenters/dsl/components/dialog.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#attributes, #context, #id, #type

Instance Method Summary collapse

Methods included from Mixins::Common

#badge, #card, #form, #list, #table

Methods included from Mixins::Menus

#menu

Methods included from Mixins::Content

#content

Methods included from Mixins::ExpansionPanels

#expansion_panel

Methods included from Mixins::Grids

#grid

Methods included from Mixins::Typography

#display, #headline, #subheading

Methods included from Mixins::Append

#<<, #yield_to

Methods included from Mixins::Toggles

#checkbox, #icon_toggle, #radio_button, #switch

Methods inherited from Base

#expand!

Methods included from Serializer

#to_hash

Methods included from Lockable

#lock!, #locked?

Constructor Details

#initialize(**attribs_, &block) ⇒ Dialog

Returns a new instance of Dialog.



11
12
13
14
15
16
17
18
19
20
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 11

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

Instance Attribute Details

#buttonsObject

Returns the value of attribute buttons.



9
10
11
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 9

def buttons
  @buttons
end

#componentsObject

Returns the value of attribute components.



9
10
11
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 9

def components
  @components
end

#heightObject

Returns the value of attribute height.



9
10
11
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 9

def height
  @height
end

#shows_errorsObject

Returns the value of attribute shows_errors.



9
10
11
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 9

def shows_errors
  @shows_errors
end

#widthObject

Returns the value of attribute width.



9
10
11
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 9

def width
  @width
end

Instance Method Details

#body(*text, **options, &block) ⇒ Object



35
36
37
38
39
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 35

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

#button(text = nil, **attribs, &block) ⇒ Object



41
42
43
44
45
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 41

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

#heading(*text, **options, &block) ⇒ Object



29
30
31
32
33
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 29

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

#title(*title, **options, &block) ⇒ Object



22
23
24
25
26
27
# File 'lib/voom/presenters/dsl/components/dialog.rb', line 22

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