Match the remote signer login screen to the app's normal typography
This commit is contained in:
5 files changed
+64
-23
No files matched your search
@@ -1,5 +1,7 @@
|
||||
<section class="<%= section_class %>">
|
||||
<h4 class="<%= title_class %>"><%= @title %></h4>
|
||||
<% if @title.present? %>
|
||||
<h4 class="<%= title_class %>"><%= @title %></h4>
|
||||
<% end %>
|
||||
|
||||
<% if @description.present? %>
|
||||
<p class="mt-2 <%= text_class %> text-gray-600"><%= @description %></p>
|
||||
@@ -28,9 +30,7 @@
|
||||
data-nostr-signer-connect-status-url-value="<%= @status_url %>">
|
||||
<% unless @pending_session.bunker? %>
|
||||
<div data-nostr-signer-connect-target="details">
|
||||
<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="<%= @title.present? ? "mt-4" : "" %> flex justify-center">
|
||||
<div class="<%= qr_wrapper_class %> rounded-lg bg-white p-3">
|
||||
<%= qr_svg %>
|
||||
</div>
|
||||
@@ -69,17 +69,17 @@
|
||||
</div>
|
||||
|
||||
<% unless @modal %>
|
||||
<details class="mt-4 text-sm">
|
||||
<details class="mt-4">
|
||||
<summary class="cursor-pointer text-gray-600">Prefer a bunker:// URI?</summary>
|
||||
<%= form_with url: @create_url, method: :post, local: true, class: "mt-3" do %>
|
||||
<p>
|
||||
<%= text_field_tag :bunker_uri, nil,
|
||||
placeholder: "bunker://…",
|
||||
class: "w-full text-xs",
|
||||
class: "w-full",
|
||||
autocomplete: "off" %>
|
||||
</p>
|
||||
<p class="mt-2">
|
||||
<%= submit_tag "Connect bunker", class: "btn-sm btn-gray" %>
|
||||
<%= submit_tag "Connect bunker", class: "btn-md btn-gray" %>
|
||||
</p>
|
||||
<% end %>
|
||||
</details>
|
||||
@@ -93,7 +93,7 @@
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="mt-3 text-sm">
|
||||
<p class="mt-3">
|
||||
Connect a signer app on your phone or desktop. Your private key never leaves your signer.
|
||||
</p>
|
||||
|
||||
@@ -102,17 +102,17 @@
|
||||
class: "btn-md btn-blue w-full sm:w-auto" %>
|
||||
</div>
|
||||
|
||||
<details class="mt-4 text-sm">
|
||||
<details class="mt-4">
|
||||
<summary class="cursor-pointer text-gray-600">Already have a bunker:// URI?</summary>
|
||||
<%= form_with url: @create_url, method: :post, local: true, class: "mt-3" do %>
|
||||
<p>
|
||||
<%= text_field_tag :bunker_uri, nil,
|
||||
placeholder: "bunker://…",
|
||||
class: "w-full text-xs",
|
||||
class: "w-full",
|
||||
autocomplete: "off" %>
|
||||
</p>
|
||||
<p class="mt-2">
|
||||
<%= submit_tag "Connect bunker", class: "btn-sm btn-gray" %>
|
||||
<%= submit_tag "Connect bunker", class: "btn-md btn-gray" %>
|
||||
</p>
|
||||
<% end %>
|
||||
</details>
|
||||
|
||||
@@ -16,7 +16,9 @@ class NostrSignerConnectComponent < ViewComponent::Base
|
||||
end
|
||||
|
||||
def section_class
|
||||
@modal ? "" : "mt-8"
|
||||
return "" if @modal || @title.blank?
|
||||
|
||||
"mt-8"
|
||||
end
|
||||
|
||||
def title_class
|
||||
@@ -24,23 +26,23 @@ class NostrSignerConnectComponent < ViewComponent::Base
|
||||
end
|
||||
|
||||
def text_class
|
||||
@modal ? "text-base" : "text-sm"
|
||||
"text-base"
|
||||
end
|
||||
|
||||
def input_class
|
||||
@modal ? "text-sm font-mono" : "text-xs"
|
||||
"text-sm font-mono"
|
||||
end
|
||||
|
||||
def qr_wrapper_class
|
||||
@modal ? "w-[264px] max-w-full" : "w-56 max-w-full"
|
||||
@modal ? "w-[264px] max-w-full" : "w-[232px] max-w-full"
|
||||
end
|
||||
|
||||
def action_button_class
|
||||
@modal ? "btn-md btn-gray w-full" : "btn-sm btn-gray"
|
||||
@modal ? "btn-md btn-gray w-full" : "btn-md btn-gray"
|
||||
end
|
||||
|
||||
def cancel_button_class
|
||||
@modal ? "btn-md btn-outline text-gray-700 w-full" : "btn-sm btn-outline text-gray-700"
|
||||
@modal ? "btn-md btn-outline text-gray-700 w-full" : "btn-md btn-outline text-gray-700"
|
||||
end
|
||||
|
||||
def button_form_options
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
<%= render HeaderCompactComponent.new(title: "Log in with a remote signer") %>
|
||||
<%= render HeaderCompactComponent.new(title: "Log in") %>
|
||||
|
||||
<%= render MainCompactComponent.new do %>
|
||||
<p class="mb-6 text-sm text-gray-600">
|
||||
Open your Nostr signer app and scan the QR code, or paste a bunker URI.
|
||||
Your private key stays in your signer.
|
||||
<h2 class="mb-2 text-xl font-bold text-gray-900">Remote signer</h2>
|
||||
|
||||
<p class="mb-6 text-gray-600">
|
||||
Open your Nostr signer app and scan the QR code, or copy the connection URL
|
||||
and paste it in your signer app.
|
||||
</p>
|
||||
|
||||
<%= render NostrSignerConnectComponent.new(
|
||||
pending_session: @signer_session,
|
||||
create_url: nostr_connect_path,
|
||||
status_url: nostr_connect_status_path,
|
||||
title: "Remote signer",
|
||||
title: nil,
|
||||
show_disconnect: false
|
||||
) %>
|
||||
|
||||
|
||||
@@ -47,9 +47,36 @@ RSpec.describe NostrSignerConnectComponent, type: :component do
|
||||
expect(svg["width"]).to be_nil
|
||||
expect(svg["height"]).to be_nil
|
||||
expect(svg["class"]).to include("w-full")
|
||||
expect(rendered.css("div.w-56").any?).to be(true)
|
||||
|
||||
qr_wrapper = rendered.css("div.rounded-lg.bg-white").first
|
||||
expect(qr_wrapper["class"]).to include("w-[232px]", "max-w-full")
|
||||
expect(rendered.css("[data-nostr-signer-connect-target='details']").any?).to be(true)
|
||||
expect(rendered.text).to include("Try again")
|
||||
|
||||
expect(rendered.css("p.text-sm")).to be_empty
|
||||
expect(rendered.css("button.btn-sm")).to be_empty
|
||||
expect(rendered.css("p.text-base").any?).to be(true)
|
||||
expect(rendered.css("button.btn-md").any?).to be(true)
|
||||
end
|
||||
|
||||
it "omits the section heading and its spacing when no title is given" do
|
||||
pending_session = instance_double(
|
||||
NostrSignerSession,
|
||||
bunker?: false,
|
||||
nostrconnect_uri: "nostrconnect://#{SecureRandom.hex(32)}?relay=wss%3A%2F%2Frelay.example.com&secret=abc"
|
||||
)
|
||||
|
||||
rendered = render_inline(
|
||||
described_class.new(
|
||||
pending_session: pending_session,
|
||||
create_url: "/users/nostr_connect",
|
||||
title: nil
|
||||
)
|
||||
)
|
||||
|
||||
expect(rendered.css("h4")).to be_empty
|
||||
expect(rendered.css("section").first["class"]).not_to include("mt-8")
|
||||
expect(rendered.css("div.flex.justify-center").first["class"]).not_to include("mt-4")
|
||||
end
|
||||
|
||||
it "uses normal typography in modal mode" do
|
||||
|
||||
@@ -30,6 +30,16 @@ RSpec.describe "Users::NostrConnects", type: :request do
|
||||
get nostr_connect_path
|
||||
end.not_to have_enqueued_job(NostrConnectListenerJob)
|
||||
end
|
||||
|
||||
it "uses the standard login layout" do
|
||||
get nostr_connect_path
|
||||
|
||||
html = Nokogiri::HTML(response.body)
|
||||
|
||||
expect(html.at_css("h1").text.strip).to eq("Log in")
|
||||
expect(html.at_css("h2").text.strip).to eq("Remote signer")
|
||||
expect(html.css("h4").map { |node| node.text.strip }).not_to include("Remote signer")
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET /users/nostr_connect/status" do
|
||||
|
||||
Reference in new issue
Block a user