Class: Emjay::Components::MjBody
Instance Attribute Summary
#attributes, #context, #props
Class Method Summary
collapse
Instance Method Summary
collapse
#get_box_widths, #get_shorthand_attr_value, #get_shorthand_border_value, #html_attributes, #render_children, #styles
ending_tag?, #get_attribute, #get_content, #initialize, raw_element?
Class Method Details
.allowed_attributes ⇒ Object
17
18
19
20
21
22
23
|
# File 'lib/emjay/components/body/mj_body.rb', line 17
def self.allowed_attributes
{
"width" => "unit(px)",
"background-color" => "color",
"id" => "string"
}
end
|
.component_name ⇒ Object
9
10
11
|
# File 'lib/emjay/components/body/mj_body.rb', line 9
def self.component_name
"mj-body"
end
|
.default_attributes ⇒ Object
13
14
15
|
# File 'lib/emjay/components/body/mj_body.rb', line 13
def self.default_attributes
{"width" => "600px"}
end
|
Instance Method Details
#get_child_context ⇒ Object
25
26
27
|
# File 'lib/emjay/components/body/mj_body.rb', line 25
def get_child_context
@context.merge(container_width: get_attribute("width"))
end
|
#get_styles ⇒ Object
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/emjay/components/body/mj_body.rb', line 29
def get_styles
{
body: {
"word-spacing" => "normal",
"background-color" => get_attribute("background-color")
},
div: {
"word-spacing" => "normal",
"background-color" => get_attribute("background-color")
}
}
end
|
#render ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/emjay/components/body/mj_body.rb', line 42
def render
global_data = @context[:global_data]
lang = global_data&.lang || "und"
dir = global_data&.dir || "auto"
title = global_data&.title || ""
preview = global_data&.preview || ""
preview_html = if preview.empty?
""
else
%(\n <div style="display:none;font-size:1px;color:#ffffff;line-height:1px;max-height:0px;max-width:0px;opacity:0;overflow:hidden;">#{preview}</div>\n )
end
title_attr = title.empty? ? "" : " aria-label=\"#{title}\""
<<~HTML
<body#{html_attributes(id: get_attribute("id"), class: get_attribute("css-class"), style: :body)}>
#{preview_html}
<div#{title_attr} aria-roledescription="email" role="article" lang="#{lang}" dir="#{dir}"#{html_attributes(style: :div)}>
#{render_children}
</div>
</body>
HTML
end
|