Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress #398

Merged
merged 7 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions examples/progress.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lacci/lib/shoes/drawables.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@
require "shoes/drawables/radio"
require "shoes/drawables/span"
require "shoes/drawables/video"
require "shoes/drawables/progress"
13 changes: 13 additions & 0 deletions lacci/lib/shoes/drawables/progress.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions lib/scarpe/wv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
26 changes: 26 additions & 0 deletions lib/scarpe/wv/progress.rb
Original file line number Diff line number Diff line change
@@ -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
1 change: 0 additions & 1 deletion lib/scarpe/wv/shape.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

module Scarpe::Webview
class Shape < Drawable

def initialize(properties)
super(properties)
end
Expand Down
3 changes: 2 additions & 1 deletion scarpe-components/lib/scarpe/components/html.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down