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

Inherits:
EventBase show all
Includes:
Mixins::Attaches, Mixins::Common, 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::TextFields

#datetime_field, #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 Serializer

#to_hash

Methods included from Lockable

#lock!, #locked?

Constructor Details

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

Returns a new instance of Card.



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

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.



22
23
24
# File 'lib/voom/presenters/dsl/components/card.rb', line 22

def components
  @components
end

#heightObject (readonly)

Returns the value of attribute height.



22
23
24
# File 'lib/voom/presenters/dsl/components/card.rb', line 22

def height
  @height
end

#selectedObject (readonly)

Returns the value of attribute selected.



22
23
24
# File 'lib/voom/presenters/dsl/components/card.rb', line 22

def selected
  @selected
end

#shows_errorsObject (readonly)

Returns the value of attribute shows_errors.



22
23
24
# File 'lib/voom/presenters/dsl/components/card.rb', line 22

def shows_errors
  @shows_errors
end

#widthObject (readonly)

Returns the value of attribute width.



22
23
24
# File 'lib/voom/presenters/dsl/components/card.rb', line 22

def width
  @width
end

Instance Method Details

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



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

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

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



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

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

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



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

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