Uniform use of .section/1 across all stats components
This commit is contained in:
@@ -337,4 +337,23 @@ defmodule MusicLibraryWeb.StatsComponents do
|
|||||||
_other -> ""
|
_other -> ""
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr :container_class, :string, default: nil
|
||||||
|
slot :title, required: true
|
||||||
|
slot :side_actions
|
||||||
|
slot :inner_block, required: true
|
||||||
|
|
||||||
|
def section(assigns) do
|
||||||
|
~H"""
|
||||||
|
<div class={["mt-5", @container_class]}>
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h1 class="text-base font-semibold text-zinc-900 lg:text-2xl dark:text-zinc-200">
|
||||||
|
{render_slot(@title)}
|
||||||
|
</h1>
|
||||||
|
{render_slot(@side_actions)}
|
||||||
|
</div>
|
||||||
|
{render_slot(@inner_block)}
|
||||||
|
</div>
|
||||||
|
"""
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -227,13 +227,12 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
~H"""
|
~H"""
|
||||||
<div class="flow-root">
|
<div class="flow-root">
|
||||||
<.tabs id="scrobble-activity" class="mt-4">
|
<.tabs id="scrobble-activity" class="mt-4">
|
||||||
<div class="mt-5 flex end items-center justify-between">
|
<.section>
|
||||||
<div class="flex">
|
<:title>
|
||||||
<h1 class="text-base font-semibold text-zinc-900 lg:text-2xl dark:text-zinc-200 mr-2">
|
|
||||||
{gettext("Scrobble activity")}
|
{gettext("Scrobble activity")}
|
||||||
</h1>
|
|
||||||
<.refresh_lastfm_feed_button />
|
<.refresh_lastfm_feed_button />
|
||||||
</div>
|
</:title>
|
||||||
|
<:side_actions>
|
||||||
<.tabs_list active_tab={@scrobble_activity_mode} variant="segmented">
|
<.tabs_list active_tab={@scrobble_activity_mode} variant="segmented">
|
||||||
<:tab
|
<:tab
|
||||||
name="albums"
|
name="albums"
|
||||||
@@ -248,7 +247,7 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
{gettext("Tracks")}
|
{gettext("Tracks")}
|
||||||
</:tab>
|
</:tab>
|
||||||
</.tabs_list>
|
</.tabs_list>
|
||||||
</div>
|
</:side_actions>
|
||||||
<.tabs_panel name="albums" active={@scrobble_activity_mode == "albums"}>
|
<.tabs_panel name="albums" active={@scrobble_activity_mode == "albums"}>
|
||||||
<ul
|
<ul
|
||||||
id="scrobble-activity-albums"
|
id="scrobble-activity-albums"
|
||||||
@@ -333,7 +332,7 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
<ul
|
<ul
|
||||||
id="scrobble-activity-tracks"
|
id="scrobble-activity-tracks"
|
||||||
role="list"
|
role="list"
|
||||||
class="mt-5 rounded-md bg-white p-6 shadow-sm dark:bg-zinc-800"
|
class="mt-4 rounded-md bg-white p-6 shadow-sm dark:bg-zinc-800"
|
||||||
phx-update="stream"
|
phx-update="stream"
|
||||||
>
|
>
|
||||||
<li
|
<li
|
||||||
@@ -412,6 +411,7 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</.tabs_panel>
|
</.tabs_panel>
|
||||||
|
</.section>
|
||||||
</.tabs>
|
</.tabs>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
@@ -516,25 +516,6 @@ defmodule MusicLibraryWeb.StatsLive.Index do
|
|||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
attr :container_class, :string, default: nil
|
|
||||||
slot :title, required: true
|
|
||||||
slot :side_actions
|
|
||||||
slot :inner_block, required: true
|
|
||||||
|
|
||||||
defp section(assigns) do
|
|
||||||
~H"""
|
|
||||||
<div class={["mt-5", @container_class]}>
|
|
||||||
<div class="flex items-center justify-between">
|
|
||||||
<h1 class="text-base font-semibold text-zinc-900 lg:text-2xl dark:text-zinc-200">
|
|
||||||
{render_slot(@title)}
|
|
||||||
</h1>
|
|
||||||
{render_slot(@side_actions)}
|
|
||||||
</div>
|
|
||||||
{render_slot(@inner_block)}
|
|
||||||
</div>
|
|
||||||
"""
|
|
||||||
end
|
|
||||||
|
|
||||||
defp assign_counts(socket) do
|
defp assign_counts(socket) do
|
||||||
collection_count_by_format = Collection.count_records_by_format()
|
collection_count_by_format = Collection.count_records_by_format()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
defmodule MusicLibraryWeb.StatsLive.TopByPeriod do
|
defmodule MusicLibraryWeb.StatsLive.TopByPeriod do
|
||||||
use MusicLibraryWeb, :live_component
|
use MusicLibraryWeb, :live_component
|
||||||
|
|
||||||
|
import MusicLibraryWeb.StatsComponents, only: [section: 1]
|
||||||
|
|
||||||
attr :id, :string, required: true
|
attr :id, :string, required: true
|
||||||
attr :title, :string, required: true
|
attr :title, :string, required: true
|
||||||
attr :key, :atom, required: true
|
attr :key, :atom, required: true
|
||||||
@@ -19,12 +21,11 @@ defmodule MusicLibraryWeb.StatsLive.TopByPeriod do
|
|||||||
@impl true
|
@impl true
|
||||||
def render(assigns) do
|
def render(assigns) do
|
||||||
~H"""
|
~H"""
|
||||||
<div class="mt-5">
|
<div>
|
||||||
<.tabs>
|
<.tabs>
|
||||||
<div class="flex justify-between">
|
<.section>
|
||||||
<h1 class="text-base font-semibold text-zinc-900 lg:text-2xl dark:text-zinc-200">
|
<:title>{@title}</:title>
|
||||||
{@title}
|
<:side_actions>
|
||||||
</h1>
|
|
||||||
<.tabs_list active_tab={name_from_period(@key, @period)} variant="segmented" size="xs">
|
<.tabs_list active_tab={name_from_period(@key, @period)} variant="segmented" size="xs">
|
||||||
<:tab
|
<:tab
|
||||||
class="flex-1"
|
class="flex-1"
|
||||||
@@ -67,7 +68,7 @@ defmodule MusicLibraryWeb.StatsLive.TopByPeriod do
|
|||||||
{gettext("∞")}
|
{gettext("∞")}
|
||||||
</:tab>
|
</:tab>
|
||||||
</.tabs_list>
|
</.tabs_list>
|
||||||
</div>
|
</:side_actions>
|
||||||
<.async_result :let={items} assign={assigns[@key]}>
|
<.async_result :let={items} assign={assigns[@key]}>
|
||||||
<:loading>
|
<:loading>
|
||||||
<div class="flex h-182 items-center justify-center">
|
<div class="flex h-182 items-center justify-center">
|
||||||
@@ -80,6 +81,7 @@ defmodule MusicLibraryWeb.StatsLive.TopByPeriod do
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</.async_result>
|
</.async_result>
|
||||||
|
</.section>
|
||||||
</.tabs>
|
</.tabs>
|
||||||
</div>
|
</div>
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user