Improve html tree component

This commit is contained in:
Thelonius Kort
2023-05-03 22:37:43 +02:00
parent 7990b74bf0
commit 8a0e2f22c1
3 changed files with 18 additions and 4 deletions

View File

@ -3,6 +3,7 @@ defmodule OutlookWeb.HtmlTreeComponent do
use Phoenix.Component
# use OutlookWeb, :html
import OutlookWeb.CoreComponents
import OutlookWeb.ViewHelpers
alias Phoenix.LiveView.JS
@ -15,10 +16,14 @@ defmodule OutlookWeb.HtmlTreeComponent do
end
def attributes(assigns) do
~H"&nbsp; <%= @name %>=&quot;<%= @value %>&quot;"
~H"&nbsp; <%= @name %>=&quot;<%= elipsed_text(@value, 16) %>&quot;"
end
def tnode(%{node: %{status: _}} = assigns), do: ~H"<%= String.slice(@node.content, 0..20) %><%= if String.length(@node.content) > 20 do %>...<% end %><br>"
def tnode(%{node: %{status: _}} = assigns) do
~H"""
<span title={@node.content} {@node.eph.attributes}><%= elipsed_text(@node.content, 30) %></span><br>
"""
end
def tnode(assigns) when assigns.node.type == :element do
~H"""
@ -32,7 +37,7 @@ defmodule OutlookWeb.HtmlTreeComponent do
def tnode(assigns) when assigns.node.type == :text do
~H"""
"<%= String.slice(@node.content, 0..35) %><%= if String.length(@node.content) > 35 do %>..."<% end %><br>
"<%= elipsed_text(@node.content, 30) %><br>
"""
end