Browse Source

Add a "text" component

theenglishway (time) 2 years ago
parent
commit
a0e61aa93d
4 changed files with 17 additions and 5 deletions
  1. 2 1
      lib/views/basics.ex
  2. 2 2
      lib/views/education.ex
  3. 11 0
      lib/views/text.ex
  4. 2 2
      lib/views/work.ex

+ 2 - 1
lib/views/basics.ex

@@ -1,5 +1,6 @@
 defmodule CvGenView.Basics do
   use Phoenix.Component
+  alias CvGenView.Text
 
   attr(:name, :string, required: true)
   attr(:title, :string, required: true)
@@ -13,7 +14,7 @@ defmodule CvGenView.Basics do
 
   def about(assigns),
     do: ~H"""
-    <p><%= @summary %></p>
+    <Text.text text={@summary}/>
     """
 
   def contact(assigns) do

+ 2 - 2
lib/views/education.ex

@@ -1,6 +1,6 @@
 defmodule CvGenView.Education do
   use Phoenix.Component
-  alias CvGenView.Date
+  alias CvGenView.{Text, Date}
 
   attr(:institution, :string, required: true)
   attr(:location, :string, required: true)
@@ -15,7 +15,7 @@ defmodule CvGenView.Education do
       <div class="box">
         <h1><%= @institution %></h1>
         <h2><%= @area %></h2>
-        <p><%= @summary %></p>
+        <Text.text text={@summary}/>
       </div>
     </div>
     """

+ 11 - 0
lib/views/text.ex

@@ -0,0 +1,11 @@
+defmodule CvGenView.Text do
+  use Phoenix.Component
+
+  attr(:text, :any, required: true)
+  attr(:rest, :global)
+
+  def text(assigns),
+    do: ~H"""
+    <p {@rest}><%= @text %></p>
+    """
+end

+ 2 - 2
lib/views/work.ex

@@ -1,6 +1,6 @@
 defmodule CvGenView.Work do
   use Phoenix.Component
-  alias CvGenView.Date
+  alias CvGenView.{Date, Text}
 
   attr(:name, :string, required: true)
   attr(:start_date, :any, required: true)
@@ -21,7 +21,7 @@ defmodule CvGenView.Work do
 
       <h1><%= @position %></h1>
 
-      <p class="summary" lang="en"><%= @summary %></p>
+      <Text.text text={@summary} class="summary"/>
 
       <h2>Points clés</h2>
       <ul class="highlights">