mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-09-10 15:04:25 +08:00
Regroup cell insert buttons (#1073)
* Regroup cell insert buttons * Add spacing to divider * Split into two menus * Remove smart cell icon
This commit is contained in:
parent
bc4c04c1b7
commit
4369a45bd5
2 changed files with 26 additions and 13 deletions
|
@ -8,25 +8,38 @@ defmodule LivebookWeb.SessionLive.InsertButtonsComponent do
|
||||||
aria-label="insert new"
|
aria-label="insert new"
|
||||||
data-element="insert-buttons">
|
data-element="insert-buttons">
|
||||||
<div class={"w-full absolute z-10 focus-within:z-[11] #{if(@persistent, do: "opacity-100", else: "opacity-0")} hover:opacity-100 focus-within:opacity-100 flex space-x-2 justify-center items-center"}>
|
<div class={"w-full absolute z-10 focus-within:z-[11] #{if(@persistent, do: "opacity-100", else: "opacity-0")} hover:opacity-100 focus-within:opacity-100 flex space-x-2 justify-center items-center"}>
|
||||||
<button class="button-base button-small"
|
|
||||||
phx-click="insert_cell_below"
|
|
||||||
phx-value-type="markdown"
|
|
||||||
phx-value-section_id={@section_id}
|
|
||||||
phx-value-cell_id={@cell_id}
|
|
||||||
>+ Markdown</button>
|
|
||||||
<button class="button-base button-small"
|
<button class="button-base button-small"
|
||||||
phx-click="insert_cell_below"
|
phx-click="insert_cell_below"
|
||||||
phx-value-type="code"
|
phx-value-type="code"
|
||||||
phx-value-section_id={@section_id}
|
phx-value-section_id={@section_id}
|
||||||
phx-value-cell_id={@cell_id}
|
phx-value-cell_id={@cell_id}
|
||||||
>+ Code</button>
|
>+ Code</button>
|
||||||
<button class="button-base button-small"
|
<.menu id={"#{@id}-block-menu"} position="left">
|
||||||
phx-click="insert_section_below"
|
<:toggle>
|
||||||
phx-value-section_id={@section_id}
|
<button class="button-base button-small">+ Block</button>
|
||||||
phx-value-cell_id={@cell_id}
|
</:toggle>
|
||||||
>+ Section</button>
|
<:content>
|
||||||
|
<button class="menu-item text-gray-500"
|
||||||
|
role="menuitem"
|
||||||
|
phx-click="insert_cell_below"
|
||||||
|
phx-value-type="markdown"
|
||||||
|
phx-value-section_id={@section_id}
|
||||||
|
phx-value-cell_id={@cell_id}>
|
||||||
|
<.remix_icon icon="markdown-fill" />
|
||||||
|
<span class="font-medium">Markdown</span>
|
||||||
|
</button>
|
||||||
|
<button class="menu-item text-gray-500"
|
||||||
|
role="menuitem"
|
||||||
|
phx-click="insert_section_below"
|
||||||
|
phx-value-section_id={@section_id}
|
||||||
|
phx-value-cell_id={@cell_id}>
|
||||||
|
<.remix_icon icon="h-2" />
|
||||||
|
<span class="font-medium">Section</span>
|
||||||
|
</button>
|
||||||
|
</:content>
|
||||||
|
</.menu>
|
||||||
<%= if @smart_cell_definitions != [] do %>
|
<%= if @smart_cell_definitions != [] do %>
|
||||||
<.menu id={"#{@id}-smart-cell-menu"}>
|
<.menu id={"#{@id}-smart-menu"} position="left">
|
||||||
<:toggle>
|
<:toggle>
|
||||||
<button class="button-base button-small">+ Smart</button>
|
<button class="button-base button-small">+ Smart</button>
|
||||||
</:toggle>
|
</:toggle>
|
||||||
|
|
|
@ -106,7 +106,7 @@ defmodule LivebookWeb.SessionLiveTest do
|
||||||
{:ok, view, _} = live(conn, "/sessions/#{session.id}")
|
{:ok, view, _} = live(conn, "/sessions/#{session.id}")
|
||||||
|
|
||||||
view
|
view
|
||||||
|> element("button", "+ Markdown")
|
|> element("button", "Markdown")
|
||||||
|> render_click()
|
|> render_click()
|
||||||
|
|
||||||
assert %{notebook: %{sections: [%{cells: [%Cell.Markdown{}]}]}} =
|
assert %{notebook: %{sections: [%{cells: [%Cell.Markdown{}]}]}} =
|
||||||
|
|
Loading…
Add table
Reference in a new issue