Archived
1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
cli-old/lib/widgets/sidebar.rb

41 lines
873 B
Ruby
Raw Normal View History

2017-07-21 11:00:11 -04:00
# frozen_string_literal: true
module Widgets
class Sidebar < Container
2017-07-30 22:25:53 -04:00
def trigger(event)
focus&.trigger event
end
2017-07-22 09:44:43 -04:00
2017-07-30 22:25:53 -04:00
def node
elem = render
React::Curses::Nodes.klass_for(elem).new nil, elem
end
2017-07-25 12:22:38 -04:00
2017-07-30 22:25:53 -04:00
def render
create_element :window, x: props[:x], y: props[:y], width: props[:width], height: props[:height] do
create_element :wrapper do
create_element Logo, props[:logo]
render_menu
end
end
end
2017-07-25 12:22:38 -04:00
2017-07-30 22:25:53 -04:00
def render_menu
create_element Menu, props[:menu].merge(
2017-07-25 12:22:38 -04:00
on_up: props[:on_menu_up],
on_down: props[:on_menu_down],
active_friend_index: props[:active_friend_index],
friends: props[:friends],
2017-07-25 12:22:38 -04:00
).freeze
end
2017-07-24 18:34:50 -04:00
def focus
case props[:focus]
2017-07-30 22:25:53 -04:00
when :menu then node.children[0].children[1].instance
2017-07-24 18:34:50 -04:00
end
end
2017-07-21 11:00:11 -04:00
end
end