Class: RubyNative::Helper::NavbarBuilder
- Inherits:
-
Object
- Object
- RubyNative::Helper::NavbarBuilder
- Defined in:
- lib/ruby_native/helper.rb
Instance Method Summary collapse
- #button(title = nil, icon: nil, icons: 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.
103 104 105 106 |
# File 'lib/ruby_native/helper.rb', line 103 def initialize(context) @context = context @items = [] end |
Instance Method Details
#button(title = nil, icon: nil, icons: nil, href: nil, click: nil, position: :trailing, selected: false, &block) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ruby_native/helper.rb', line 108 def (title = nil, icon: nil, icons: nil, href: nil, click: nil, position: :trailing, selected: false, &block) resolved = RubyNative::Helper.resolve_icon(icon: icon, icons: icons, platform: @context.try(:native_platform)) data = { native_button: "" } data[:native_title] = title if title data[:native_icon] = resolved if resolved 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
127 128 129 130 131 132 133 |
# File 'lib/ruby_native/helper.rb', line 127 def (title: "Save", click: "[type='submit']") @items << @context.tag.div(data: { native_submit_button: "", native_title: title, native_click: click }) end |
#to_html ⇒ Object
135 136 137 |
# File 'lib/ruby_native/helper.rb', line 135 def to_html @context.safe_join(@items) end |