From df27f03db17bfc11a3f13d4336ae430e34d49d88 Mon Sep 17 00:00:00 2001
From: Inhji
Date: Sun, 7 May 2023 10:30:32 +0200
Subject: [PATCH] add note_list component
---
lib/chiya_web/components/public_components.ex | 64 +++++++++++++++++++
.../controllers/page_html/channel.html.heex | 10 +--
.../controllers/page_html/home.html.heex | 51 +--------------
3 files changed, 66 insertions(+), 59 deletions(-)
diff --git a/lib/chiya_web/components/public_components.ex b/lib/chiya_web/components/public_components.ex
index 4a364b5..d0d3342 100644
--- a/lib/chiya_web/components/public_components.ex
+++ b/lib/chiya_web/components/public_components.ex
@@ -6,6 +6,8 @@ defmodule ChiyaWeb.PublicComponents do
router: ChiyaWeb.Router,
statics: ChiyaWeb.static_paths()
+ import ChiyaWeb.Format
+
@doc """
Renders a horizontal line
"""
@@ -46,4 +48,66 @@ defmodule ChiyaWeb.PublicComponents do
"""
end
+
+ attr :layout, :atom, default: :list
+ attr :notes, :list, required: true
+
+ def note_list(assigns) do
+ case assigns.layout do
+ :gallery ->
+ ~H"""
+
+ """
+
+ _ ->
+ ~H"""
+
+ """
+ end
+ end
+
+ defp gallery_name(note), do: "gallery-#{note.id}"
end
diff --git a/lib/chiya_web/controllers/page_html/channel.html.heex b/lib/chiya_web/controllers/page_html/channel.html.heex
index 668ed3a..48743a0 100644
--- a/lib/chiya_web/controllers/page_html/channel.html.heex
+++ b/lib/chiya_web/controllers/page_html/channel.html.heex
@@ -7,14 +7,6 @@
diff --git a/lib/chiya_web/controllers/page_html/home.html.heex b/lib/chiya_web/controllers/page_html/home.html.heex
index 80a7851..b2b39b5 100644
--- a/lib/chiya_web/controllers/page_html/home.html.heex
+++ b/lib/chiya_web/controllers/page_html/home.html.heex
@@ -23,55 +23,6 @@
<%= if @channel do %>
- <%= if @channel.layout == :default do %>
-
- <% end %>
-
- <%= if @channel.layout == :gallery do %>
-
- <% end %>
+ <.note_list notes={@channel.notes} layout={@channel.layout} />
<% end %>