Skip to content

Commit 6ff6bb1

Browse files
committed
chore: work through Liveview changes
1 parent 63ee407 commit 6ff6bb1

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

lib/school_house/content/lesson.ex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ defmodule SchoolHouse.Content.Lesson do
5656
Phoenix.View.render_to_string(SchoolHouseWeb.LessonView, "_section_header.html",
5757
fragment: fragment,
5858
header: header,
59-
name: name
59+
name: String.trim(name),
60+
as: :string
6061
)
6162
end)
6263
end

lib/school_house_web.ex

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ defmodule SchoolHouseWeb do
3131
def view do
3232
quote do
3333
use Phoenix.Component
34+
import Phoenix.HTML
35+
import Phoenix.HTML.Form
36+
use PhoenixHTMLHelpers
3437

3538
# Import convenience functions from controllers
3639
import Phoenix.Controller,

lib/school_house_web/views/lesson_view.ex

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
defmodule SchoolHouseWeb.LessonView do
22
use SchoolHouseWeb, :view
3-
import Phoenix.Component, only: [sigil_H: 2]
3+
use Phoenix.Component
44

55
def fa_locale_styles(assigns) do
66
~H"""
@@ -13,4 +13,27 @@ defmodule SchoolHouseWeb.LessonView do
1313
</style>
1414
"""
1515
end
16+
17+
def render("_section_header.html", assigns) do
18+
~H"""
19+
<.section_header name={@name} header={@header} fragment={@fragment} />
20+
"""
21+
end
22+
23+
attr :name, :string, required: true
24+
attr :header, :string, required: true
25+
attr :fragment, :string, required: true
26+
27+
def section_header(assigns) do
28+
~H"""
29+
<div class="group">
30+
<%= content_tag(@header, id: @fragment, class: "group") do %>
31+
<%= @name %>
32+
<a href={"##{@fragment}"} class="ml-2 opacity-0 group-hover:opacity-100 transition-opacity">
33+
<i class="fas fa-link text-sm"></i>
34+
</a>
35+
<% end %>
36+
</div>
37+
"""
38+
end
1639
end

0 commit comments

Comments
 (0)