showing active instruction with bg
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
|
||||
require "source_view"
|
||||
require "instruction_view"
|
||||
|
||||
class BlockView
|
||||
|
||||
@ -26,7 +27,7 @@ class BlockView
|
||||
div.col_md_5 do
|
||||
h6 { "Block: #{block.name}"}
|
||||
block.codes.each do |code|
|
||||
code.to_s.br
|
||||
InstructionView :interpreter => interpreter , :instruction => code
|
||||
end
|
||||
end
|
||||
div.col_md_2 do
|
||||
|
25
app/instruction_view.rb
Normal file
25
app/instruction_view.rb
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
|
||||
class InstructionView
|
||||
|
||||
include React::Component
|
||||
required_param :interpreter
|
||||
required_param :instruction
|
||||
|
||||
define_state :active => ""
|
||||
|
||||
before_mount do
|
||||
interpreter.register_event(:instruction_changed, self)
|
||||
end
|
||||
|
||||
def instruction_changed old , ins
|
||||
active! instruction == ins ? "active" : ""
|
||||
end
|
||||
|
||||
def render
|
||||
return unless instruction
|
||||
div :class => active do
|
||||
instruction.to_s
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user