From e9d365ee9ec1ac81da57734ae7e3ebc8bd3362e7 Mon Sep 17 00:00:00 2001 From: Robert Kleinschuster Date: Fri, 13 Dec 2024 21:23:12 +0100 Subject: [PATCH] use css truncate everywhere and remove StringUtils.truncate function (#513) Co-authored-by: robs --- lib/pinchflat/utils/string_utils.ex | 17 ----------------- .../custom_components/button_components.ex | 2 +- .../custom_components/table_components.ex | 4 ++-- .../media_items/media_item_html/edit.html.heex | 4 ++-- .../media_items/media_item_html/show.html.heex | 6 +++--- .../media_profile_html/edit.html.heex | 2 +- .../media_profile_html/index.html.heex | 2 +- .../media_profile_html/show.html.heex | 4 ++-- .../searches/search_html/show.html.heex | 4 ++-- .../sources/source_html/edit.html.heex | 2 +- .../sources/source_html/show.html.heex | 4 ++-- .../source_live/index_table_live.html.heex | 2 +- test/pinchflat/utils/string_utils_test.exs | 14 -------------- .../controllers/pages/job_table_live_test.exs | 4 ++-- 14 files changed, 20 insertions(+), 51 deletions(-) diff --git a/lib/pinchflat/utils/string_utils.ex b/lib/pinchflat/utils/string_utils.ex index bee23b50..49328b2c 100644 --- a/lib/pinchflat/utils/string_utils.ex +++ b/lib/pinchflat/utils/string_utils.ex @@ -25,23 +25,6 @@ defmodule Pinchflat.Utils.StringUtils do |> String.slice(0..(length - 1)) end - @doc """ - Truncates a string to the given length and adds `...` if the string is longer than the given length. - Will break on a word boundary. Nothing happens if the string is shorter than the given length. - - Returns binary() - """ - def truncate(string, length) do - if String.length(string) > length do - string - |> String.slice(0..(length - 1)) - |> String.replace(~r/\s+\S*$/, "") - |> Kernel.<>("...") - else - string - end - end - @doc """ Wraps a string in double braces. Useful as a UI helper now that LiveView 1.0.0 allows `{}` for interpolation so now we can't use braces diff --git a/lib/pinchflat_web/components/custom_components/button_components.ex b/lib/pinchflat_web/components/custom_components/button_components.ex index 9942ebcb..f1f3470c 100644 --- a/lib/pinchflat_web/components/custom_components/button_components.ex +++ b/lib/pinchflat_web/components/custom_components/button_components.ex @@ -26,7 +26,7 @@ defmodule PinchflatWeb.CustomComponents.ButtonComponents do ~H"""