2021-04-23 23:40:13 +08:00
|
|
|
defmodule LivebookWeb.HomeLive.ImportComponent do
|
|
|
|
use LivebookWeb, :live_component
|
|
|
|
|
|
|
|
@impl true
|
|
|
|
def render(assigns) do
|
2021-07-07 20:32:49 +08:00
|
|
|
~H"""
|
2021-04-28 20:28:28 +08:00
|
|
|
<div class="p-6 pb-4 flex flex-col space-y-8">
|
2021-04-23 23:40:13 +08:00
|
|
|
<h3 class="text-2xl font-semibold text-gray-800">
|
|
|
|
Import notebook
|
|
|
|
</h3>
|
|
|
|
<div class="tabs">
|
|
|
|
<%= live_patch to: Routes.home_path(@socket, :import, "url"),
|
2021-07-07 20:32:49 +08:00
|
|
|
class: "tab #{if(@tab == "url", do: "active")}" do %>
|
|
|
|
<.remix_icon icon="download-cloud-2-line" class="align-middle" />
|
2021-04-23 23:40:13 +08:00
|
|
|
<span class="font-medium">
|
|
|
|
From URL
|
|
|
|
</span>
|
|
|
|
<% end %>
|
|
|
|
<%= live_patch to: Routes.home_path(@socket, :import, "content"),
|
2021-07-07 20:32:49 +08:00
|
|
|
class: "tab #{if(@tab == "content", do: "active")}" do %>
|
|
|
|
<.remix_icon icon="clipboard-line" class="align-middle" />
|
2021-04-23 23:40:13 +08:00
|
|
|
<span class="font-medium">
|
|
|
|
From clipboard
|
|
|
|
</span>
|
|
|
|
<% end %>
|
2021-11-01 20:59:39 +08:00
|
|
|
<%= live_patch to: Routes.home_path(@socket, :import, "file_upload"),
|
|
|
|
class: "tab #{if(@tab == "file_upload", do: "active")}" do %>
|
|
|
|
<.remix_icon icon="file-upload-line" class="align-middle" />
|
|
|
|
<span class="font-medium">
|
|
|
|
File upload
|
|
|
|
</span>
|
|
|
|
<% end %>
|
2021-04-23 23:40:13 +08:00
|
|
|
<div class="flex-grow tab">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
2021-11-02 02:33:43 +08:00
|
|
|
<.live_component module={component_for_tab(@tab)}
|
|
|
|
id={"import-#{@tab}"}
|
|
|
|
{@import_opts} />
|
2021-04-23 23:40:13 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
"""
|
|
|
|
end
|
2021-07-07 20:32:49 +08:00
|
|
|
|
|
|
|
defp component_for_tab("url"), do: LivebookWeb.HomeLive.ImportUrlComponent
|
|
|
|
defp component_for_tab("content"), do: LivebookWeb.HomeLive.ImportContentComponent
|
2021-11-01 20:59:39 +08:00
|
|
|
defp component_for_tab("file_upload"), do: LivebookWeb.HomeLive.ImportFileUploadComponent
|
2021-04-23 23:40:13 +08:00
|
|
|
end
|