From 6f78ec40d731c8557ed33048af94d65e87404298 Mon Sep 17 00:00:00 2001 From: Kieran Date: Wed, 17 Apr 2024 11:31:50 -0700 Subject: [PATCH] [Enhancement] Improve layout of media item page on large displays (#192) * Improved layout of media items page * Removed useless anchor tag --- .../components/core_components.ex | 7 +++--- .../custom_components/text_components.ex | 21 +++++++++++++++- .../media_item_html/media_preview.heex | 4 ++-- .../media_item_html/show.html.heex | 24 +++++++++++++------ .../media_profile_html/show.html.heex | 4 ++-- .../pages/page_html/home.html.heex | 4 ++-- .../sources/source_html/show.html.heex | 4 ++-- 7 files changed, 49 insertions(+), 19 deletions(-) diff --git a/lib/pinchflat_web/components/core_components.ex b/lib/pinchflat_web/components/core_components.ex index 654b743..ccdf0b9 100644 --- a/lib/pinchflat_web/components/core_components.ex +++ b/lib/pinchflat_web/components/core_components.ex @@ -19,7 +19,6 @@ defmodule PinchflatWeb.CoreComponents do import PinchflatWeb.Gettext alias Phoenix.LiveView.JS - alias PinchflatWeb.CustomComponents.TextComponents @doc """ Renders a modal. @@ -638,9 +637,11 @@ defmodule PinchflatWeb.CoreComponents do ~H""" """ diff --git a/lib/pinchflat_web/components/custom_components/text_components.ex b/lib/pinchflat_web/components/custom_components/text_components.ex index 1433bd3..1a577f5 100644 --- a/lib/pinchflat_web/components/custom_components/text_components.ex +++ b/lib/pinchflat_web/components/custom_components/text_components.ex @@ -35,11 +35,12 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do Renders a subtle link with the given href and content. """ attr :href, :string, required: true + attr :target, :string, default: "_self" slot :inner_block def subtle_link(assigns) do ~H""" - <.link href={@href} class="underline decoration-bodydark decoration-1 hover:decoration-white"> + <.link href={@href} target={@target} class="underline decoration-bodydark decoration-1 hover:decoration-white"> <%= render_slot(@inner_block) %> """ @@ -59,4 +60,22 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do """ end + + @doc """ + Renders a block of text with each line broken into a separate span. + """ + attr :text, :string, required: true + + def break_on_newline(assigns) do + broken_text = + assigns.text + |> String.split("\n", trim: false) + |> Enum.intersperse(Phoenix.HTML.Tag.tag(:span, class: "inline-block mt-2")) + + assigns = Map.put(assigns, :text, broken_text) + + ~H""" + <%= @text %> + """ + end end diff --git a/lib/pinchflat_web/controllers/media_items/media_item_html/media_preview.heex b/lib/pinchflat_web/controllers/media_items/media_item_html/media_preview.heex index 2146a98..5ad0533 100644 --- a/lib/pinchflat_web/controllers/media_items/media_item_html/media_preview.heex +++ b/lib/pinchflat_web/controllers/media_items/media_item_html/media_preview.heex @@ -1,12 +1,12 @@ <%= if media_type(@media_item) == :video do %> -