-
+
- {render_items(assigns, @item_list)}
+ <%= render_items(assigns, @item_list) %>
@@ -70,74 +63,79 @@ defmodule AshHqWeb.Components.Search do
end
defp render_items(assigns, items) do
- ~F"""
+ assigns = assign(assigns, items: items)
+
+ ~H"""
- {/if}
- {/for}
+ <% end %>
+ <% end %>
"""
end
@@ -207,7 +205,8 @@ defmodule AshHqWeb.Components.Search do
def handle_event("select-next", _, socket) do
if socket.assigns[:selected_item] && socket.assigns[:item_list] do
next =
- socket.assigns.item_list
+ socket.assigns[:item_list]
+ |> Kernel.||([])
|> Enum.drop_while(&(&1.id != socket.assigns.selected_item.id))
|> Enum.at(1)
@@ -220,7 +219,8 @@ defmodule AshHqWeb.Components.Search do
def handle_event("select-previous", _, socket) do
if socket.assigns[:selected_item] && socket.assigns[:item_list] do
next =
- socket.assigns.item_list
+ socket.assigns[:item_list]
+ |> Kernel.||([])
|> Enum.reverse()
|> Enum.drop_while(&(&1.id != socket.assigns.selected_item.id))
|> Enum.at(1)
@@ -232,7 +232,7 @@ defmodule AshHqWeb.Components.Search do
end
def handle_event("go-to-doc", _data, socket) do
- case Enum.find(socket.assigns.item_list, fn item ->
+ case Enum.find(socket.assigns[:item_list] || [], fn item ->
item.id == socket.assigns.selected_item.id
end) do
nil ->
@@ -251,7 +251,7 @@ defmodule AshHqWeb.Components.Search do
defp search(socket) do
if socket.assigns.search in [nil, ""] do
- socket
+ assign(socket, :item_list, [])
else
item_list =
socket.assigns.search
diff --git a/lib/ash_hq_web/components/search_bar.ex b/lib/ash_hq_web/components/search_bar.ex
index 1e1412fb..01fedec5 100644
--- a/lib/ash_hq_web/components/search_bar.ex
+++ b/lib/ash_hq_web/components/search_bar.ex
@@ -1,29 +1,28 @@
defmodule AshHqWeb.Components.SearchBar do
@moduledoc "A clickable search bar that brings up the search overlay"
- use Surface.Component
+ use Phoenix.Component
- prop class, :css_class, default: ""
- prop device_brand, :string
+ import AshHqWeb.Tails
- def render(assigns) do
- ~F"""
+ attr :class, :any, default: ""
+ attr :device_brand, :string
+
+ def search_bar(assigns) do
+ ~H"""
"""
diff --git a/lib/ash_hq_web/components/tag.ex b/lib/ash_hq_web/components/tag.ex
deleted file mode 100644
index 623e0d5c..00000000
--- a/lib/ash_hq_web/components/tag.ex
+++ /dev/null
@@ -1,25 +0,0 @@
-defmodule AshHqWeb.Components.Tag do
- @moduledoc "Renders a simple pill style tag"
- use Surface.Component
-
- import AshHqWeb.Tails
-
- prop color, :atom, values: [:red, :blue]
- prop class, :string
- slot default
-
- def render(assigns) do
- ~F"""
-
- <#slot />
-
- """
- end
-end
diff --git a/lib/ash_hq_web/core_components.ex b/lib/ash_hq_web/core_components.ex
new file mode 100644
index 00000000..e69de29b
diff --git a/lib/ash_hq_web/pages/blog.ex b/lib/ash_hq_web/pages/blog.ex
index 3fdf7afe..f88417b3 100644
--- a/lib/ash_hq_web/pages/blog.ex
+++ b/lib/ash_hq_web/pages/blog.ex
@@ -1,51 +1,45 @@
defmodule AshHqWeb.Pages.Blog do
@moduledoc "Blog page"
- use Surface.LiveComponent
+ use Phoenix.LiveComponent
import AshHqWeb.Tails
alias AshHqWeb.Components.Blog.Tag
- prop(params, :map, default: %{})
-
- data(post, :any, default: nil)
- data(posts, :any, default: [])
- data(tag, :string)
- data(tags, :any, default: [])
- data(slug, :string)
+ attr(:params, :map, default: %{})
def render(assigns) do
- ~F"""
+ ~H"""
- {#if @post}
+ <%= if @post do %>
-
+
-
{@post.title}
+
<%= @post.title %>
- {#for tag <- @post.tag_names || []}
-
- {/for}
+ <%= for tag <- @post.tag_names || [] do %>
+
+ <% end %>
- {@post.author}
+ <%= @post.author %>
- {@post.published_at |> DateTime.to_date()}
+ <%= @post.published_at |> DateTime.to_date() %>
- {raw(@post.body_html)}
+ <%= Phoenix.HTML.raw(@post.body_html) %>
- {#else}
+ <% else %>
- {#if @tag}
-
Showing posts with tag: {@tag}
- {#else}
+ <%= if @tag do %>
+
Showing posts with tag: <%= @tag %>
+ <% else %>
Showing all posts
- {/if}
- {#for post <- @posts}
-
-
{post.title}
+ <% end %>
+ <%= for post <- @posts do %>
+
+
<%= post.title %>
- {post.author}
+ <%= post.author %>
- {post.published_at |> DateTime.to_date()}
+ <%= post.published_at |> DateTime.to_date() %>
- {#for tag <- post.tag_names || []}
-
- {/for}
+ <%= for tag <- post.tag_names || [] do %>
+
+ <% end %>
- {/for}
- {/if}
+ <% end %>
+ <% end %>
All Tags:
- {#for tag <- @tags}
-
- {/for}
+ <%= for tag <- @tags do %>
+
+ <% end %>
Connect
-
+
"""
end
-
- def mount(socket) do
- {:ok, socket}
- end
end
diff --git a/lib/ash_hq_web/pages/docs.ex b/lib/ash_hq_web/pages/docs.ex
index 43d7ddd0..3d9a0c9d 100644
--- a/lib/ash_hq_web/pages/docs.ex
+++ b/lib/ash_hq_web/pages/docs.ex
@@ -1,6 +1,6 @@
defmodule AshHqWeb.Pages.Docs do
@moduledoc "The page for showing documentation"
- use Surface.LiveComponent
+ use Phoenix.LiveComponent
import AshHqWeb.Helpers
import AshHqWeb.Tails
@@ -8,31 +8,16 @@ defmodule AshHqWeb.Pages.Docs do
alias AshHqWeb.Components.DocSidebar
alias AshHqWeb.DocRoutes
alias Phoenix.LiveView.JS
- alias Surface.Components.LivePatch
require Logger
require Ash.Query
- prop(change_versions, :event, required: true)
- prop(libraries, :list, default: [])
- prop(uri, :string)
- prop(remove_version, :event)
- prop(add_version, :event)
- prop(change_version, :event)
- prop(params, :map, required: true)
-
- data(library, :any)
- data(docs, :any)
- data(library_version, :any)
- data(guide, :any)
- data(positional_options, :list)
- data(description, :string)
- data(title, :string)
- data(sidebar_data, :any)
- data(not_found, :boolean, default: false)
+ attr(:libraries, :list, default: [])
+ attr(:uri, :string)
+ attr(:params, :map, required: true)
@spec render(any) :: Phoenix.LiveView.Rendered.t()
def render(assigns) do
- ~F"""
+ ~H"""
@@ -40,7 +25,7 @@ defmodule AshHqWeb.Pages.Docs do
@@ -48,9 +33,9 @@ defmodule AshHqWeb.Pages.Docs do