Sha256: 684453aa2906eeffcb53d9407420108d47885d4e1a8b6d1cbcad57ab9d6f22e8

Contents?: true

Size: 1.26 KB

Versions: 6

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

class Scarpe
  class GlimmerLibUIAlert < GlimmerLibUIWidget
    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

6 entries across 6 versions & 2 rubygems

Version Path
scarpe-0.4.0 spikes/glibui/alert.rb
scarpe-0.3.0 spikes/glibui/alert.rb
scarpe-0.2.2 spikes/glibui/alert.rb
lacci-0.2.1 lib/scarpe/glibui/alert.rb
scarpe-0.2.1 lib/scarpe/glibui/alert.rb
scarpe-0.2.0 lib/scarpe/glibui/alert.rb