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 %> -