"""
end
defp cell_input(%{cell_view: %{input_type: :password}} = assigns) do
~H"""
<.with_password_toggle id={@cell_view.id}>
"""
end
defp cell_input(assigns) do
~H"""
"""
end
defp html_input_type(:password), do: "password"
defp html_input_type(:number), do: "number"
defp html_input_type(:color), do: "color"
defp html_input_type(:range), do: "range"
defp html_input_type(:select), do: "select"
defp html_input_type(_), do: "text"
defp cell_body(assigns) do
~H"""
<%= render_slot(@inner_block) %>
"""
end
defp cell_link_button(assigns) do
~H"""
<.remix_icon icon="link" class="text-xl" />
"""
end
defp cell_settings_button(assigns) do
~H"""
<%= live_patch to: Routes.session_path(@socket, :cell_settings, @session_id, @cell_id),
class: "icon-button",
aria_label: "cell settings" do %>
<.remix_icon icon="settings-3-line" class="text-xl" />
<% end %>
"""
end
defp move_cell_up_button(assigns) do
~H"""
"""
end
defp move_cell_down_button(assigns) do
~H"""
"""
end
defp delete_cell_button(assigns) do
~H"""
"""
end
defp editor(assigns) do
~H"""
"""
end
# The whole page has to load and then hooks are mounted.
# There may be a tiny delay before the markdown is rendered
# or editors are mounted, so show neat placeholders immediately.
defp content_placeholder(assigns) do
~H"""
<%= if @empty do %>
<% else %>
<% end %>
"""
end
defp cell_status(%{cell_view: %{evaluation_status: :evaluating}} = assigns) do
~H"""
<.status_indicator circle_class="bg-blue-500" animated_circle_class="bg-blue-400" change_indicator={true}>
"""
end
defp cell_status(%{cell_view: %{evaluation_status: :queued}} = assigns) do
~H"""
<.status_indicator circle_class="bg-gray-400" animated_circle_class="bg-gray-300">
Queued
"""
end
defp cell_status(%{cell_view: %{validity_status: :evaluated}} = assigns) do
~H"""
<.status_indicator
circle_class="bg-green-400"
change_indicator={true}
tooltip={evaluated_label(@cell_view.evaluation_time_ms)}>
Evaluated
"""
end
defp cell_status(%{cell_view: %{validity_status: :stale}} = assigns) do
~H"""
<.status_indicator circle_class="bg-yellow-200" change_indicator={true}>
Stale
"""
end
defp cell_status(%{cell_view: %{validity_status: :aborted}} = assigns) do
~H"""
<.status_indicator circle_class="bg-gray-500">
Aborted
"""
end
defp cell_status(assigns), do: ~H""
defp status_indicator(assigns) do
assigns =
assigns
|> assign_new(:animated_circle_class, fn -> nil end)
|> assign_new(:change_indicator, fn -> false end)
|> assign_new(:tooltip, fn -> nil end)
~H"""
<%= render_slot(@inner_block) %>
<%= if @change_indicator do %>
*
<% end %>
<%= if @animated_circle_class do %>
<% end %>
"""
end
defp evaluated_label(time_ms) when is_integer(time_ms) do
evaluation_time =
if time_ms > 100 do
seconds = time_ms |> Kernel./(1000) |> Float.floor(1)
"#{seconds}s"
else
"#{time_ms}ms"
end
"Took " <> evaluation_time
end
defp evaluated_label(_time_ms), do: nil
defp outputs(assigns) do
~H"""
<%= for {output, index} <- @cell_view.outputs |> Enum.reverse() |> Enum.with_index(), output != :ignored do %>