Polish the remote signer connection modal

This commit is contained in:
raucao committed 2026-11-27 15:43:01 +04:00
1 parent 7d9cf4b593
commit 78be012edd
5 files changed
+33 -9

No files matched your search

@@ -1,5 +1,5 @@
<section class="<%= section_class %>">
<h4 class="mb-0"><%= @title %></h4>
<h4 class="<%= title_class %>"><%= @title %></h4>
<% if @description.present? %>
<p class="mt-2 <%= text_class %> text-gray-600"><%= @description %></p>
@@ -27,7 +27,7 @@
<p class="mt-3 <%= text_class %>">Scan this QR code with your signer app, or copy the connection URI:</p>
<div class="mt-4 flex justify-center">
<div class="w-56 max-w-full rounded-lg bg-white p-3">
<div class="<%= qr_wrapper_class %> rounded-lg bg-white p-3">
<%= qr_svg %>
</div>
</div>
@@ -59,8 +59,9 @@
<p class="mt-2 hidden <%= text_class %> text-red-700" data-nostr-signer-connect-target="error"></p>
<p class="mt-4 hidden" data-nostr-signer-connect-target="retry">
<%= button_to "Try again", @create_url, method: :post, class: action_button_class %>
<p class="mt-4 hidden" hidden data-nostr-signer-connect-target="retry">
<%= button_to "Try again", @create_url, method: :post, class: action_button_class,
form: button_form_options %>
</p>
<% unless @modal %>
@@ -83,7 +84,7 @@
<% if @show_disconnect && @destroy_url.present? %>
<p class="mt-4">
<%= button_to "Cancel", @destroy_url, method: :delete,
class: cancel_button_class %>
class: cancel_button_class, form: button_form_options %>
</p>
<% end %>
</div>
@@ -19,6 +19,10 @@ class NostrSignerConnectComponent < ViewComponent::Base
@modal ? "" : "mt-8"
end
def title_class
@modal ? "mb-1 text-xl font-bold" : "mb-0"
end
def text_class
@modal ? "text-base" : "text-sm"
end
@@ -27,12 +31,20 @@ class NostrSignerConnectComponent < ViewComponent::Base
@modal ? "text-sm font-mono" : "text-xs"
end
def qr_wrapper_class
@modal ? "w-full" : "w-56 max-w-full"
end
def action_button_class
@modal ? "btn-md btn-gray" : "btn-sm btn-gray"
@modal ? "btn-md btn-gray w-full" : "btn-sm btn-gray"
end
def cancel_button_class
@modal ? "btn-md btn-outline text-gray-700" : "btn-sm btn-outline text-gray-700"
@modal ? "btn-md btn-outline text-gray-700 w-full" : "btn-sm btn-outline text-gray-700"
end
def button_form_options
@modal ? { class: "w-full" } : {}
end
def qr_svg
@@ -89,6 +89,9 @@ export default class extends Controller {
this.showError(message)
this.statusTarget.textContent = "Connection request ended."
if (this.hasDetailsTarget) this.detailsTarget.classList.add("hidden")
if (this.hasRetryTarget) this.retryTarget.classList.remove("hidden")
if (this.hasRetryTarget) {
this.retryTarget.classList.remove("hidden")
this.retryTarget.hidden = false
}
}
}
+1 -1
View File
@@ -96,7 +96,7 @@
<%= render ModalComponent.new(
show_close_button: false,
dismissible: false,
card_class: "w-80 max-w-[85vw]"
card_class: "w-96 max-w-[85vw]"
) do %>
<%= render NostrSignerConnectComponent.new(
pending_session: @pending_signer_session,
@@ -73,6 +73,14 @@ RSpec.describe NostrSignerConnectComponent, type: :component do
expect(rendered.css("p.text-base").any?).to be(true)
expect(rendered.css("button.btn-md").any?).to be(true)
expect(rendered.css("section.mt-8")).to be_empty
expect(rendered.css("h4").first["class"]).to include("text-xl", "font-bold")
expect(rendered.css("div.w-full.rounded-lg").any?).to be(true)
expect(rendered.css("div.w-56")).to be_empty
expect(rendered.css("button.w-full").size).to be >= 3
expect(rendered.css("form.w-full").size).to eq(2)
retry_node = rendered.css("[data-nostr-signer-connect-target='retry']").first
expect(retry_node["hidden"]).not_to be_nil
end
it "keeps the inline bunker option when no connection exists" do