Skip to content

Commit

Permalink
Add rel prop to Link component
Browse files Browse the repository at this point in the history
  • Loading branch information
bartblast committed Jan 26, 2025
1 parent f6be8f8 commit b8989cc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/hologram/ui/link.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ defmodule Hologram.UI.Link do
use Hologram.Component

prop :class, :string, default: nil
prop :rel, :string, default: nil
prop :style, :string, default: nil
prop :to, [:module, :string, :tuple]

Expand All @@ -11,6 +12,7 @@ defmodule Hologram.UI.Link do
<a
href={page_path(@to)}
class={@class}
rel={@rel}
style={@style}
$pointerdown={:__prefetch_page__, to: @to}
$click={:__load_prefetched_page__, to: @to}
Expand Down
5 changes: 5 additions & 0 deletions test/elixir/hologram/ui/link_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ defmodule Hologram.UI.LinkTest do
~s'<a href="/hologram-test-fixtures-ui-link-module1" class="my_class">my anchor text</a>'
end

test "with rel prop" do
assert render_markup(~H'<Link to={Module1} rel="nofollow">my anchor text</Link>') ==
~s'<a href="/hologram-test-fixtures-ui-link-module1" rel="nofollow">my anchor text</a>'
end

test "with style prop" do
assert render_markup(~H'<Link to={Module1} style="my_style">my anchor text</Link>') ==
~s'<a href="/hologram-test-fixtures-ui-link-module1" style="my_style">my anchor text</a>'
Expand Down

0 comments on commit b8989cc

Please sign in to comment.