diff --git a/assets/css/tooltips.css b/assets/css/tooltips.css index de4ee162d..82ffcc493 100644 --- a/assets/css/tooltips.css +++ b/assets/css/tooltips.css @@ -23,7 +23,7 @@ Example usage: } .tooltip.distant-medium { - --distance: 10px; + --distance: 14px; } /* Tooltip text */ diff --git a/assets/css/utilities.css b/assets/css/utilities.css index 468db5b9a..0415b7842 100644 --- a/assets/css/utilities.css +++ b/assets/css/utilities.css @@ -5,14 +5,34 @@ background-color: #282c34; } - body[data-editor-theme="light"] .bg-editor { - background-color: #fafafa; + .bg-editor-lighter { + background-color: #2f343e; + } + + .border-editor { + border-color: #363c46; } .text-editor { color: #c4cad6; } + body[data-editor-theme="light"] .bg-editor { + background-color: #fafafa; + } + + body[data-editor-theme="light"] .bg-editor-lighter { + background-color: #ebebec; + } + + body[data-editor-theme="light"] .border-editor { + border-color: #dfdfe0; + } + + body[data-editor-theme="light"] .text-editor { + color: #383a41; + } + .font-editor { font-family: "JetBrains Mono", "Droid Sans Mono", "monospace"; font-variant-ligatures: none; diff --git a/assets/js/hooks/cell_editor/live_editor/codemirror/theme.js b/assets/js/hooks/cell_editor/live_editor/codemirror/theme.js index 2354113be..db43c5b83 100644 --- a/assets/js/hooks/cell_editor/live_editor/codemirror/theme.js +++ b/assets/js/hooks/cell_editor/live_editor/codemirror/theme.js @@ -21,6 +21,12 @@ function buildEditorTheme(colors, { dark }) { borderRadius: "8px", fontSize: "14px", fontFamily: fonts.mono, + + // A workaround for a strange contenteditable behaviour in + // Chrome and Safari, where clicking on the right side of the + // editor results in focus. See https://discuss.codemirror.net/t/editor-focus-happens-when-clicking-outside-the-editor/7544/3 + display: "inline-flex !important", + width: "100%", }, "&.cm-focused": { diff --git a/lib/livebook_web/components/core_components.ex b/lib/livebook_web/components/core_components.ex index b9957931e..2483b17e6 100644 --- a/lib/livebook_web/components/core_components.ex +++ b/lib/livebook_web/components/core_components.ex @@ -641,7 +641,7 @@ defmodule LivebookWeb.CoreComponents do def status_indicator(assigns) do ~H""" - + - + """ diff --git a/lib/livebook_web/components/notebook_components.ex b/lib/livebook_web/components/notebook_components.ex index 084e5d515..caf881b43 100644 --- a/lib/livebook_web/components/notebook_components.ex +++ b/lib/livebook_web/components/notebook_components.ex @@ -46,46 +46,24 @@ defmodule LivebookWeb.NotebookComponents do def cell_icon(%{cell_type: :code, language: :elixir} = assigns) do ~H""" -
- - - +
+ <.language_icon language={:elixir} class="w-full h-full text-[#663299]" />
""" end def cell_icon(%{cell_type: :code, language: :erlang} = assigns) do ~H""" -
- - - - - - +
+ <.language_icon language={:erlang} class="w-full h-full text-[#a90533]" />
""" end def cell_icon(%{cell_type: :markdown} = assigns) do ~H""" -
- - - +
+ <.language_icon language={:markdown} class="w-full h-full text-[#3e64ff]" />
""" end @@ -97,4 +75,51 @@ defmodule LivebookWeb.NotebookComponents do
""" end + + @doc """ + Renders an icon for the given language. + """ + attr :language, :atom, required: true + attr :class, :string, default: nil + + def language_icon(%{language: :elixir} = assigns) do + ~H""" + + + + + """ + end + + def language_icon(%{language: :erlang} = assigns) do + ~H""" + + + + + + + """ + end + + def language_icon(%{language: :markdown} = assigns) do + ~H""" + + + + """ + end end diff --git a/lib/livebook_web/live/session_live/cell_component.ex b/lib/livebook_web/live/session_live/cell_component.ex index 30aead3c5..f5b67af52 100644 --- a/lib/livebook_web/live/session_live/cell_component.ex +++ b/lib/livebook_web/live/session_live/cell_component.ex @@ -100,9 +100,6 @@ defmodule LivebookWeb.SessionLive.CellComponent do /> <:secondary> -
- <.cell_icon cell_type={:code} language={:erlang} /> -
<.cell_settings_button cell_id={@cell_view.id} session_id={@session_id} /> <.amplify_output_button /> <.cell_link_button cell_id={@cell_view.id} /> @@ -121,7 +118,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do intellisense />
- <.cell_status id={@cell_view.id} cell_view={@cell_view} /> + <.cell_indicators id={@cell_view.id} variant="editor" cell_view={@cell_view} />
<.doctest_summary cell_id={@cell_view.id} doctest_summary={@cell_view.eval.doctest_summary} /> @@ -155,9 +152,9 @@ defmodule LivebookWeb.SessionLive.CellComponent do <.cell_body>
-
- Notebook dependencies and setup - <.cell_status id={"#{@cell_view.id}-1"} cell_view={@cell_view} /> +
+ Notebook dependencies and setup + <.cell_indicators id={"#{@cell_view.id}-1"} variant="default" cell_view={@cell_view} />
@@ -170,7 +167,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do intellisense />
- <.cell_status id={"#{@cell_view.id}-2"} cell_view={@cell_view} /> + <.cell_indicators id={"#{@cell_view.id}-2"} variant="editor" cell_view={@cell_view} />
<.evaluation_outputs @@ -258,9 +255,9 @@ defmodule LivebookWeb.SessionLive.CellComponent do <.content_skeleton empty={false} />
<% end %> -
+
- <.cell_status id={"#{@cell_view.id}-1"} cell_view={@cell_view} /> + <.cell_indicators id={"#{@cell_view.id}-1"} variant="default" cell_view={@cell_view} />
@@ -274,7 +271,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do read_only />
- <.cell_status id={"#{@cell_view.id}-2"} cell_view={@cell_view} /> + <.cell_indicators id={"#{@cell_view.id}-2"} variant="editor" cell_view={@cell_view} />
@@ -683,6 +680,35 @@ defmodule LivebookWeb.SessionLive.CellComponent do """ end + defp cell_indicators(assigns) do + ~H""" +
+
+ <.cell_status id={@id} cell_view={@cell_view} /> +
+
+ <.language_icon language={cell_language(@cell_view)} class="w-3 h-3" /> +
+
+ """ + end + + defp cell_indicator_container_class(variant) do + [ + "px-1.5 h-[22px] rounded-lg flex items-center", + case variant do + "default" -> "bg-gray-50 border border-gray-200 text-gray-500 px-1.5 h-[22px]" + "editor" -> "bg-editor-lighter border border-editor text-editor px-1.5 h-[22px]" + end + ] + end + + defp cell_language(%{language: language}), do: language + defp cell_language(%{type: :smart}), do: :elixir + + defp has_status?(%{eval: %{status: :ready, validity: :fresh}}), do: false + defp has_status?(_cell_view), do: true + defp cell_status(%{cell_view: %{eval: %{status: :evaluating}}} = assigns) do ~H""" <.cell_status_indicator variant={:progressing} change_indicator={true}> @@ -753,7 +779,7 @@ defmodule LivebookWeb.SessionLive.CellComponent do ~H"""
-
+
<%= render_slot(@inner_block) %> *