Skip to content

Commit c3a233f

Browse files
authored
Bug: fix spacing in open in editor button (#949)
* Moved tooltip to button * Extracted button * Added condition to second button * Removed fake assigns * Add button_link component * Replaced button with link on editor not found * Fix e2e test
1 parent 64c709a commit c3a233f

3 files changed

Lines changed: 59 additions & 15 deletions

File tree

e2e/tests/node-inspector.spec.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,15 @@ test('user can change nodes using node tree and see their assigns and callback t
154154
await expect(findTraces(dbgApp)).toHaveCount(6);
155155
});
156156

157-
test('Open in editor is disabled when envs are not set', async ({ dbgApp }) => {
158-
const openButton = dbgApp.getByRole('button', { name: 'Open in editor' });
159-
await expect(openButton).toBeDisabled();
157+
test('Open in editor shows docs link when envs are not set', async ({
158+
dbgApp,
159+
}) => {
160+
const openInEditorLink = dbgApp.getByRole('link', {
161+
name: 'Open in Editor',
162+
});
163+
await expect(openInEditorLink).toBeVisible();
164+
await expect(openInEditorLink).toHaveAttribute(
165+
'href',
166+
/open_in_editor\.html/
167+
);
160168
});

lib/live_debugger/app/debugger/web/live_components/node_basic_info.ex

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,23 @@ defmodule LiveDebugger.App.Debugger.Web.LiveComponents.NodeBasicInfo do
109109
</.button>
110110
111111
<div class="flex flex-row items-center gap-2">
112+
<.tooltip
113+
:if={!@elixir_editor}
114+
id={@id <> "-env-not-set"}
115+
content="Cannot open in editor? Click to see the documentation."
116+
>
117+
<.button_link
118+
href={@editor_docs_url}
119+
id="open-in-editor"
120+
variant="secondary"
121+
size="sm"
122+
class="opacity-50 cursor-pointer"
123+
>
124+
<.icon name="icon-external-link" class="w-4 h-4" /> Open in Editor
125+
</.button_link>
126+
</.tooltip>
112127
<.button
113-
disabled={!@elixir_editor}
128+
:if={@elixir_editor}
114129
class="shrink-0"
115130
variant="secondary"
116131
id="open-in-editor"
@@ -122,17 +137,6 @@ defmodule LiveDebugger.App.Debugger.Web.LiveComponents.NodeBasicInfo do
122137
>
123138
<.icon name="icon-external-link" class="w-4 h-4" /> Open in Editor
124139
</.button>
125-
126-
<.tooltip
127-
id={@id <> "-env-not-set"}
128-
content="Cannot open in editor? Click to see the documentation."
129-
>
130-
<span :if={!@elixir_editor} class="text-error-text">
131-
<.link href={@editor_docs_url} target="_blank">
132-
<.icon name="icon-info" class="w-4 h-4" />
133-
</.link>
134-
</span>
135-
</.tooltip>
136140
</div>
137141
</div>
138142

lib/live_debugger/app/web/components.ex

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,38 @@ defmodule LiveDebugger.App.Web.Components do
248248
"""
249249
end
250250

251+
@doc """
252+
Link styled as a button. Use for external links that should match button appearance.
253+
"""
254+
attr(:href, :string, required: true)
255+
attr(:variant, :string, default: "secondary", values: ["primary", "secondary"])
256+
attr(:size, :string, default: "sm", values: ["md", "sm"])
257+
attr(:target, :string, default: "_blank")
258+
attr(:id, :string, default: nil)
259+
attr(:class, :any, default: nil, doc: "Additional classes to add.")
260+
attr(:rest, :global, include: ~w(rel))
261+
262+
slot(:inner_block, required: true)
263+
264+
def button_link(assigns) do
265+
~H"""
266+
<.link
267+
href={@href}
268+
target={@target}
269+
id={@id}
270+
class={[
271+
"inline-flex items-center gap-1.5 shrink-0 w-max h-max rounded text-xs font-semibold",
272+
button_size_classes(@size),
273+
button_color_classes(@variant),
274+
@class
275+
]}
276+
{@rest}
277+
>
278+
<%= render_slot(@inner_block) %>
279+
</.link>
280+
"""
281+
end
282+
251283
@doc """
252284
Collapsible element that can be toggled open and closed.
253285
It uses the `details` and `summary` HTML elements.

0 commit comments

Comments
 (0)