Sha256: 960104e9d80a8dbe7436e10297c7557d844f012ee7147d94806a96d562ede461

Contents?: true

Size: 866 Bytes

Versions: 6

Compression:

Stored size: 866 Bytes

Contents

# frozen_string_literal: true

class Scarpe
  class GlimmerLibUIButton < GlimmerLibUIWidget
    def initialize(properties)
      super

      # Bind to display-side handler for "click"
      bind("click") do
        # This will be sent to the bind_self_event in Button
        send_self_event(event_name: "click")
      end
    end

    def element
      HTML.render do |h|
        h.button(id: html_id, onclick: handler_js_code("click"), style: style) do
          @text
        end
      end
    end

    private

    def style
      styles = {}

      styles[:width] = Dimensions.length(@width) if @width
      styles[:height] = Dimensions.length(@height) if @height

      styles[:top] = Dimensions.length(@top) if @top
      styles[:left] = Dimensions.length(@left) if @left
      styles[:position] = "absolute" if @top || @left

      styles
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

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