Class: Essence::Row

Inherits:
Essence
  • Object
show all
Defined in:
lib/essence/components/row.rb

Constant Summary collapse

CLASS =
"flex gap-4"
KINDS =
{
  default: "flex-col md:flex-row md:items-center md:justify-between",
  center: "flex-col md:flex-row md:items-center md:justify-center",
  start: "flex-col md:flex-row md:items-center md:justify-start",
  end: "flex-col md:flex-row md:items-center md:justify-end",
}

Constants inherited from Essence

Essence::TAILWIND_MERGER

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind: :default, **attributes) ⇒ Row

Returns a new instance of Row.



16
17
18
19
20
# File 'lib/essence/components/row.rb', line 16

def initialize(kind: :default, **attributes)
  @kind = kind
  @attributes = attributes
  @attributes[:class] = @attributes[:class] ? TAILWIND_MERGER.merge([ CLASS, KINDS[kind], @attributes[:class] ]) : CLASS
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



14
15
16
# File 'lib/essence/components/row.rb', line 14

def attributes
  @attributes
end

#kindObject (readonly)

Returns the value of attribute kind.



13
14
15
# File 'lib/essence/components/row.rb', line 13

def kind
  @kind
end

Instance Method Details

#item(**attrs) ⇒ Object



26
27
28
# File 'lib/essence/components/row.rb', line 26

def item(**attrs, &)
  div(class: TAILWIND_MERGER.merge([ "flex items-center gap-2 flex-wrap", iattrs[:class] ]), **attrs, &)
end

#view_templateObject



22
23
24
# File 'lib/essence/components/row.rb', line 22

def view_template(&)
  div(**attributes, &)
end