module Pakyow::Presenter::Renderer::Behavior::InsertPrototypeBar

@api private

Public Class Methods

ui_modes_html(view, current_modes) click to toggle source

@api private

# File lib/pakyow/presenter/renderer/behavior/insert_prototype_bar.rb, line 72
          def self.ui_modes_html(view, current_modes)
            current_modes = current_modes.map(&:to_sym)

            modes = view.object.each_significant_node(:mode).map { |node|
              node.label(:mode)
            }

            modes.unshift(
              (view.info(:mode) || :default).to_sym
            ).uniq!

            options = modes.map { |each_mode|
              selected = if current_modes.include?(each_mode)
                " selected=\"selected\""
              else
                ""
              end

              nice_mode = Support.inflector.humanize(Support.inflector.underscore(each_mode))
              "<option value=\"#{each_mode}\"#{selected}>#{nice_mode}</option>"
            }.join

            <<~HTML
              UI Mode: <select onchange="document.location = window.location.pathname + '?modes[]=' + this.value " style="-webkit-appearance: none; -moz-appearance: none; -ms-appearance: none; -o-appearance: none; appearance: none; font-size: 11px; font-weight: 500; line-height: 20px; background: none; border: none; color: #fff; outline: none; margin: 0; margin-left: 5px;">
                #{options}
              </select>
            HTML
          end