File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -56,7 +56,8 @@ defmodule SchoolHouse.Content.Lesson do
56
56
Phoenix.View . render_to_string ( SchoolHouseWeb.LessonView , "_section_header.html" ,
57
57
fragment: fragment ,
58
58
header: header ,
59
- name: name
59
+ name: String . trim ( name ) ,
60
+ as: :string
60
61
)
61
62
end )
62
63
end
Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ defmodule SchoolHouseWeb do
31
31
def view do
32
32
quote do
33
33
use Phoenix.Component
34
+ import Phoenix.HTML
35
+ import Phoenix.HTML.Form
36
+ use PhoenixHTMLHelpers
34
37
35
38
# Import convenience functions from controllers
36
39
import Phoenix.Controller ,
Original file line number Diff line number Diff line change 1
1
defmodule SchoolHouseWeb.LessonView do
2
2
use SchoolHouseWeb , :view
3
- import Phoenix.Component , only: [ sigil_H: 2 ]
3
+ use Phoenix.Component
4
4
5
5
def fa_locale_styles ( assigns ) do
6
6
~H"""
@@ -13,4 +13,27 @@ defmodule SchoolHouseWeb.LessonView do
13
13
</ style >
14
14
"""
15
15
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
16
39
end
You can’t perform that action at this time.
0 commit comments