Class: Scarpe::WebviewAlert
- Inherits:
-
WebviewWidget
- Object
- Shoes::Linkable
- WebviewWidget
- Scarpe::WebviewAlert
- Defined in:
- lib/scarpe/wv/alert.rb
Constant Summary
Constants included from Shoes::Log
Shoes::Log::DEFAULT_COMPONENT, Shoes::Log::DEFAULT_DEBUG_LOG_CONFIG, Shoes::Log::DEFAULT_LOG_CONFIG
Instance Attribute Summary
Attributes inherited from WebviewWidget
#children, #parent, #shoes_linkable_id
Attributes inherited from Shoes::Linkable
Instance Method Summary collapse
- #button_style ⇒ Object protected
- #element ⇒ Object
-
#initialize(properties) ⇒ WebviewAlert
constructor
A new instance of WebviewAlert.
- #modal_style ⇒ Object protected
-
#overlay_style ⇒ Object
protected
If the whole widget is hidden, the parent style adds display:none.
- #text_style ⇒ Object protected
Methods inherited from WebviewWidget
#add_child, #bind, #destroy_self, display_class_for, #handler_js_code, #html_element, #html_id, #inspect, #needs_update!, #promise_update, #properties_changed, #remove_child, #rgb_to_hex, #set_parent, #style, #to_html
Methods included from Shoes::Log
configure_logger, #log_init, logger
Methods inherited from Shoes::Linkable
#bind_shoes_event, #send_self_event, #send_shoes_event, #unsub_shoes_event
Constructor Details
#initialize(properties) ⇒ WebviewAlert
Returns a new instance of WebviewAlert.
5 6 7 8 9 10 11 |
# File 'lib/scarpe/wv/alert.rb', line 5 def initialize(properties) super bind("click") do send_self_event(event_name: "click") end end |
Instance Method Details
#button_style ⇒ Object (protected)
62 63 64 |
# File 'lib/scarpe/wv/alert.rb', line 62 def {} end |
#element ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/scarpe/wv/alert.rb', line 13 def element onclick = handler_js_code("click") HTML.render do |h| h.div(id: html_id, style: ) do h.div(style: modal_style) do h.div(style: text_style) { @text } h.(style: , onclick: onclick) { "OK" } end end end end |
#modal_style ⇒ Object (protected)
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/scarpe/wv/alert.rb', line 45 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 |
#overlay_style ⇒ Object (protected)
If the whole widget is hidden, the parent style adds display:none
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/scarpe/wv/alert.rb', line 29 def { 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", }.merge(style) end |
#text_style ⇒ Object (protected)
58 59 60 |
# File 'lib/scarpe/wv/alert.rb', line 58 def text_style {} end |