Class: Emjay::Components::MjNavbar
- Inherits:
-
BodyComponent
- Object
- Emjay::Component
- BodyComponent
- Emjay::Components::MjNavbar
- Defined in:
- lib/emjay/components/body/mj_navbar.rb
Instance Attribute Summary
Attributes inherited from Emjay::Component
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_attributes ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/emjay/components/body/mj_navbar.rb', line 34 def self.allowed_attributes { "align" => "enum(left,center,right)", "base-url" => "string", "hamburger" => "string", "ico-align" => "enum(left,center,right)", "ico-open" => "string", "ico-close" => "string", "ico-color" => "color", "ico-font-size" => "unit(px,%)", "ico-font-family" => "string", "ico-text-transform" => "string", "ico-padding" => "unit(px,%){1,4}", "ico-padding-left" => "unit(px,%)", "ico-padding-top" => "unit(px,%)", "ico-padding-right" => "unit(px,%)", "ico-padding-bottom" => "unit(px,%)", "padding" => "unit(px,%){1,4}", "padding-left" => "unit(px,%)", "padding-top" => "unit(px,%)", "padding-right" => "unit(px,%)", "padding-bottom" => "unit(px,%)", "ico-text-decoration" => "string", "ico-line-height" => "unit(px,%,)" } end |
.component_name ⇒ Object
12 13 14 |
# File 'lib/emjay/components/body/mj_navbar.rb', line 12 def self.component_name "mj-navbar" end |
.default_attributes ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/emjay/components/body/mj_navbar.rb', line 16 def self.default_attributes { "align" => "center", "base-url" => nil, "hamburger" => nil, "ico-align" => "center", "ico-open" => "☰", "ico-close" => "⊗", "ico-color" => "#000000", "ico-font-size" => "30px", "ico-font-family" => "Ubuntu, Helvetica, Arial, sans-serif", "ico-text-transform" => "uppercase", "ico-padding" => "10px", "ico-text-decoration" => "none", "ico-line-height" => "30px" } end |
Instance Method Details
#get_styles ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/emjay/components/body/mj_navbar.rb', line 65 def get_styles { div: {}, label: { "display" => "block", "cursor" => "pointer", "mso-hide" => "all", "-moz-user-select" => "none", "user-select" => "none", "color" => get_attribute("ico-color"), "font-size" => get_attribute("ico-font-size"), "font-family" => get_attribute("ico-font-family"), "text-transform" => get_attribute("ico-text-transform"), "text-decoration" => get_attribute("ico-text-decoration"), "line-height" => get_attribute("ico-line-height"), "padding" => get_attribute("ico-padding"), "padding-top" => get_attribute("ico-padding-top"), "padding-right" => get_attribute("ico-padding-right"), "padding-bottom" => get_attribute("ico-padding-bottom"), "padding-left" => get_attribute("ico-padding-left") }, trigger: { "display" => "none", "max-height" => "0px", "max-width" => "0px", "font-size" => "0px", "overflow" => "hidden" }, icoOpen: { "mso-hide" => "all" }, icoClose: { "display" => "none", "mso-hide" => "all" } } end |
#head_style(breakpoint) ⇒ Object
61 62 63 |
# File 'lib/emjay/components/body/mj_navbar.rb', line 61 def head_style(breakpoint) "\n noinput.mj-menu-checkbox { display:block!important; max-height:none!important; visibility:visible!important; }\n\n @media only screen and (max-width:#{MakeLowerBreakpoint.call(breakpoint)}) {\n .mj-menu-checkbox[type=\"checkbox\"] ~ .mj-inline-links { display:none!important; }\n .mj-menu-checkbox[type=\"checkbox\"]:checked ~ .mj-inline-links,\n .mj-menu-checkbox[type=\"checkbox\"] ~ .mj-menu-trigger { display:block!important; max-width:none!important; max-height:none!important; font-size:inherit!important; }\n .mj-menu-checkbox[type=\"checkbox\"] ~ .mj-inline-links > a { display:block!important; }\n .mj-menu-checkbox[type=\"checkbox\"]:checked ~ .mj-menu-trigger .mj-menu-icon-close { display:block!important; }\n .mj-menu-checkbox[type=\"checkbox\"]:checked ~ .mj-menu-trigger .mj-menu-icon-open { display:none!important; }\n }\n " end |
#render ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/emjay/components/body/mj_navbar.rb', line 103 def render hamburger_html = (get_attribute("hamburger") == "hamburger") ? render_hamburger : "" div_attrs = html_attributes( class: "mj-inline-links", style: :div ) children = @props[:children] || [] children_html = render_children(children, attributes: {"navbarBaseUrl" => get_attribute("base-url")}) align = get_attribute("align") <<~HTML #{hamburger_html} <div #{div_attrs} > #{ConditionalTag.conditional_tag("<table role=\"presentation\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"#{align}\"><tr>")} #{children_html} #{ConditionalTag.conditional_tag("</tr></table>")} </div> HTML end |