From 2f9dd73a7b631de1baf71beaa56f067c143e1881 Mon Sep 17 00:00:00 2001 From: Cristine Guadelupe Date: Fri, 11 Feb 2022 09:49:00 -0300 Subject: [PATCH] New bin modal (#997) * New empty bin modal * New bin modal * Smaller buttons * Conditional rendering improvements --- .../live/session_live/bin_component.ex | 172 +++++++++++------- 1 file changed, 110 insertions(+), 62 deletions(-) diff --git a/lib/livebook_web/live/session_live/bin_component.ex b/lib/livebook_web/live/session_live/bin_component.ex index 09a0a2c20..a28be045a 100644 --- a/lib/livebook_web/live/session_live/bin_component.ex +++ b/lib/livebook_web/live/session_live/bin_component.ex @@ -36,78 +36,126 @@ defmodule LivebookWeb.SessionLive.BinComponent do Bin
-

- Here you can find all the deleted cells from this notebook session. -

- <%= if @bin_entries == [] do %> -
-
- <.remix_icon icon="windy-line" class="text-gray-400 text-xl" /> +
+

+ Find all your deleted cells from this notebook session +

+ <%= if @bin_entries != [] do %> +
+ + <.remix_icon icon="search-line" class="align-bottom text-gray-500" /> + + +
+ <% end %> +
+ <%= cond do %> + <%= @bin_entries == [] -> %> +
+
+ <.remix_icon icon="delete-bin-6-line" class="text-gray-700 text-xl bg-gray-100 p-3 rounded-full" /> +
+
+ You haven't deleted any cells or sections yet. Once you do, they'll appear here. +
-
- There are currently no cells in the bin. + <% @matching_entries == [] -> %> +
+
+ <.remix_icon icon="file-search-line" class="text-gray-700 text-xl bg-gray-100 p-3 rounded-full" /> +
+
+ We couldn't find any results for your query. +
-
- <% else %> -
- -
-
- <%= for {%{cell: cell} = entry, index} <- Enum.take(@matching_entries, @limit) |> Enum.with_index(1) do %> -
-
-

- <%= index %>. - <%= Cell.type(cell) |> Atom.to_string() |> String.capitalize() %> cell - deleted from “<%= entry.section_name %>” section - <%= format_date_relatively(entry.deleted_at) %> -

-
- - - - - - + <% true -> %> +
+ <%= for %{cell: cell} = entry <- Enum.take(@matching_entries, @limit) do %> +
+
+
+ <.cell_icon cell_type={Cell.type(cell)}/> +

+ <%= Cell.type(cell) |> Atom.to_string() |> String.capitalize() %> cell + deleted from “<%= entry.section_name %>” section +

+
+
+ + <%= format_date_relatively(entry.deleted_at) %> + +
+
+ <.code_preview + source_id={"bin-cell-#{cell.id}-source"} + language={Cell.type(cell)} + source={cell.source} /> +
+ +
- <.code_preview - source_id={"bin-cell-#{cell.id}-source"} - language={Cell.type(cell)} - source={cell.source} /> -
- <% end %> - <%= if length(@matching_entries) > @limit do %> -
- -
- <% end %> -
+ <% end %> + <%= if length(@matching_entries) > @limit do %> +
+ +
+ <% end %> +
<% end %>
""" end + defp cell_icon(%{cell_type: :elixir} = assigns) do + ~H""" +
+ + + +
+ """ + end + + defp cell_icon(%{cell_type: :markdown} = assigns) do + ~H""" +
+ + + +
+ """ + end + defp format_date_relatively(date) do time_words = date |> DateTime.to_naive() |> Livebook.Utils.Time.time_ago_in_words() time_words <> " ago"