defmodule LivebookWeb.NotebookComponents do use LivebookWeb, :html @doc """ Renders a learn notebook card. """ attr :notebook_info, :map, required: true def learn_notebook_card(assigns) do ~H""" <.link navigate={~p"/learn/notebooks/#{@notebook_info.slug}"} class="flex flex-col border-2 border-gray-100 hover:border-gray-200 rounded-2xl" >
{"#{@notebook_info.title}
{@notebook_info.title}

{@notebook_info.details.description}

""" end @doc """ Resolves the given image source into a URL. """ @spec learn_img_src(Livebook.Notebook.Learn.image_source()) :: String.t() def learn_img_src({:url, url}), do: url def learn_img_src({:static, filename}), do: ~p"/images/#{filename}" @doc """ Renders an icon for the given cell. """ attr :cell_type, :atom, required: true attr :language, :atom, default: nil def cell_icon(assigns) def cell_icon(%{cell_type: :code} = assigns) do ~H"""
<.language_icon language={Atom.to_string(@language)} class="w-full h-full text-gray-600" />
""" end def cell_icon(%{cell_type: :markdown} = assigns) do ~H"""
<.language_icon language="markdown" class="w-full h-full text-gray-600" />
""" end def cell_icon(%{cell_type: :smart} = assigns) do ~H"""
<.remix_icon icon="flashlight-line text-gray-600" />
""" end @doc """ Renders an icon for the given language. The icons are adapted from https://github.com/material-extensions/vscode-material-icon-theme. """ attr :language, :string, 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 def language_icon(%{language: "python"} = assigns) do ~H""" """ end def language_icon(%{language: "pyproject.toml"} = assigns) do ~H""" """ end end