Sha256: ed30a6f3348a00dbc522c1de1c03c8dc6a2faba88e2a1542398e1d883b0b4c53

Contents?: true

Size: 777 Bytes

Versions: 6

Compression:

Stored size: 777 Bytes

Contents

# frozen_string_literal: true

class Scarpe
  class GlimmerLibUIImage < GlimmerLibUIWidget
    def initialize(properties)
      super
    end

    def element
      if @click
        HTML.render do |h|
          h.a(id: html_id, href: @click) { h.img(id: html_id, src: @url, style:) }
        end
      else
        HTML.render do |h|
          h.img(id: html_id, src: @url, style:)
        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/image.rb
scarpe-0.3.0 spikes/glibui/image.rb
scarpe-0.2.2 spikes/glibui/image.rb
lacci-0.2.1 lib/scarpe/glibui/image.rb
scarpe-0.2.1 lib/scarpe/glibui/image.rb
scarpe-0.2.0 lib/scarpe/glibui/image.rb