defmodule ChiyaWeb.PublicComponents do use Phoenix.Component use Phoenix.VerifiedRoutes, endpoint: ChiyaWeb.Endpoint, router: ChiyaWeb.Router, statics: ChiyaWeb.static_paths() import ChiyaWeb.Format import ChiyaWeb.Markdown, only: [render: 1] import Phoenix.HTML, only: [raw: 1] import ChiyaWeb.CoreComponents @doc """ Renders a middot as divider """ def dot(assigns), do: ~H""" ยท """ @doc """ Renders a horizontal line """ def line(assigns), do: ~H"""
""" @doc """ Renders a note-header with title. """ attr :class, :string, default: nil attr :inline, :boolean, default: false slot :inner_block, required: true slot :subtitle slot :actions def header(assigns) do ~H"""

<%= render_slot(@inner_block) %> <%= render_slot(@subtitle) %>

<%= render_slot(@subtitle) %>

<%= render_slot(@actions) %>
""" end attr :layout, :atom, default: :list attr :notes, :list, required: true def note_list(assigns) do case assigns.layout do :gallery -> ~H""" """ :microblog -> ~H"""
<%= for note <- assigns.notes do %>
<%= raw(render(note.content)) %>
<% end %>
""" # default, show headings only _ -> ~H"""
<%= for note <- assigns.notes do %> <%= note.name %> <%= pretty_date(note.published_at) %> <% end %>
""" end end defp gallery_name(note), do: "gallery-#{note.id}" end