livebook/lib/livebook_web/live/session_live/elixir_standalone_live.ex
Jonatan Kłosko 90e7941fe4
Redesign (#80)
* Update cell actions

* Add new focus indicator

* Update headings typography

* Update cell actions and insert buttons

* Add sidebar menu

* Add settings modal

* Update homepage

* Update settings dialog

* Rename classes

* Add floating menu

* Update icon colors on hover

* Fix homepage tests

* Format assets source

* Update monaco editor

* Fix editor width on resize

* Add more padding to the notebook content

* Update settings dialog title

* Show reevaluate button when the cell is in evaluated state

* Show section actions on focus or hover only

* Pre-fill runtime selector with the current configuration

* Ignore cmd + enter in Markdown cells
2021-03-20 14:10:15 +01:00

38 lines
1 KiB
Elixir

defmodule LivebookWeb.SessionLive.ElixirStandaloneLive do
use LivebookWeb, :live_view
alias Livebook.{Session, Runtime}
@impl true
def mount(_params, %{"session_id" => session_id}, socket) do
{:ok, assign(socket, session_id: session_id, output: nil)}
end
@impl true
def render(assigns) do
~L"""
<div class="flex-col space-y-3">
<p class="text-gray-700">
Start a new local node to handle code evaluation.
This is the default runtime and is started automatically
as soon as you evaluate the first cell.
</p>
<button class="button" phx-click="init">
Connect
</button>
<%= if @output do %>
<div class="markdown max-h-20 overflow-y-auto tiny-scrollbar">
<pre><code><%= @output %></code></pre>
</div>
<% end %>
</div>
"""
end
@impl true
def handle_event("init", _params, socket) do
{:ok, runtime} = Runtime.ElixirStandalone.init()
Session.connect_runtime(socket.assigns.session_id, runtime)
{:noreply, socket}
end
end