Skip to content

Commit

Permalink
chore: Update minor deps and phoenix view syntax (#236)
Browse files Browse the repository at this point in the history
  • Loading branch information
esdrasedu authored Dec 11, 2024
1 parent 61dd90c commit 56a731f
Show file tree
Hide file tree
Showing 16 changed files with 1,532 additions and 942 deletions.
56 changes: 28 additions & 28 deletions lib/ash_admin/components/core_components.ex
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ defmodule AshAdmin.CoreComponents do
</button>
</div>
<div id={"#{@id}-content"}>
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</div>
</.focus_wrap>
</div>
Expand Down Expand Up @@ -122,9 +122,9 @@ defmodule AshAdmin.CoreComponents do
<p :if={@title} class="flex items-center gap-1.5 text-sm font-semibold leading-6">
<.icon :if={@kind == :info} name="hero-information-circle-mini" class="h-4 w-4" />
<.icon :if={@kind == :error} name="hero-exclamation-circle-mini" class="h-4 w-4" />
<%= @title %>
{@title}
</p>
<p class="mt-2 text-sm leading-5"><%= msg %></p>
<p class="mt-2 text-sm leading-5">{msg}</p>
<button type="button" class="group absolute top-1 right-1 p-2" aria-label={gettext("close")}>
<.icon name="hero-x-mark-solid" class="h-5 w-5 opacity-40 group-hover:opacity-70" />
</button>
Expand Down Expand Up @@ -197,9 +197,9 @@ defmodule AshAdmin.CoreComponents do
~H"""
<.form :let={f} for={@for} as={@as} {@rest}>
<div class="mt-10 space-y-8 bg-white">
<%= render_slot(@inner_block, f) %>
{render_slot(@inner_block, f)}
<div :for={action <- @actions} class="mt-2 flex items-center justify-between gap-6">
<%= render_slot(action, f) %>
{render_slot(action, f)}
</div>
</div>
</.form>
Expand Down Expand Up @@ -231,7 +231,7 @@ defmodule AshAdmin.CoreComponents do
]}
{@rest}
>
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</button>
"""
end
Expand Down Expand Up @@ -312,36 +312,36 @@ defmodule AshAdmin.CoreComponents do
class="rounded border-zinc-300 text-zinc-900 focus:ring-0"
{@rest}
/>
<%= @label %>
{@label}
</label>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end

def input(%{type: "select"} = assigns) do
~H"""
<div phx-feedback-for={@name}>
<.label for={@id}><%= @label %></.label>
<.label for={@id}>{@label}</.label>
<select
id={@id}
name={@name}
class="mt-2 block w-full rounded-md border border-gray-300 bg-white shadow-sm focus:border-zinc-400 focus:ring-0 sm:text-sm"
multiple={@multiple}
{@rest}
>
<option :if={@prompt} value=""><%= @prompt %></option>
<%= Phoenix.HTML.Form.options_for_select(@options, @value) %>
<option :if={@prompt} value="">{@prompt}</option>
{Phoenix.HTML.Form.options_for_select(@options, @value)}
</select>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end

def input(%{type: "textarea"} = assigns) do
~H"""
<div phx-feedback-for={@name}>
<.label for={@id}><%= @label %></.label>
<.label for={@id}>{@label}</.label>
<textarea
id={@id}
name={@name}
Expand All @@ -353,7 +353,7 @@ defmodule AshAdmin.CoreComponents do
]}
{@rest}
><%= Phoenix.HTML.Form.normalize_value("textarea", @value) %></textarea>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end
Expand All @@ -362,7 +362,7 @@ defmodule AshAdmin.CoreComponents do
def input(assigns) do
~H"""
<div phx-feedback-for={@name}>
<.label for={@id}><%= @label %></.label>
<.label for={@id}>{@label}</.label>
<input
type={@type}
name={@name}
Expand All @@ -376,7 +376,7 @@ defmodule AshAdmin.CoreComponents do
]}
{@rest}
/>
<.error :for={msg <- @errors}><%= msg %></.error>
<.error :for={msg <- @errors}>{msg}</.error>
</div>
"""
end
Expand All @@ -390,7 +390,7 @@ defmodule AshAdmin.CoreComponents do
def label(assigns) do
~H"""
<label for={@for} class="block text-sm font-semibold leading-6 text-zinc-800">
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</label>
"""
end
Expand All @@ -404,7 +404,7 @@ defmodule AshAdmin.CoreComponents do
~H"""
<p class="mt-3 flex gap-3 text-sm leading-6 text-rose-600 phx-no-feedback:hidden">
<.icon name="hero-exclamation-circle-mini" class="mt-0.5 h-5 w-5 flex-none" />
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</p>
"""
end
Expand All @@ -423,13 +423,13 @@ defmodule AshAdmin.CoreComponents do
<header class={[@actions != [] && "flex items-center justify-between gap-6", @class]}>
<div>
<h1 class="text-lg font-semibold leading-8 text-zinc-800">
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</h1>
<p :if={@subtitle != []} class="mt-2 text-sm leading-6 text-zinc-600">
<%= render_slot(@subtitle) %>
{render_slot(@subtitle)}
</p>
</div>
<div class="flex-none"><%= render_slot(@actions) %></div>
<div class="flex-none">{render_slot(@actions)}</div>
</header>
"""
end
Expand Down Expand Up @@ -470,8 +470,8 @@ defmodule AshAdmin.CoreComponents do
<table class="w-[40rem] mt-11 sm:w-full">
<thead class="text-sm text-left leading-6 text-zinc-500">
<tr>
<th :for={col <- @col} class="p-0 pr-6 pb-4 font-normal"><%= col[:label] %></th>
<th class="relative p-0 pb-4"><span class="sr-only"><%= gettext("Actions") %></span></th>
<th :for={col <- @col} class="p-0 pr-6 pb-4 font-normal">{col[:label]}</th>
<th class="relative p-0 pb-4"><span class="sr-only">{gettext("Actions")}</span></th>
</tr>
</thead>
<tbody
Expand All @@ -488,7 +488,7 @@ defmodule AshAdmin.CoreComponents do
<div class="block py-4 pr-6">
<span class="absolute -inset-y-px right-0 -left-4 group-hover:bg-zinc-50 sm:rounded-l-xl" />
<span class={["relative", i == 0 && "font-semibold text-zinc-900"]}>
<%= render_slot(col, @row_item.(row)) %>
{render_slot(col, @row_item.(row))}
</span>
</div>
</td>
Expand All @@ -499,7 +499,7 @@ defmodule AshAdmin.CoreComponents do
:for={action <- @action}
class="relative ml-4 font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
>
<%= render_slot(action, @row_item.(row)) %>
{render_slot(action, @row_item.(row))}
</span>
</div>
</td>
Expand Down Expand Up @@ -529,8 +529,8 @@ defmodule AshAdmin.CoreComponents do
<div class="mt-14">
<dl class="-my-4 divide-y divide-zinc-100">
<div :for={item <- @item} class="flex gap-4 py-4 text-sm leading-6 sm:gap-8">
<dt class="w-1/4 flex-none text-zinc-500"><%= item.title %></dt>
<dd class="text-zinc-700"><%= render_slot(item) %></dd>
<dt class="w-1/4 flex-none text-zinc-500">{item.title}</dt>
<dd class="text-zinc-700">{render_slot(item)}</dd>
</div>
</dl>
</div>
Expand All @@ -555,7 +555,7 @@ defmodule AshAdmin.CoreComponents do
class="text-sm font-semibold leading-6 text-zinc-900 hover:text-zinc-700"
>
<.icon name="hero-arrow-left-solid" class="h-3 w-3" />
<%= render_slot(@inner_block) %>
{render_slot(@inner_block)}
</.link>
</div>
"""
Expand Down
4 changes: 2 additions & 2 deletions lib/ash_admin/components/layouts.ex
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ defmodule AshAdmin.Layouts do
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
<meta name="csrf-token" content={get_csrf_token()} />
<title><%= assigns[:page_title] || "Ash Admin" %></title>
<title>{assigns[:page_title] || "Ash Admin"}</title>
<style nonce={csp_nonce(@conn, :style)}>
<%= raw(render("app.css", %{})) %>
</style>
Expand All @@ -48,7 +48,7 @@ defmodule AshAdmin.Layouts do
</script>
</head>
<body>
<%= @inner_content %>
{@inner_content}
</body>
<script nonce={csp_nonce(@conn, :script)}>
<%= raw(render("app.js", %{})) %>
Expand Down
34 changes: 17 additions & 17 deletions lib/ash_admin/components/resource/data_table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ defmodule AshAdmin.Components.Resource.DataTable do
<ul>
<li :for={{field, message} <- all_errors(form)}>
<span :if={field}>
<%= field %>:
{field}:
</span>
<span>
<%= message %>
{message}
</span>
</li>
</ul>
</div>
<%= AshAdmin.Components.Resource.Form.render_attributes(
{AshAdmin.Components.Resource.Form.render_attributes(
assigns,
@resource,
@action,
form
) %>
)}
<div class="px-4 py-3 text-right sm:px-6">
<button
type="submit"
Expand Down Expand Up @@ -93,13 +93,13 @@ defmodule AshAdmin.Components.Resource.DataTable do
<ul>
<%= for {path, error} <- AshPhoenix.Form.errors(@query, for_path: :all) do %>
<%= for {field, message} <- error do %>
<li><%= Enum.join(path ++ [field], ".") %>: <%= message %></li>
<li>{Enum.join(path ++ [field], ".")}: {message}</li>
<% end %>
<% end %>
</ul>
</div>
<div class="px-2">
<%= render_pagination_links(assigns, :top) %>
{render_pagination_links(assigns, :top)}
<div :if={@thousand_records_warning && !@action.get? && match?({:ok, _}, @data)}>
Only showing up to 1000 rows. To show more, enable
Expand All @@ -118,7 +118,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
prefix={@prefix}
actor={@actor}
/>
<%= render_pagination_links(assigns, :bottom) %>
{render_pagination_links(assigns, :bottom)}
</div>
</div>
</div>
Expand Down Expand Up @@ -433,7 +433,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
>
Previous
</button>
<%= render_pagination_information(assigns, true) %>
{render_pagination_information(assigns, true)}
<button
:if={next_page?(@data)}
phx-click="next_page"
Expand All @@ -445,7 +445,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
</div>
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
<div>
<%= render_pagination_information(assigns) %>
{render_pagination_information(assigns)}
</div>
<div>
<nav
Expand Down Expand Up @@ -475,9 +475,9 @@ defmodule AshAdmin.Components.Resource.DataTable do
</svg>
</button>
<span :if={offset?(@data)}>
<%= render_page_links(assigns, leading_page_nums(@data)) %>
<%= render_middle_page_num(assigns, @page_num, trailing_page_nums(@data)) %>
<%= render_page_links(assigns, trailing_page_nums(@data)) %>
{render_page_links(assigns, leading_page_nums(@data))}
{render_middle_page_num(assigns, @page_num, trailing_page_nums(@data))}
{render_page_links(assigns, trailing_page_nums(@data))}
</span>
<button
:if={next_page?(@data)}
Expand Down Expand Up @@ -525,7 +525,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
])
}
>
<%= i %>
{i}
</button>
"""
end
Expand All @@ -536,14 +536,14 @@ defmodule AshAdmin.Components.Resource.DataTable do
~H"""
<p class={classes(["text-sm text-gray-700", "sm:hidden": @small])}>
<span :if={offset?(@data)}>
Showing <span class="font-medium"><%= first(@data) %></span>
to <span class="font-medium"><%= last(@data) %></span>
Showing <span class="font-medium">{first(@data)}</span>
to <span class="font-medium">{last(@data)}</span>
<%= if count(@data) do %>
of
<% end %>
</span>
<span :if={count(@data)}>
<span class="font-medium"><%= count(@data) %></span> results
<span class="font-medium">{count(@data)}</span> results
</span>
</p>
"""
Expand Down Expand Up @@ -598,7 +598,7 @@ defmodule AshAdmin.Components.Resource.DataTable do
...
</span>
<span :if={!@ellipsis}>
<%= @num %>
{@num}
</span>
</span>
"""
Expand Down
Loading

0 comments on commit 56a731f

Please sign in to comment.