From 12f02a079baaf650cffed91b54254d33168b3693 Mon Sep 17 00:00:00 2001 From: Claudio Ortolina Date: Wed, 24 Sep 2025 14:48:16 +0300 Subject: [PATCH] Move search_form to CoreComponents --- .../components/core_components.ex | 21 +++++++++++++++++++ .../components/record_components.ex | 19 ----------------- .../live/scrobbled_tracks_live/index.ex | 1 - priv/gettext/default.pot | 13 +----------- priv/gettext/en/LC_MESSAGES/default.po | 13 +----------- 5 files changed, 23 insertions(+), 44 deletions(-) diff --git a/lib/music_library_web/components/core_components.ex b/lib/music_library_web/components/core_components.ex index edc42320..4022f4b6 100644 --- a/lib/music_library_web/components/core_components.ex +++ b/lib/music_library_web/components/core_components.ex @@ -19,6 +19,8 @@ defmodule MusicLibraryWeb.CoreComponents do alias Phoenix.LiveView.JS + import Fluxon.Components.Input + @doc """ Renders a simple form. @@ -55,6 +57,25 @@ defmodule MusicLibraryWeb.CoreComponents do """ end + attr :query, :string, required: true + + def search_form(assigns) do + ~H""" +
+ <.input + type="search" + size="sm" + id={:query} + name={:query} + value={@query} + placeholder={gettext("Search")} + phx-debounce="500" + autocomplete="off" + /> +
+ """ + end + @doc """ Renders a [Heroicon](https://heroicons.com). diff --git a/lib/music_library_web/components/record_components.ex b/lib/music_library_web/components/record_components.ex index 1d692934..002d620d 100644 --- a/lib/music_library_web/components/record_components.ex +++ b/lib/music_library_web/components/record_components.ex @@ -188,25 +188,6 @@ defmodule MusicLibraryWeb.RecordComponents do """ end - attr :query, :string, required: true - - def search_form(assigns) do - ~H""" -
- <.input - type="search" - size="sm" - id={:query} - name={:query} - value={@query} - placeholder={gettext("Search")} - phx-debounce="500" - autocomplete="off" - /> -
- """ - end - attr :records, :list, required: true attr :records_count, :integer, required: true attr :title, :string, required: true diff --git a/lib/music_library_web/live/scrobbled_tracks_live/index.ex b/lib/music_library_web/live/scrobbled_tracks_live/index.ex index cdcc2db6..2e51bc0f 100644 --- a/lib/music_library_web/live/scrobbled_tracks_live/index.ex +++ b/lib/music_library_web/live/scrobbled_tracks_live/index.ex @@ -2,7 +2,6 @@ defmodule MusicLibraryWeb.ScrobbledTracksLive.Index do use MusicLibraryWeb, :live_view import MusicLibraryWeb.Components.Pagination - import MusicLibraryWeb.RecordComponents, only: [search_form: 1] alias LastFm.Track alias MusicLibrary.ScrobbleActivity diff --git a/priv/gettext/default.pot b/priv/gettext/default.pot index 7fe781da..43dd0c3f 100644 --- a/priv/gettext/default.pot +++ b/priv/gettext/default.pot @@ -181,8 +181,7 @@ msgstr "" msgid "Saving..." msgstr "" -#: lib/music_library_web/components/record_components.ex -#: lib/music_library_web/live/scrobble_live/index.html.heex +#: lib/music_library_web/components/core_components.ex #, elixir-autogen, elixir-format msgid "Search" msgstr "" @@ -1408,11 +1407,6 @@ msgstr "" msgid "Scrobble" msgstr "" -#: lib/music_library_web/live/scrobble_live/index.html.heex -#, elixir-autogen, elixir-format -msgid "Scrobble to Last.fm" -msgstr "" - #: lib/music_library_web/live/scrobble_live/index.ex #, elixir-autogen, elixir-format msgid "Failed to fetch releases for this release group" @@ -1422,8 +1416,3 @@ msgstr "" #, elixir-autogen, elixir-format msgid "Failed to search for release groups" msgstr "" - -#: lib/music_library_web/live/scrobble_live/index.html.heex -#, elixir-autogen, elixir-format -msgid "Searching..." -msgstr "" diff --git a/priv/gettext/en/LC_MESSAGES/default.po b/priv/gettext/en/LC_MESSAGES/default.po index 665beb6d..0e3744c4 100644 --- a/priv/gettext/en/LC_MESSAGES/default.po +++ b/priv/gettext/en/LC_MESSAGES/default.po @@ -181,8 +181,7 @@ msgstr "" msgid "Saving..." msgstr "" -#: lib/music_library_web/components/record_components.ex -#: lib/music_library_web/live/scrobble_live/index.html.heex +#: lib/music_library_web/components/core_components.ex #, elixir-autogen, elixir-format msgid "Search" msgstr "" @@ -1408,11 +1407,6 @@ msgstr "" msgid "Scrobble" msgstr "" -#: lib/music_library_web/live/scrobble_live/index.html.heex -#, elixir-autogen, elixir-format, fuzzy -msgid "Scrobble to Last.fm" -msgstr "" - #: lib/music_library_web/live/scrobble_live/index.ex #, elixir-autogen, elixir-format msgid "Failed to fetch releases for this release group" @@ -1422,8 +1416,3 @@ msgstr "" #, elixir-autogen, elixir-format, fuzzy msgid "Failed to search for release groups" msgstr "" - -#: lib/music_library_web/live/scrobble_live/index.html.heex -#, elixir-autogen, elixir-format, fuzzy -msgid "Searching..." -msgstr ""