2015-07-22 21:05:31 +02:00
|
|
|
|
2015-07-23 16:26:48 +02:00
|
|
|
require "source_view"
|
2015-07-22 21:05:31 +02:00
|
|
|
|
|
|
|
class BlockView
|
|
|
|
|
|
|
|
include React::Component
|
2015-07-23 19:08:40 +02:00
|
|
|
required_param :interpreter
|
2015-07-22 21:05:31 +02:00
|
|
|
|
2015-07-24 09:01:01 +02:00
|
|
|
before_mount do
|
|
|
|
interpreter.register_event(event: :block_changed, listener: self, callback: :block_changed)
|
|
|
|
end
|
|
|
|
|
|
|
|
def block_changed block
|
|
|
|
block! block
|
|
|
|
end
|
2015-07-22 21:05:31 +02:00
|
|
|
|
|
|
|
def render
|
2015-07-23 16:26:48 +02:00
|
|
|
div.row do
|
2015-07-24 09:01:01 +02:00
|
|
|
div.col_md_5 do
|
2015-07-23 19:08:40 +02:00
|
|
|
SourceView :source => interpreter.block.codes.first.source
|
2015-07-23 16:26:48 +02:00
|
|
|
end
|
2015-07-24 09:01:01 +02:00
|
|
|
div.col_md_5 do
|
2015-07-23 19:08:40 +02:00
|
|
|
interpreter.block.codes.each do |code|
|
2015-07-23 16:26:48 +02:00
|
|
|
code.to_s.br
|
|
|
|
end
|
2015-07-22 21:05:31 +02:00
|
|
|
end
|
2015-07-24 09:01:01 +02:00
|
|
|
div.col_md_2 do
|
|
|
|
button.btn.btn_default { "next" }.on(:click) { interpreter.tick }
|
|
|
|
end
|
2015-07-22 21:05:31 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|