livebook/lib/livebook_web/live/home_live/import_component.ex
Jonatan Kłosko c1654345b7
Migrate to latest LV (#437)
* Update phoenix deps

* Update reference to LiveDashboard encode_pid

* Fix form input id references

* Move to HEEx

* Update back to filesystem LV npm package

* Further HEEx rewrites

* Refactor icons into function components

* .html.leex -> .html.heex

* Further refactoring

* Move render helpers into function components

* Add doctype back

* Further refactoring

* Refactor cell component

* Further refactoring

* Compose sidebar using function components

* Rewrite notebook card component as function component

* Fruther refactoring

* Fix race condition in runtime tests

* Rewrite tooltips into function component

* Update Tailwind purge rules

* Revert "Rewrite tooltips into function component"

This reverts commit bd6ca8f0b5.

* Refactor conditional tooltip
2021-07-07 14:32:49 +02:00

38 lines
1.3 KiB
Elixir

defmodule LivebookWeb.HomeLive.ImportComponent do
use LivebookWeb, :live_component
@impl true
def render(assigns) do
~H"""
<div class="p-6 pb-4 flex flex-col space-y-8">
<h3 class="text-2xl font-semibold text-gray-800">
Import notebook
</h3>
<div class="tabs">
<%= live_patch to: Routes.home_path(@socket, :import, "url"),
class: "tab #{if(@tab == "url", do: "active")}" do %>
<.remix_icon icon="download-cloud-2-line" class="align-middle" />
<span class="font-medium">
From URL
</span>
<% end %>
<%= live_patch to: Routes.home_path(@socket, :import, "content"),
class: "tab #{if(@tab == "content", do: "active")}" do %>
<.remix_icon icon="clipboard-line" class="align-middle" />
<span class="font-medium">
From clipboard
</span>
<% end %>
<div class="flex-grow tab">
</div>
</div>
<div>
<%= live_component component_for_tab(@tab), id: "import-#{@tab}" %>
</div>
</div>
"""
end
defp component_for_tab("url"), do: LivebookWeb.HomeLive.ImportUrlComponent
defp component_for_tab("content"), do: LivebookWeb.HomeLive.ImportContentComponent
end