Extract json_viewer component

This commit is contained in:
Claudio Ortolina
2025-05-24 09:39:12 +01:00
parent 160f5aa3da
commit c09438fe5e
3 changed files with 16 additions and 10 deletions
@@ -182,6 +182,18 @@ defmodule MusicLibraryWeb.CoreComponents do
"""
end
attr :title, :string, required: true
attr :data, :map, required: true
def json_viewer(assigns) do
~H"""
<details class="mt-4 px-4 text-zinc-700 hover:text-zinc-500 dark:text-zinc-400 dark:hover:text-zinc-300">
<summary class="text-xs sm:text-sm cursor-pointer">{@title}</summary>
<pre><code class="text-xs sm:text-sm"><%= Jason.encode!(@data, pretty: true) %></code></pre>
</details>
"""
end
## JS Commands
def show(js \\ %JS{}, selector) do