Class: Voom::Presenters::DSL::Components::Card

Inherits:
EventBase show all
Includes:
Mixins::Attaches, Mixins::Common, Mixins::DateTimeFields, Mixins::Icons, Mixins::Snackbars, Mixins::TextFields
Defined in:
lib/voom/presenters/dsl/components/card.rb

Defined Under Namespace

Classes: Actions, Media

Instance Attribute Summary collapse

Attributes inherited from EventBase

#event_parent_id

Attributes included from Mixins::Event

#events

Attributes inherited from Base

#attributes, #context, #id, #type

Instance Method Summary collapse

Methods included from Mixins::Snackbars

#snackbar

Methods included from Mixins::Icons

#icon

Methods included from Mixins::DateTimeFields

#date_field, #datetime_field, #time_field

Methods included from Mixins::TextFields

#hidden_field, #text_area, #text_field

Methods included from Mixins::Attaches

#attach

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::Buttons

#button

Methods included from Mixins::Grids

#grid

Methods included from Mixins::Typography

#body, #display, #headline, #subheading, #title

Methods included from Mixins::Append

#<<, #yield_to

Methods included from Mixins::Toggles

#checkbox, #icon_toggle, #radio_button, #switch

Methods included from Mixins::Event

#event

Methods inherited from Base

#expand!

Methods included from Mixins::YieldTo

#yield_to

Methods included from Serializer

#to_hash

Methods included from Lockable

#lock!, #locked?

Constructor Details

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

Returns a new instance of Card.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/voom/presenters/dsl/components/card.rb', line 27

def initialize(**attribs_, &block)
  super(type: :card, **attribs_, &block)
  @height = attribs.delete(:height)
  @width = attribs.delete(:width)
  @selected = attribs.delete(:selected) {false}
  self.text(attribs.delete(:text)) if attribs.key?(:text)
  @shows_errors = attribs.delete(:shows_errors){true}

  @components = []
  expand!
end

Instance Attribute Details

#componentsObject (readonly)

Returns the value of attribute components.



24
25
26
# File 'lib/voom/presenters/dsl/components/card.rb', line 24

def components
  @components
end

#heightObject (readonly)

Returns the value of attribute height.



24
25
26
# File 'lib/voom/presenters/dsl/components/card.rb', line 24

def height
  @height
end

#selectedObject (readonly)

Returns the value of attribute selected.



24
25
26
# File 'lib/voom/presenters/dsl/components/card.rb', line 24

def selected
  @selected
end

#shows_errorsObject (readonly)

Returns the value of attribute shows_errors.



24
25
26
# File 'lib/voom/presenters/dsl/components/card.rb', line 24

def shows_errors
  @shows_errors
end

#widthObject (readonly)

Returns the value of attribute width.



24
25
26
# File 'lib/voom/presenters/dsl/components/card.rb', line 24

def width
  @width
end

Instance Method Details

#actions(**attribs, &block) ⇒ Object



95
96
97
98
99
100
# File 'lib/voom/presenters/dsl/components/card.rb', line 95

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

#media(**attribs, &block) ⇒ Object



39
40
41
42
43
44
# File 'lib/voom/presenters/dsl/components/card.rb', line 39

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

#text(*text, **attribs, &block) ⇒ Object



90
91
92
93
# File 'lib/voom/presenters/dsl/components/card.rb', line 90

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