diff --git a/lib/chiya/channels/channel.ex b/lib/chiya/channels/channel.ex index b7147a4..3605616 100644 --- a/lib/chiya/channels/channel.ex +++ b/lib/chiya/channels/channel.ex @@ -8,8 +8,17 @@ defmodule Chiya.Channels.Channel do field :content, :string field :name, :string field :slug, ChannelSlug.Type - field :visibility, Ecto.Enum, values: [:public, :private, :unlisted] - field :layout, Ecto.Enum, values: [:default, :gallery] + field :visibility, Ecto.Enum, values: [ + :public, + :private, + :unlisted + ] + field :layout, Ecto.Enum, values: [ + :default, + :microblog, + :photoblog, + :gallery + ] many_to_many :notes, Chiya.Notes.Note, join_through: "channels_notes", @@ -28,10 +37,10 @@ defmodule Chiya.Channels.Channel do |> validate_exclusion(:slug, ~w(admin user dev)) end - def icon(%Chiya.Channels.Channel{visibility: vis}) do - case(vis) do - :public -> "๐ŸŒ" + def icon(%Chiya.Channels.Channel{visibility: visibility}) do + case(visibility) do :private -> "๐Ÿ”’" + :public -> "๐ŸŒ" :unlisted -> "๐Ÿ‘๏ธ" end end diff --git a/lib/chiya_web/components/core_components.ex b/lib/chiya_web/components/core_components.ex index 0a0400f..a90874e 100644 --- a/lib/chiya_web/components/core_components.ex +++ b/lib/chiya_web/components/core_components.ex @@ -238,6 +238,7 @@ defmodule ChiyaWeb.CoreComponents do """ attr :for, :any, required: true, doc: "the datastructure for the form" attr :as, :any, default: nil, doc: "the server side parameter to collect all input under" + attr :class, :string, default: "shadow rounded mt-10 bg-white dark:bg-gray-900" attr :rest, :global, include: ~w(autocomplete name rel action enctype method novalidate target multipart), @@ -248,8 +249,8 @@ defmodule ChiyaWeb.CoreComponents do def simple_form(assigns) do ~H""" - <.form :let={f} for={@for} as={@as} {@rest}> -
+ <.form :let={f} for={@for} as={@as} {@rest} class={@class}> +
<%= render_slot(@inner_block, f) %>
<%= render_slot(action, f) %> @@ -323,8 +324,7 @@ defmodule ChiyaWeb.CoreComponents do attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs" attr :rest, :global, - include: ~w(autocomplete accept cols disabled form max maxlength min minlength - pattern placeholder readonly required rows size step) + include: ~w(autocomplete accept cols disabled form max maxlength min minlength pattern placeholder readonly required rows size step) slot :inner_block diff --git a/lib/chiya_web/components/public_components.ex b/lib/chiya_web/components/public_components.ex index 542867f..740a58d 100644 --- a/lib/chiya_web/components/public_components.ex +++ b/lib/chiya_web/components/public_components.ex @@ -7,6 +7,8 @@ defmodule ChiyaWeb.PublicComponents do statics: ChiyaWeb.static_paths() import ChiyaWeb.Format + import ChiyaWeb.Markdown, only: [render: 1] + import Phoenix.HTML, only: [raw: 1] @doc """ Renders a horizontal line @@ -90,9 +92,31 @@ defmodule ChiyaWeb.PublicComponents do """ - _ -> + :microblog -> ~H""" -
+
+ <%= for note <- assigns.notes do %> +
+
+ <%= raw render(note.content) %> +
+ + ยท + Permalink +
+ <% end %> +
+ """ + + :photoblog -> + ~H""" + """ + + _ -> # default, show headings only + ~H""" +
<%= for note <- assigns.notes do %> <% end %> + <% else %> + <.line /> + +

No comments yet.

<% end %> <.line /> - <.simple_form :let={f} for={@changeset} action={~p"/#{@note.slug}/comment"}> + <.simple_form :let={f} for={@changeset} action={~p"/#{@note.slug}/comment"} class="bg-theme-background -m-3"> <.error :if={@changeset.action}> Oops, something went wrong! Please check the errors below. - <.input field={f[:author_name]} type="text" placeholder="Name" /> - <.input field={f[:content]} type="textarea" placeholder="Content" rows="3" /> + <.input field={f[:author_name]} type="text" placeholder="Name" class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/40 dark:placeholder-theme-base/60 dark:focus:border-theme-base/60 dark:focus:border-theme-base/60" /> + <.input field={f[:content]} type="textarea" placeholder="Content" rows="3" class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/60 dark:placeholder-theme-base/60 focus:border-theme-base/60 dark:focus:border-theme-base/60" /> <.input field={f[:note_id]} type="hidden" /> <:actions> <.button>Submit Comment