2015-07-25 14:28:59 +02:00
|
|
|
|
|
|
|
|
|
|
|
class InstructionView
|
|
|
|
|
|
|
|
include React::Component
|
|
|
|
required_param :interpreter
|
|
|
|
required_param :instruction
|
|
|
|
|
|
|
|
define_state :active => ""
|
|
|
|
|
|
|
|
before_mount do
|
|
|
|
interpreter.register_event(:instruction_changed, self)
|
2015-07-25 20:04:20 +02:00
|
|
|
check_active interpreter.instruction
|
2015-07-25 14:28:59 +02:00
|
|
|
end
|
|
|
|
|
2015-07-25 20:04:20 +02:00
|
|
|
def check_active i
|
|
|
|
active! instruction == i ? "active" : ""
|
|
|
|
|
|
|
|
end
|
2015-07-25 14:28:59 +02:00
|
|
|
def instruction_changed old , ins
|
2015-07-25 20:04:20 +02:00
|
|
|
check_active ins
|
2015-07-25 14:28:59 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def render
|
|
|
|
return unless instruction
|
|
|
|
div :class => active do
|
|
|
|
instruction.to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|