move components to Components context

This commit is contained in:
shibao 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}

View File

@ -11,7 +11,7 @@ msgid ""
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:96
#: lib/cannery_web/components/topbar.ex:96
#: lib/cannery_web/templates/layout/topbar.html.heex:36
#: lib/cannery_web/templates/user_confirmation/new.html.heex:26
#: lib/cannery_web/templates/user_registration/new.html.heex:39
@ -23,7 +23,7 @@ msgid "Log in"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:89
#: lib/cannery_web/components/topbar.ex:89
#: lib/cannery_web/templates/layout/topbar.html.heex:28
#: lib/cannery_web/templates/user_confirmation/new.html.heex:21
#: lib/cannery_web/templates/user_registration/new.html.heex:3

View File

@ -76,27 +76,27 @@ msgid "Self-host your own instance, or use an instance from someone you trust."
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:47
#: lib/cannery_web/components/topbar.ex:47
msgid "Ammo"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:41
#: lib/cannery_web/components/topbar.ex:41
msgid "Containers"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:60
#: lib/cannery_web/components/topbar.ex:60
msgid "Invites"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:53
#: lib/cannery_web/components/topbar.ex:53
msgid "Manage"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:35
#: lib/cannery_web/components/topbar.ex:35
msgid "Tags"
msgstr ""
@ -117,7 +117,7 @@ msgid "Count"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:28
#: lib/cannery_web/components/ammo_group_card.ex:28
#: lib/cannery_web/live/ammo_group_live/show.html.heex:8
msgid "Count:"
msgstr ""
@ -150,7 +150,7 @@ msgid "Notes"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:34
#: lib/cannery_web/components/ammo_group_card.ex:34
#: lib/cannery_web/live/ammo_group_live/show.html.heex:14
msgid "Notes:"
msgstr ""
@ -162,7 +162,7 @@ msgid "Price paid"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_group_live/ammo_group_card.ex:41
#: lib/cannery_web/components/ammo_group_card.ex:41
#: lib/cannery_web/live/ammo_group_live/show.html.heex:21
msgid "Price paid:"
msgstr ""
@ -371,7 +371,7 @@ msgid "Tracer"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/container_card.ex:26
#: lib/cannery_web/components/container_card.ex:26
#: lib/cannery_web/live/container_live/show.html.heex:8
msgid "Description:"
msgstr ""
@ -394,7 +394,7 @@ msgid "Location"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/container_card.ex:38
#: lib/cannery_web/components/container_card.ex:38
#: lib/cannery_web/live/container_live/show.html.heex:20
msgid "Location:"
msgstr ""
@ -445,7 +445,7 @@ msgid "Type"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/container_live/container_card.ex:32
#: lib/cannery_web/components/container_card.ex:32
#: lib/cannery_web/live/container_live/show.html.heex:14
msgid "Type:"
msgstr ""
@ -461,7 +461,7 @@ msgid "Disable"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:23
#: lib/cannery_web/live/invite_live/index.ex:35
msgid "Edit Invite"
msgstr ""
@ -481,7 +481,7 @@ msgid "Invite Disabled"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:31
#: lib/cannery_web/live/invite_live/index.ex:43
#: lib/cannery_web/live/invite_live/index.html.leex:3
msgid "Listing Invites"
msgstr ""
@ -493,7 +493,7 @@ msgid "Listing Tags"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:27
#: lib/cannery_web/live/invite_live/index.ex:39
msgid "New Invite"
msgstr ""

View File

@ -119,17 +119,17 @@ msgid "Error"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/views/error_view.ex:10
#: lib/cannery_web/views/error_view.ex:11
msgid "Internal Server Error"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/views/error_view.ex:8
#: lib/cannery_web/views/error_view.ex:9
msgid "Not found"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/views/error_view.ex:9
#: lib/cannery_web/views/error_view.ex:10
msgid "Unauthorized"
msgstr ""
@ -208,3 +208,8 @@ msgstr ""
#: lib/cannery_web/live/container_live/show.ex:52
msgid "Could not delete %{name}: %{error}"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:20
msgid "You are not authorized to view this page"
msgstr ""

View File

@ -16,7 +16,7 @@ msgid "Register to setup %{name}"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/component/topbar.ex:75
#: lib/cannery_web/components/topbar.ex:75
#: lib/cannery_web/templates/layout/topbar.html.heex:21
msgid "Are you sure you want to log out?"
msgstr ""
@ -103,10 +103,10 @@ msgid "Saving..."
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/components/tag_card.ex:33
#: lib/cannery_web/live/ammo_type_live/show.html.heex:26
#: lib/cannery_web/live/container_live/index.html.heex:36
#: lib/cannery_web/live/container_live/show.html.heex:36
#: lib/cannery_web/live/tag_live/tag_card.ex:33
msgid "Are you sure you want to delete %{name}?"
msgstr ""
@ -132,7 +132,7 @@ msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/ammo_type_live/index.ex:41
#: lib/cannery_web/live/ammo_type_live/show.ex:39
#: lib/cannery_web/live/invite_live/index.ex:39
#: lib/cannery_web/live/invite_live/index.ex:51
#: lib/cannery_web/live/tag_live/index.ex:41
msgid "%{name} deleted succesfully"
msgstr ""
@ -152,16 +152,16 @@ msgid "Ammo group deleted succesfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:87
#: lib/cannery_web/live/invite_live/index.ex:99
msgid "%{name} disabled succesfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:69
#: lib/cannery_web/live/invite_live/index.ex:81
msgid "%{name} enabled succesfully"
msgstr ""
#, elixir-format, ex-autogen
#: lib/cannery_web/live/invite_live/index.ex:53
#: lib/cannery_web/live/invite_live/index.ex:65
msgid "%{name} updated succesfully"
msgstr ""