This is a view component that renders out the file tree in the editor menu for RailsInspire.
<%= tag.ul(class: "ml-4") do %> <% @tree.map do |node| %> <%= tag.li do %> <% if node.last.is_a?(SampleFile) %> <%= link_to [node.last.sample, node.last], class: "flex items-center space-x-1 ml-5 mb-2 hover:text-blue-300" do %> <div><%= render "icons/heroicons/outline/document-text" %></div> <div><%= node.first %></div> <% end %> <% else %> <div class="flex items-center space-x-1 mb-1"> <div class="flex items-center"> <%= render "icons/heroicons/solid/chevron-down" %> <%= render "icons/heroicons/solid/folder" %> </div> <div><%= node.first %></div> </div> <%= render FileTreeComponent.new(node.last) %> <% end %> <% end %> <% end %> <% end %>
The view component uses recursion to render children of each node.