Sha256: a5a6a85687e245213eb5fef90edb215071e862ef22857fd1623307269418c54f

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module RailsDevtools
  module Routes
    class RouteDetails::RoutePathInput < Components::ApplicationComponent
      def initialize(route:, prefix: "", suffix: "path")
        @route = route
        @prefix = prefix
        @suffix = suffix
      end

      def view_template
        turbo_frame_tag("route_path_input") do
          div(
            class: "join w-full",
            data_controller: "clipboard",
            data_clipboard_success_content_value: "Copied!"
          ) do
            input(
              value: input_value,
              class: "input input-bordered input-primary input-sm w-full join-item",
              data_clipboard_target: "source"
            )
            button(
              class: "btn btn-primary btn-outline btn-sm join-item",
              data_action: "clipboard#copy",
              data_clipboard_target: "button"
            ) { "Copy" }
          end
        end
      end

      private

      def input_value
        "#{prefix}#{@route.name}_#{@suffix}()"
      end

      def prefix
        return "" if @prefix.blank?

        "#{@prefix}."
      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/route_details/route_path_input.rb
rails_devtools-0.1.2 app/views/rails_devtools/routes/route_details/route_path_input.rb
rails_devtools-0.1.1 app/views/rails_devtools/routes/route_details/route_path_input.rb
rails_devtools-0.1.0 app/views/rails_devtools/routes/route_details/route_path_input.rb