Skip to content

Commit 97fdaa4

Browse files
committed
remove hook, make only text select node, add underline
1 parent ee6fe85 commit 97fdaa4

5 files changed

Lines changed: 23 additions & 62 deletions

File tree

assets/js/hooks.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Alpine from 'alpinejs';
22
import collapse from '@alpinejs/collapse';
33

4-
import { CollapsibleOpen, CollapsibleChevronOnly } from './hooks/collapsible';
4+
import CollapsibleOpen from './hooks/collapsible_open';
55
import Fullscreen from './hooks/fullscreen';
66
import ToggleTheme from './hooks/toggle_theme';
77
import Tooltip from './hooks/tooltip';
@@ -22,7 +22,6 @@ window.addEventListener('phx:page-loading-stop', (_info) => topbar.hide());
2222
function createHooks() {
2323
return {
2424
CollapsibleOpen,
25-
CollapsibleChevronOnly,
2625
Fullscreen,
2726
Tooltip,
2827
ToggleTheme,

assets/js/hooks/collapsible.js

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const CollapsibleOpen = {
2+
mounted() {
3+
this.el.open = true;
4+
},
5+
};
6+
7+
export default CollapsibleOpen;

lib/live_debugger/components.ex

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,6 @@ defmodule LiveDebugger.Components do
121121
attr(:chevron_class, :any, default: nil, doc: "CSS class for the chevron icon")
122122
attr(:open, :boolean, default: false, doc: "Whether the collapsible is open by default")
123123

124-
attr(:chevron_only?, :boolean,
125-
default: false,
126-
doc: "Weather to make only chevron clickable to open/close the collapsible"
127-
)
128-
129124
attr(:icon, :string,
130125
default: "icon-chevron-right",
131126
doc: "Icon for chevron. It will be rotated 90 degrees when the collapsible is open"
@@ -148,20 +143,10 @@ defmodule LiveDebugger.Components do
148143
>
149144
<summary
150145
id={@id <> "-summary"}
151-
class={
152-
[
153-
"block flex items-center",
154-
if(@chevron_only?, do: "cursor-default", else: "cursor-pointer")
155-
] ++
156-
List.wrap(@label_class)
157-
}
158-
{allow_only_chevron_to_collapse(@chevron_only?)}
146+
class={["block flex items-center cursor-pointer" | List.wrap(@label_class)]}
159147
{@rest}
160148
>
161-
<.icon
162-
name={@icon}
163-
class={["chevron cursor-pointer rotate-icon shrink-0" | List.wrap(@chevron_class)]}
164-
/>
149+
<.icon name={@icon} class={["rotate-icon shrink-0" | List.wrap(@chevron_class)]} />
165150
<%= render_slot(@label) %>
166151
</summary>
167152
<%= render_slot(@inner_block) %>
@@ -265,12 +250,6 @@ defmodule LiveDebugger.Components do
265250
def show_collapsible_assign(true), do: %{:"phx-hook" => "CollapsibleOpen"}
266251
def show_collapsible_assign(_), do: %{}
267252

268-
@doc """
269-
Used to add CollapsibleChevronOnly hook to element based on condition.
270-
"""
271-
def allow_only_chevron_to_collapse(true), do: %{:"phx-hook" => "CollapsibleChevronOnly"}
272-
def allow_only_chevron_to_collapse(_), do: %{}
273-
274253
@doc """
275254
Typography component to render headings.
276255
"""

lib/live_debugger/components/tree.ex

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ defmodule LiveDebugger.Components.Tree do
9494
chevron_class="text-accent-icon h-5 w-5"
9595
open={@open}
9696
label_class="rounded-md py-1 hover:bg-surface-1-bg-hover"
97-
chevron_only?={true}
9897
style={style_for_padding(@level, @collapsible?)}
9998
>
10099
<:label>
@@ -146,32 +145,34 @@ defmodule LiveDebugger.Components.Tree do
146145
|> assign(:button_id, "tree-node-button-#{assigns.node.parsed_id}-#{assigns.tree_id}")
147146

148147
~H"""
149-
<button
150-
id={@button_id}
151-
phx-hook="Highlight"
152-
phx-click="select_node"
153-
phx-value-node_id={@node.parsed_id}
154-
phx-value-search-attribute={get_search_attribute(@node)}
155-
phx-value-search-value={get_search_value(@node, @parent_dom_id)}
148+
<span
156149
class={[
157150
"flex shrink grow items-center rounded-md hover:bg-surface-1-bg-hover",
158151
if(!@collapsible?, do: "p-1")
159152
]}
160153
style={if(!@collapsible?, do: @padding_style)}
161154
>
162-
<span class="flex min-w-0 gap-0.5 items-center">
155+
<button
156+
id={@button_id}
157+
phx-hook="Highlight"
158+
phx-click="select_node"
159+
phx-value-node_id={@node.parsed_id}
160+
phx-value-search-attribute={get_search_attribute(@node)}
161+
phx-value-search-value={get_search_value(@node, @parent_dom_id)}
162+
class="flex min-w-0 gap-0.5 items-center"
163+
>
163164
<.icon name={@node.icon} class="text-accent-icon w-5 h-5 shrink-0" />
164165
<.tooltip
165166
id={"tree-node-#{@node.parsed_id}-#{@tree_id}"}
166167
content={@node.tooltip}
167168
class="truncate"
168169
>
169-
<span class={if(@selected?, do: "font-semibold")}>
170+
<span class={["hover:underline", if(@selected?, do: "font-semibold")]}>
170171
<%= @node.label %>
171172
</span>
172173
</.tooltip>
173-
</span>
174-
</button>
174+
</button>
175+
</span>
175176
"""
176177
end
177178

0 commit comments

Comments
 (0)