Sha256: 6a772c8f9178ff5fc3b555e9c588b348887552cb3cf81011bb3234c6341dea40

Contents?: true

Size: 1020 Bytes

Versions: 4

Compression:

Stored size: 1020 Bytes

Contents

# frozen_string_literal: true

module RailsDevtools
  module Routes
    class Index < ApplicationView
      def initialize(form: nil, routes: [])
        @routes = routes
        @form = form
      end

      def view_template
        render Components::PageContent.new do |page|
          page.page_title { "Routes" }
          page.search_form(form: @form, path: helpers.routes_path, method: :get)
          page.results { results }
        end
      end

      private

      def results
        if @routes.values.all? { |routes| routes.empty? }
          div(class: "text-neutral") { "No results found" }
        else
          div(class: "flex gap-2 flex-wrap w-full items-start") do
            @routes.each do |engine, routes|
              h3(class: "first:mt-0 mt-4 text-neutral opacity-75 text-lg") { engine }
              routes.each do |route|
                render Routes::RouteCard.new(route: route, engine: engine)
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_devtools-0.1.3 app/views/rails_devtools/routes/index.rb
rails_devtools-0.1.2 app/views/rails_devtools/routes/index.rb
rails_devtools-0.1.1 app/views/rails_devtools/routes/index.rb
rails_devtools-0.1.0 app/views/rails_devtools/routes/index.rb