require 'yaml' require_relative 'helpers/indented_grid' Voom::Presenters.define(:component_status) do helpers Voom::Presenters::Helpers::Inflector helpers Demo::Helpers::IndentedGrid attach 'top_nav' attach 'component_drawer' helpers do def status @status ||= YAML::load_file(File.join(__dir__, '../../component-status.yml')) end def item_color(item) trace {item.inspect} case item when ->(i) {['low', 'not planned'].include?(i['Priority'])} :lightgray when ->(i) {(i.fetch('Completeness')||0) > 1} :DarkSeaGreen when ->(i) {(i.fetch('Completeness')||0)==1} :LightYellow when ->(i) {['medium', 'high'].include?(i['Priority']) && i['MDC']=='N' && i['MDL']=='N'} :lightcoral when ->(i) {i['Priority']=='medium'} :coral when ->(i) {i['Priority']=='now'} :CornflowerBlue else nil end end def key items = [{'Completeness' => 2, text: 'Available'}, {'Priority' => 'high', 'Completeness'=>1, 'MDC' => nil, 'MDL' => nil, text: 'Available with caveats'}, {'Priority' => 'now', 'Completeness'=>0, 'MDC' => nil, 'MDL' => nil, text: 'In progress'}, {'Priority' => 'medium', 'Completeness'=>0, 'MDC' => nil, 'MDL' => nil, text: 'Up Next'}, {'Priority' => 'medium', 'Completeness'=>0, 'MDC' => 'N', 'MDL' => 'N', text: 'Implementation needed'}, {'Priority' => 'low', 'Completeness'=>0, 'MDC' => 'N', 'MDL' => 'N', text: 'Not Planned'}, ] table do header do items.each do |item| column color: item_color(item) column item[:text] end end end end end indented_grid do display 'Component Status' key table do header do status.first.keys.each do |heading| column inflector.humanize(heading) end end status.each do |item| row do status.first.keys.each_with_index do |heading, index| value = item[heading] color = index ==0 ? item_color(item) : nil column value, color: color end end end end end end