split up components into admin and public
This commit is contained in:
parent
0fa4826143
commit
d1f4b70fe8
4 changed files with 51 additions and 4 deletions
|
@ -57,6 +57,9 @@ defmodule ChiyaWeb do
|
||||||
use Phoenix.LiveView,
|
use Phoenix.LiveView,
|
||||||
layout: {ChiyaWeb.Layouts, :app}
|
layout: {ChiyaWeb.Layouts, :app}
|
||||||
|
|
||||||
|
# Import admin components
|
||||||
|
import ChiyaWeb.AdminComponents
|
||||||
|
|
||||||
unquote(html_helpers())
|
unquote(html_helpers())
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -79,6 +82,25 @@ defmodule ChiyaWeb do
|
||||||
|
|
||||||
# Include general helpers for rendering HTML
|
# Include general helpers for rendering HTML
|
||||||
unquote(html_helpers())
|
unquote(html_helpers())
|
||||||
|
|
||||||
|
# Import admin components
|
||||||
|
import ChiyaWeb.AdminComponents
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def html_public do
|
||||||
|
quote do
|
||||||
|
use Phoenix.Component
|
||||||
|
|
||||||
|
# Import convenience functions from controllers
|
||||||
|
import Phoenix.Controller,
|
||||||
|
only: [get_csrf_token: 0, view_module: 1, view_template: 1]
|
||||||
|
|
||||||
|
# Include general helpers for rendering HTML
|
||||||
|
unquote(html_helpers())
|
||||||
|
|
||||||
|
# Import public components
|
||||||
|
import ChiyaWeb.PublicComponents
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -94,7 +116,6 @@ defmodule ChiyaWeb do
|
||||||
alias Phoenix.LiveView.JS
|
alias Phoenix.LiveView.JS
|
||||||
|
|
||||||
# Custom functions
|
# Custom functions
|
||||||
import ChiyaWeb.AdminComponents
|
|
||||||
import ChiyaWeb.Format, only: [from_now: 1, pretty_date: 1]
|
import ChiyaWeb.Format, only: [from_now: 1, pretty_date: 1]
|
||||||
alias ChiyaWeb.Markdown
|
alias ChiyaWeb.Markdown
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
defmodule ChiyaWeb.AdminComponents do
|
defmodule ChiyaWeb.AdminComponents do
|
||||||
|
use Phoenix.Component
|
||||||
|
|
||||||
use Phoenix.Component
|
|
||||||
use Phoenix.VerifiedRoutes,
|
use Phoenix.VerifiedRoutes,
|
||||||
endpoint: ChiyaWeb.Endpoint,
|
endpoint: ChiyaWeb.Endpoint,
|
||||||
router: ChiyaWeb.Router,
|
router: ChiyaWeb.Router,
|
||||||
|
@ -8,6 +8,15 @@ defmodule ChiyaWeb.AdminComponents do
|
||||||
|
|
||||||
import ChiyaWeb.CoreComponents
|
import ChiyaWeb.CoreComponents
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Renders a horizontal line
|
||||||
|
"""
|
||||||
|
def line(assigns) do
|
||||||
|
~H"""
|
||||||
|
<hr class="my-6 dark:border-gray-700" />
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
@doc """
|
@doc """
|
||||||
Renders a UI for uploading files
|
Renders a UI for uploading files
|
||||||
"""
|
"""
|
||||||
|
|
17
lib/chiya_web/components/public_components.ex
Normal file
17
lib/chiya_web/components/public_components.ex
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
defmodule ChiyaWeb.PublicComponents do
|
||||||
|
use Phoenix.Component
|
||||||
|
|
||||||
|
use Phoenix.VerifiedRoutes,
|
||||||
|
endpoint: ChiyaWeb.Endpoint,
|
||||||
|
router: ChiyaWeb.Router,
|
||||||
|
statics: ChiyaWeb.static_paths()
|
||||||
|
|
||||||
|
@doc """
|
||||||
|
Renders a horizontal line
|
||||||
|
"""
|
||||||
|
def line(assigns) do
|
||||||
|
~H"""
|
||||||
|
<hr class="my-6 border-theme-dim" />
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
defmodule ChiyaWeb.PageHTML do
|
defmodule ChiyaWeb.PageHTML do
|
||||||
use ChiyaWeb, :html
|
use ChiyaWeb, :html_public
|
||||||
|
|
||||||
embed_templates "page_html/*"
|
embed_templates "page_html/*"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue