feat(join): highlight auto-linked join-form links

This commit is contained in:
Simon 2026-06-03 12:16:53 +02:00
parent aced57d0fd
commit ee5ccbf7e9
3 changed files with 9 additions and 7 deletions

View file

@ -63,7 +63,7 @@ defmodule MvWeb.Helpers.JoinDescriptionRenderer do
end end
defp anchor(url, label) do defp anchor(url, label) do
["<a href=\"", escape(url), "\">", escape(label), "</a>"] ["<a href=\"", escape(url), "\" class=\"link link-primary\">", escape(label), "</a>"]
end end
defp escape(text), do: Phoenix.HTML.html_escape(text) |> Phoenix.HTML.safe_to_string() defp escape(text), do: Phoenix.HTML.html_escape(text) |> Phoenix.HTML.safe_to_string()

View file

@ -15,18 +15,18 @@ defmodule MvWeb.Helpers.JoinDescriptionRendererTest do
end end
describe "render/1" do describe "render/1" do
test "converts a raw URL to an anchor tag" do test "converts a raw URL to an anchor tag with the standard link class" do
result = html("Akzeptiere https://example.com/dsgvo") result = html("Akzeptiere https://example.com/dsgvo")
assert result =~ ~s(<a href="https://example.com/dsgvo") assert result =~ ~s(<a href="https://example.com/dsgvo" class="link link-primary")
assert result =~ "https://example.com/dsgvo</a>" assert result =~ "https://example.com/dsgvo</a>"
assert result =~ "Akzeptiere " assert result =~ "Akzeptiere "
end end
test "converts Markdown [text](url) to an anchor tag with the link text" do test "converts Markdown [text](url) to an anchor tag with the standard link class" do
result = html("[Datenschutzerklärung](https://example.com/dsgvo)") result = html("[Datenschutzerklärung](https://example.com/dsgvo)")
assert result =~ ~s(<a href="https://example.com/dsgvo") assert result =~ ~s(<a href="https://example.com/dsgvo" class="link link-primary")
assert result =~ ">Datenschutzerklärung</a>" assert result =~ ">Datenschutzerklärung</a>"
end end
@ -70,7 +70,7 @@ defmodule MvWeb.Helpers.JoinDescriptionRendererTest do
url = "https://example.com/#{path}" url = "https://example.com/#{path}"
result = html("[#{label}](#{url})") result = html("[#{label}](#{url})")
assert result =~ ~s(<a href="#{url}">#{label}</a>) assert result =~ ~s(<a href="#{url}" class="link link-primary">#{label}</a>)
assert result |> :binary.matches("<a ") |> length() == 1 assert result |> :binary.matches("<a ") |> length() == 1
end end
end end

View file

@ -190,7 +190,9 @@ defmodule MvWeb.JoinLiveTest do
{:ok, _view, html} = live(conn, "/join") {:ok, _view, html} = live(conn, "/join")
assert html =~ ~s(<a href="https://example.com/dsgvo">Datenschutzerklärung</a>) assert html =~
~s(<a href="https://example.com/dsgvo" class="link link-primary">Datenschutzerklärung</a>)
assert html =~ "Akzeptiere die" assert html =~ "Akzeptiere die"
end end
end end