Class: Emjay::Components::MjSpacer

Inherits:
BodyComponent show all
Defined in:
lib/emjay/components/body/mj_spacer.rb

Instance Attribute Summary

Attributes inherited from Emjay::Component

#attributes, #context, #props

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BodyComponent

#get_box_widths, #get_child_context, #get_shorthand_attr_value, #get_shorthand_border_value, #html_attributes, #render_children, #styles

Methods inherited from Emjay::Component

ending_tag?, #get_attribute, #get_child_context, #get_content, #initialize, raw_element?

Constructor Details

This class inherits a constructor from Emjay::Component

Class Method Details

.allowed_attributesObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/emjay/components/body/mj_spacer.rb', line 19

def self.allowed_attributes
  {
    "border" => "string",
    "border-bottom" => "string",
    "border-left" => "string",
    "border-right" => "string",
    "border-top" => "string",
    "container-background-color" => "color",
    "padding-bottom" => "unit(px,%)",
    "padding-left" => "unit(px,%)",
    "padding-right" => "unit(px,%)",
    "padding-top" => "unit(px,%)",
    "padding" => "unit(px,%){1,4}",
    "height" => "unit(px,%)"
  }
end

.component_nameObject



9
10
11
# File 'lib/emjay/components/body/mj_spacer.rb', line 9

def self.component_name
  "mj-spacer"
end

.default_attributesObject



13
14
15
16
17
# File 'lib/emjay/components/body/mj_spacer.rb', line 13

def self.default_attributes
  {
    "height" => "20px"
  }
end

Instance Method Details

#get_stylesObject



36
37
38
39
40
41
42
43
# File 'lib/emjay/components/body/mj_spacer.rb', line 36

def get_styles
  {
    div: {
      "height" => get_attribute("height"),
      "line-height" => get_attribute("height")
    }
  }
end

#renderObject



45
46
47
48
49
50
51
52
# File 'lib/emjay/components/body/mj_spacer.rb', line 45

def render
  div_attrs = html_attributes(style: :div)
  <<~HTML
    <div
      #{div_attrs}
    >&#8202;</div>
  HTML
end