basics.ex 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. defmodule CvGenView.Basics do
  2. use Phoenix.Component
  3. attr(:name, :string, required: true)
  4. attr(:title, :string, required: true)
  5. def basics(assigns) do
  6. ~H"""
  7. <h1><%= @name %></h1>
  8. <h2><%= @title %></h2>
  9. """
  10. end
  11. def about(assigns),
  12. do: ~H"""
  13. <p><%= @summary %></p>
  14. """
  15. def contact(assigns) do
  16. supported_profiles = [:linked_in] |> Map.new(&{&1, nil})
  17. flat_profiles =
  18. assigns.profiles |> Map.new(&{&1.network |> Macro.underscore() |> String.to_atom(), &1.url})
  19. assigns = assigns |> Map.merge(supported_profiles) |> Map.merge(flat_profiles)
  20. ~H"""
  21. <dl>
  22. <dt class="location">📍</dt>
  23. <dd class="location"><%= @location.city %></dd>
  24. <dt class="mail">📧</dt>
  25. <dd class="mail"><a href={"mailto: #{@email}"}><%= @email %></a></dd>
  26. <%= if @linked_in do %>
  27. <dt class="linked_in">LinkedIn</dt>
  28. <dd class="linked_in"><a href={@linked_in}><%= @linked_in %></a></dd>
  29. <% end %>
  30. </dl>
  31. """
  32. def css(),
  33. do: """
  34. #basics {
  35. display: grid;
  36. justify-items: center;
  37. }
  38. #basics > h1 {
  39. text-transform: uppercase;
  40. font-weight: 700;
  41. font-size: 2em;
  42. }
  43. #basics > h2 {
  44. text-transform: uppercase;
  45. color: #334960;
  46. opacity: 0.7;
  47. text-align: center;
  48. max-width: 30ch;
  49. }
  50. #contact dl {
  51. column-gap: 1em;
  52. }
  53. #contact .mail a {
  54. font-weight: bold;
  55. }
  56. """
  57. end