Class: RubyNative::Helper::NavbarBuilder
- Inherits:
-
Object
- Object
- RubyNative::Helper::NavbarBuilder
- Defined in:
- lib/ruby_native/helper.rb
Instance Method Summary collapse
- #button(icon: nil, title: nil, href: nil, click: nil, position: :trailing, selected: false, &block) ⇒ Object
-
#initialize(context) ⇒ NavbarBuilder
constructor
A new instance of NavbarBuilder.
- #submit_button(title: "Save", click: "[type='submit']") ⇒ Object
- #to_html ⇒ Object
Constructor Details
#initialize(context) ⇒ NavbarBuilder
Returns a new instance of NavbarBuilder.
124 125 126 127 |
# File 'lib/ruby_native/helper.rb', line 124 def initialize(context) @context = context @items = [] end |
Instance Method Details
#button(icon: nil, title: nil, href: nil, click: nil, position: :trailing, selected: false, &block) ⇒ Object
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/ruby_native/helper.rb', line 129 def (icon: nil, title: nil, href: nil, click: nil, position: :trailing, selected: false, &block) data = { native_button: "" } data[:native_icon] = icon if icon data[:native_title] = title if title data[:native_href] = href if href data[:native_click] = click if click data[:native_position] = position.to_s data[:native_selected] = "" if selected if block = NavbarMenuBuilder.new(@context) @context.capture(, &block) @items << @context.tag.div(data: data) { .to_html } else @items << @context.tag.div(data: data) end end |
#submit_button(title: "Save", click: "[type='submit']") ⇒ Object
147 148 149 150 151 152 153 |
# File 'lib/ruby_native/helper.rb', line 147 def (title: "Save", click: "[type='submit']") @items << @context.tag.div(data: { native_submit_button: "", native_title: title, native_click: click }) end |
#to_html ⇒ Object
155 156 157 |
# File 'lib/ruby_native/helper.rb', line 155 def to_html @context.safe_join(@items) end |