diff --git a/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex b/lib/cannery_web/components/ammo_group_card.ex similarity index 96% rename from lib/cannery_web/live/ammo_group_live/ammo_group_card.ex rename to lib/cannery_web/components/ammo_group_card.ex index d3aeaee3..be5fa696 100644 --- a/lib/cannery_web/live/ammo_group_live/ammo_group_card.ex +++ b/lib/cannery_web/components/ammo_group_card.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.AmmoGroupLive.AmmoGroupCard do +defmodule CanneryWeb.Components.AmmoGroupCard do @moduledoc """ Display card for an ammo group """ diff --git a/lib/cannery_web/live/container_live/container_card.ex b/lib/cannery_web/components/container_card.ex similarity index 96% rename from lib/cannery_web/live/container_live/container_card.ex rename to lib/cannery_web/components/container_card.ex index d8cacf0b..2d1742f1 100644 --- a/lib/cannery_web/live/container_live/container_card.ex +++ b/lib/cannery_web/components/container_card.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.ContainerLive.ContainerCard do +defmodule CanneryWeb.Components.ContainerCard do @moduledoc """ Display card for a container """ diff --git a/lib/cannery_web/live/modal_component.ex b/lib/cannery_web/components/modal.ex similarity index 96% rename from lib/cannery_web/live/modal_component.ex rename to lib/cannery_web/components/modal.ex index 0c70ae7a..28209979 100644 --- a/lib/cannery_web/live/modal_component.ex +++ b/lib/cannery_web/components/modal.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.ModalComponent do +defmodule CanneryWeb.Components.Modal do @moduledoc """ Livecomponent that displays a floating modal window """ diff --git a/lib/cannery_web/live/tag_live/tag_card.ex b/lib/cannery_web/components/tag_card.ex similarity index 96% rename from lib/cannery_web/live/tag_live/tag_card.ex rename to lib/cannery_web/components/tag_card.ex index e5b2b3ff..d3d4a2c0 100644 --- a/lib/cannery_web/live/tag_live/tag_card.ex +++ b/lib/cannery_web/components/tag_card.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.TagLive.TagCard do +defmodule CanneryWeb.Components.TagCard do @moduledoc """ Display card for a tag """ diff --git a/lib/cannery_web/component/topbar.ex b/lib/cannery_web/components/topbar.ex similarity index 98% rename from lib/cannery_web/component/topbar.ex rename to lib/cannery_web/components/topbar.ex index 22d1aba2..452ee208 100644 --- a/lib/cannery_web/component/topbar.ex +++ b/lib/cannery_web/components/topbar.ex @@ -1,4 +1,4 @@ -defmodule CanneryWeb.Component.Topbar do +defmodule CanneryWeb.Components.Topbar do @moduledoc """ Component that renders a topbar with user functions/links """ diff --git a/lib/cannery_web/live/ammo_group_live/show.ex b/lib/cannery_web/live/ammo_group_live/show.ex index c217058d..b93de877 100644 --- a/lib/cannery_web/live/ammo_group_live/show.ex +++ b/lib/cannery_web/live/ammo_group_live/show.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.AmmoGroupLive.Show do """ use CanneryWeb, :live_view - import CanneryWeb.ContainerLive.ContainerCard + import CanneryWeb.Components.ContainerCard alias Cannery.{Ammo, Repo} @impl true diff --git a/lib/cannery_web/live/ammo_type_live/show.ex b/lib/cannery_web/live/ammo_type_live/show.ex index fbf10b3c..59cad6e3 100644 --- a/lib/cannery_web/live/ammo_type_live/show.ex +++ b/lib/cannery_web/live/ammo_type_live/show.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.AmmoTypeLive.Show do """ use CanneryWeb, :live_view - import CanneryWeb.AmmoGroupLive.AmmoGroupCard + import CanneryWeb.Components.AmmoGroupCard alias Cannery.Ammo @impl true diff --git a/lib/cannery_web/live/container_live/index.ex b/lib/cannery_web/live/container_live/index.ex index 59aa4206..485739ef 100644 --- a/lib/cannery_web/live/container_live/index.ex +++ b/lib/cannery_web/live/container_live/index.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.ContainerLive.Index do """ use CanneryWeb, :live_view - import CanneryWeb.ContainerLive.ContainerCard + import CanneryWeb.Components.ContainerCard alias Cannery.{Containers, Containers.Container} alias Ecto.Changeset diff --git a/lib/cannery_web/live/container_live/show.ex b/lib/cannery_web/live/container_live/show.ex index 91cbe7c9..66f74148 100644 --- a/lib/cannery_web/live/container_live/show.ex +++ b/lib/cannery_web/live/container_live/show.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.ContainerLive.Show do """ use CanneryWeb, :live_view - import CanneryWeb.AmmoGroupLive.AmmoGroupCard + import CanneryWeb.Components.AmmoGroupCard alias Cannery.{Containers, Repo} alias Ecto.Changeset diff --git a/lib/cannery_web/live/live_helpers.ex b/lib/cannery_web/live/live_helpers.ex index a390c8be..69e80a34 100644 --- a/lib/cannery_web/live/live_helpers.ex +++ b/lib/cannery_web/live/live_helpers.ex @@ -6,9 +6,10 @@ defmodule CanneryWeb.LiveHelpers do import Phoenix.LiveView.Helpers import Phoenix.LiveView, only: [assign_new: 3] alias Cannery.Accounts + alias CanneryWeb.Components.Modal @doc """ - Renders a component inside the `CanneryWeb.ModalComponent` component. + Renders a component inside the `Modal` component. The rendered modal receives a `:return_to` option to properly update the URL when the modal is closed. @@ -23,8 +24,7 @@ defmodule CanneryWeb.LiveHelpers do """ def live_modal(component, opts) do path = Keyword.fetch!(opts, :return_to) - modal_opts = [id: :modal, return_to: path, component: component, opts: opts] - live_component(CanneryWeb.ModalComponent, modal_opts) + live_component(Modal, id: :modal, return_to: path, component: component, opts: opts) end def assign_defaults(socket, %{"user_token" => user_token} = _session) do diff --git a/lib/cannery_web/live/tag_live/index.ex b/lib/cannery_web/live/tag_live/index.ex index 4e2bac4c..5f0ce2ef 100644 --- a/lib/cannery_web/live/tag_live/index.ex +++ b/lib/cannery_web/live/tag_live/index.ex @@ -4,7 +4,7 @@ defmodule CanneryWeb.TagLive.Index do """ use CanneryWeb, :live_view - import CanneryWeb.TagLive.TagCard + import CanneryWeb.Components.TagCard alias Cannery.Tags alias Cannery.Tags.Tag diff --git a/lib/cannery_web/templates/error/error.html.heex b/lib/cannery_web/templates/error/error.html.heex index cc396286..a34b410b 100644 --- a/lib/cannery_web/templates/error/error.html.heex +++ b/lib/cannery_web/templates/error/error.html.heex @@ -13,7 +13,7 @@