[Housekeeping] Dependency updates 6-Jun-2025 (#733)
* Bumped Elixir * Silenced mix check warnings * Updated all deps with minor version upgrades * Updated more deps; Refactored text components to work with phoenix_html updates
This commit is contained in:
@@ -43,7 +43,7 @@ defmodule PinchflatWeb do
|
||||
layouts: [html: PinchflatWeb.Layouts]
|
||||
|
||||
import Plug.Conn
|
||||
import PinchflatWeb.Gettext
|
||||
use Gettext, backend: PinchflatWeb.Gettext
|
||||
|
||||
alias Pinchflat.Settings
|
||||
alias PinchflatWeb.Layouts
|
||||
@@ -94,7 +94,7 @@ defmodule PinchflatWeb do
|
||||
# HTML escaping functionality
|
||||
import Phoenix.HTML
|
||||
# Core UI components and translation
|
||||
import PinchflatWeb.Gettext
|
||||
use Gettext, backend: PinchflatWeb.Gettext
|
||||
import PinchflatWeb.CoreComponents
|
||||
import PinchflatWeb.CustomComponents.TabComponents
|
||||
import PinchflatWeb.CustomComponents.TextComponents
|
||||
|
||||
@@ -15,8 +15,7 @@ defmodule PinchflatWeb.CoreComponents do
|
||||
Icons are provided by [heroicons](https://heroicons.com). See `icon/1` for usage.
|
||||
"""
|
||||
use Phoenix.Component, global_prefixes: ~w(x-)
|
||||
|
||||
import PinchflatWeb.Gettext
|
||||
use Gettext, backend: PinchflatWeb.Gettext
|
||||
|
||||
alias Phoenix.LiveView.JS
|
||||
alias PinchflatWeb.CustomComponents.TextComponents
|
||||
|
||||
@@ -71,19 +71,39 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
|
||||
formatted_text =
|
||||
Regex.split(~r{https?://\S+}, assigns.text, include_captures: true)
|
||||
|> Enum.map(fn
|
||||
"http" <> _ = url ->
|
||||
Phoenix.HTML.Tag.content_tag(:a, url, class: "text-blue-500 hover:text-blue-300", href: url, target: "_blank")
|
||||
|
||||
text ->
|
||||
text
|
||||
|> String.split("\n", trim: false)
|
||||
|> Enum.intersperse(Phoenix.HTML.Tag.tag(:span, class: "inline-block mt-2"))
|
||||
"http" <> _ = url -> {:url, url}
|
||||
text -> Regex.split(~r{\n}, text, include_captures: true, trim: true)
|
||||
end)
|
||||
|
||||
assigns = Map.put(assigns, :text, formatted_text)
|
||||
|
||||
~H"""
|
||||
<span>{@text}</span>
|
||||
<span>
|
||||
<.rendered_description_line :for={line <- @text} content={line} />
|
||||
</span>
|
||||
"""
|
||||
end
|
||||
|
||||
defp rendered_description_line(%{content: {:url, url}} = assigns) do
|
||||
assigns = Map.put(assigns, :url, url)
|
||||
|
||||
~H"""
|
||||
<a href={@url} target="_blank" class="text-blue-500 hover:text-blue-300">
|
||||
{@url}
|
||||
</a>
|
||||
"""
|
||||
end
|
||||
|
||||
defp rendered_description_line(%{content: list_of_content} = assigns) do
|
||||
assigns = Map.put(assigns, :list_of_content, list_of_content)
|
||||
|
||||
~H"""
|
||||
<span
|
||||
:for={inner_content <- @list_of_content}
|
||||
class={[if(inner_content == "\n", do: "block", else: "mt-2 inline-block")]}
|
||||
>
|
||||
{inner_content}
|
||||
</span>
|
||||
"""
|
||||
end
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ defmodule PinchflatWeb.Gettext do
|
||||
By using [Gettext](https://hexdocs.pm/gettext),
|
||||
your module gains a set of macros for translations, for example:
|
||||
|
||||
import PinchflatWeb.Gettext
|
||||
use Gettext, backend: PinchflatWeb.Gettext
|
||||
|
||||
# Simple translation
|
||||
gettext("Here is the string to translate")
|
||||
@@ -20,5 +20,5 @@ defmodule PinchflatWeb.Gettext do
|
||||
|
||||
See the [Gettext Docs](https://hexdocs.pm/gettext) for detailed usage.
|
||||
"""
|
||||
use Gettext, otp_app: :pinchflat
|
||||
use Gettext.Backend, otp_app: :pinchflat
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user