Class: HStackComponent

Inherits:
Component show all
Defined in:
app/components/h_stack_component.rb

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/components/h_stack_component.rb', line 12

def to_s
  style_parts = [
    "display:flex",
    ("gap:#{spacing}px" if spacing > 0),
    ("justify-content:#{justify_value}" if justify != "start"),
    ("align-items:#{align_value}" if align != "start"),
    ("padding:#{padding}px" if padding),
    ("border-radius:#{rounded_value}" if rounded),
    ("background:#{bg}" if bg)
  ].compact.join(";")

  classes = [
    ("shadow-border-#{shadow}" if shadow)
  ].compact

  opts = {}
  opts[:class] = classes.join(" ") unless classes.empty?
  opts[:style] = style_parts unless style_parts.empty?

  tag.div(**opts) { @content }
end