diff --git a/examples/progress.rb b/examples/progress.rb new file mode 100644 index 000000000..0d2721e3f --- /dev/null +++ b/examples/progress.rb @@ -0,0 +1,31 @@ +Shoes.app(width: 400, height: 300) do + flow do + stack(width: 0.5) do + para "this is initally at 30%" + @progress1 = progress fraction: 0.3 + + para "this is initally at 60%" + @progress2 = progress fraction: 0.6 + + para "this is initally at 80%" + @progress3 = progress fraction: 0.8 + + para "this is a normal progress bar with no initial value" + @progress4 = progress + end + + stack(width: 0.5) do + @start = button "Start" + @start.click { start_progress } + end + end + + def start_progress + animate do + @progress1.fraction += 0.01 + @progress2.fraction += 0.015 + @progress3.fraction += 0.02 + end + end + + end diff --git a/lacci/lib/shoes/drawables.rb b/lacci/lib/shoes/drawables.rb index f97e850d3..760e883bf 100644 --- a/lacci/lib/shoes/drawables.rb +++ b/lacci/lib/shoes/drawables.rb @@ -27,3 +27,4 @@ require "shoes/drawables/radio" require "shoes/drawables/span" require "shoes/drawables/video" +require "shoes/drawables/progress" diff --git a/lacci/lib/shoes/drawables/progress.rb b/lacci/lib/shoes/drawables/progress.rb new file mode 100644 index 000000000..51e211179 --- /dev/null +++ b/lacci/lib/shoes/drawables/progress.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Shoes + class Progress < Shoes::Drawable + shoes_styles :fraction + + def initialize(fraction: nil) + super + + create_display_drawable + end + end +end diff --git a/lib/scarpe/wv.rb b/lib/scarpe/wv.rb index 513efdd87..601a8367b 100644 --- a/lib/scarpe/wv.rb +++ b/lib/scarpe/wv.rb @@ -79,4 +79,5 @@ module Scarpe::Webview require_relative "wv/rect" require_relative "wv/video" require_relative "wv/check" +require_relative "wv/progress" require_relative "wv/arrow" diff --git a/lib/scarpe/wv/progress.rb b/lib/scarpe/wv/progress.rb new file mode 100644 index 000000000..d2720b9ab --- /dev/null +++ b/lib/scarpe/wv/progress.rb @@ -0,0 +1,26 @@ +# frozen_string_literal: true + +module Scarpe::Webview + class Progress < Drawable + def initialize(properties) + super + end + + def element + HTML.render do |h| + h.progress(id: html_id, style: style, max: 1, value: @fraction) do + end + end + end + + private + + def style + styles = {} + + #ADD YOUR STYLES HERE + + styles.compact + end + end +end diff --git a/lib/scarpe/wv/shape.rb b/lib/scarpe/wv/shape.rb index 884075cbe..cac3fee7d 100644 --- a/lib/scarpe/wv/shape.rb +++ b/lib/scarpe/wv/shape.rb @@ -2,7 +2,6 @@ module Scarpe::Webview class Shape < Drawable - def initialize(properties) super(properties) end diff --git a/scarpe-components/lib/scarpe/components/html.rb b/scarpe-components/lib/scarpe/components/html.rb index ffcbc60e1..9b121ec78 100644 --- a/scarpe-components/lib/scarpe/components/html.rb +++ b/scarpe-components/lib/scarpe/components/html.rb @@ -1,7 +1,8 @@ # frozen_string_literal: true class Scarpe::Components::HTML - CONTENT_TAGS = [:div, :p, :button, :ul, :li, :textarea, :a, :video, :strong, :style, :em, :code, :defs, :marker, :u, :line, :span, :svg, :h1, :h2, :h3, :h4, :h5].freeze + + CONTENT_TAGS = [:div, :p, :button, :ul, :li, :textarea, :a, :video, :strong, :style, :progress, :em, :code, :defs, :marker, :u, :line, :span, :svg, :h1, :h2, :h3, :h4, :h5].freeze VOID_TAGS = [:input, :img, :polygon, :source, :link, :path, :rect].freeze TAGS = (CONTENT_TAGS + VOID_TAGS).freeze