move components to Components context

This commit is contained in:
2022-02-11 22:47:33 -05:00
parent 993d583fdd
commit c0b3de75a9
19 changed files with 47 additions and 40 deletions

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.AmmoGroupLive.AmmoGroupCard do
defmodule CanneryWeb.Components.AmmoGroupCard do
@moduledoc """
Display card for an ammo group
"""

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.ContainerLive.ContainerCard do
defmodule CanneryWeb.Components.ContainerCard do
@moduledoc """
Display card for a container
"""

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.ModalComponent do
defmodule CanneryWeb.Components.Modal do
@moduledoc """
Livecomponent that displays a floating modal window
"""

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.TagLive.TagCard do
defmodule CanneryWeb.Components.TagCard do
@moduledoc """
Display card for a tag
"""

View File

@ -1,4 +1,4 @@
defmodule CanneryWeb.Component.Topbar do
defmodule CanneryWeb.Components.Topbar do
@moduledoc """
Component that renders a topbar with user functions/links
"""

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,7 +13,7 @@
</head>
<body class="pb-8 m-0 p-0 w-full h-full">
<header>
<CanneryWeb.Component.Topbar.topbar current_user={assigns[:current_user]}></CanneryWeb.Component.Topbar.topbar>
<.topbar current_user={assigns[:current_user]}></.topbar>
</header>
<div class="pb-8 w-full flex flex-col justify-center items-center text-center">

View File

@ -1,6 +1,6 @@
<main class="mb-8 container min-w-full">
<header>
<CanneryWeb.Component.Topbar.topbar current_user={assigns[:current_user]}></CanneryWeb.Component.Topbar.topbar>
<.topbar current_user={assigns[:current_user]}></.topbar>
<div class="mx-8 my-2 flex flex-col space-y-4 text-center">
<%= if @flash && @flash |> Map.has_key?("info") do %>

View File

@ -1,5 +1,6 @@
defmodule CanneryWeb.ErrorView do
use CanneryWeb, :view
import CanneryWeb.Components.Topbar
alias CanneryWeb.{Endpoint, HomeLive}
def template_not_found(error_path, _assigns) do

View File

@ -1,5 +1,6 @@
defmodule CanneryWeb.LayoutView do
use CanneryWeb, :view
import CanneryWeb.Components.Topbar
alias Cannery.Accounts
alias CanneryWeb.{Endpoint, HomeLive}