Sha256: ef4dc15bdd4db853af484098bdd88ad0aee0c1887573d383cdf1b5112368c23a

Contents?: true

Size: 1.25 KB

Versions: 3

Compression:

Stored size: 1.25 KB

Contents

# frozen_string_literal: true

class Scarpe
  class WebviewAlert < WebviewWidget
    def initialize(properties)
      super

      bind("click") do
        send_self_event(event_name: "click")
      end
    end

    def element
      onclick = handler_js_code("click")

      HTML.render do |h|
        h.div(id: html_id, style: overlay_style) do
          h.div(style: modal_style) do
            h.div(style: text_style) { @text }
            h.button(style: button_style, onclick: onclick) { "OK" }
          end
        end
      end
    end

    private

    def overlay_style
      {
        position: "fixed",
        top: "0",
        left: "0",
        width: "100%",
        height: "100%",
        overflow: "auto",
        "z-index": "1",
        background: "rgba(0,0,0,0.4)",
        display: "flex",
        "align-items": "center",
        "justify-content": "center",
      }
    end

    def modal_style
      {
        "min-width": "200px",
        "min-height": "50px",
        padding: "10px",
        display: "flex",
        background: "#fefefe",
        "flex-direction": "column",
        "justify-content": "space-between",
        "border-radius": "9px",
      }
    end

    def text_style
      {}
    end

    def button_style
      {}
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
lacci-0.2.1 lib/scarpe/wv/alert.rb
scarpe-0.2.1 lib/scarpe/wv/alert.rb
scarpe-0.2.0 lib/scarpe/wv/alert.rb