Sha256: 974c5554291cdffb82fb7cbfa1b9fff9b778cf196391e8d8504fbaaacc7ad9a1

Contents?: true

Size: 969 Bytes

Versions: 2

Compression:

Stored size: 969 Bytes

Contents

# frozen_string_literal: true

class Scarpe
  class WebviewStack < Scarpe::WebviewWidget
    include Scarpe::WebviewBackground
    include Scarpe::WebviewBorder
    include Scarpe::WebviewSpacing

    def initialize(properties)
      super
    end

    def element(&block)
      HTML.render do |h|
        h.div(id: html_id, style: style, &block)
      end
    end

    def get_style
      style
    end

    private

    def style
      styles = super

      styles["margin-top"] = @margin_top if @margin_top
      styles["margin-bottom"] = @margin_bottom if @margin_bottom
      styles["margin-left"] = @margin_left if @margin_left
      styles["margin-right"] = @margin_right if @margin_right

      styles[:display] = "flex"
      styles["flex-direction"] = "column"
      styles[:width] = Dimensions.length(@width) if @width
      styles[:height] = Dimensions.length(@height) if @height
      styles["overflow"] = "auto" if @scroll

      styles
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
scarpe-0.2.1 lib/scarpe/wv/stack.rb
scarpe-0.2.0 lib/scarpe/wv/stack.rb