Class: RailsDevtools::Routes::RouteCard

Inherits:
Components::ApplicationComponent show all
Defined in:
app/views/rails_devtools/routes/route_card.rb

Instance Method Summary collapse

Methods inherited from Components::ApplicationComponent

#before_template

Constructor Details

#initialize(route:, engine:) ⇒ RouteCard

Returns a new instance of RouteCard.



5
6
7
8
# File 'app/views/rails_devtools/routes/route_card.rb', line 5

def initialize(route:, engine:)
  @route = route
  @engine = engine
end

Instance Method Details

#view_templateObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/views/rails_devtools/routes/route_card.rb', line 10

def view_template
  a(
    href: helpers.route_path(
      @route.id
    ),
    data: { turbo_frame: "drawer_content", action: "click->checkbox#toggle" },
    class: "group flex w-full"
  ) do
    div(class: "card card-compact bg-white text-sm w-full shadow-sm") do
      div(class: "card-body") do
        div(class: "flex flex-col sm:flex-row justify-between sm:items-center gap-y-2 sm:gap-x-2") do
          div(class: "flex items-center") do
            h2(class: "inline-flex card-title !mb-0 leading-none text-base items-center") do
              route_name
            end
            redirection_badge
            no_matching_controller_alert
            engine_badge
          end
          div(class: "flex gap-2 items-center justify-between sm:justify-normal") do
            div(class: "truncate") { @route.path.gsub("(.:format)", "") }
            div(class: "badge badge-sm ml-1") { @route.verb }
          end
        end
      end
    end
  end
end