[Enhancement] Add sorting, pagination, and new attributes to sources index table (#510)
* WIP - started improving handling of sorting for sources index table * WIP - Added UI to table to indicate sort column and direction * Refactored toggle liveview into a livecomponent * Added sorting for all table attrs * Added pagination to the sources table * Added tests for updated liveviews and live components * Add tests for new helper methods * Added fancy new CSS to my sources table * Added size to sources table * Adds relative div to ensure that sorting arrow doesn't run away * Fixed da tests
This commit is contained in:
@@ -2,6 +2,7 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
|
||||
@moduledoc false
|
||||
use Phoenix.Component
|
||||
|
||||
alias Pinchflat.Utils.NumberUtils
|
||||
alias PinchflatWeb.CoreComponents
|
||||
|
||||
@doc """
|
||||
@@ -125,4 +126,24 @@ defmodule PinchflatWeb.CustomComponents.TextComponents do
|
||||
{@word}{if @count == 1, do: "", else: @suffix}
|
||||
"""
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a human-readable byte size
|
||||
"""
|
||||
|
||||
attr :byte_size, :integer, required: true
|
||||
|
||||
def readable_filesize(assigns) do
|
||||
{num, suffix} = NumberUtils.human_byte_size(assigns.byte_size, precision: 2)
|
||||
|
||||
assigns =
|
||||
Map.merge(assigns, %{
|
||||
num: num,
|
||||
suffix: suffix
|
||||
})
|
||||
|
||||
~H"""
|
||||
<.localized_number number={@num} /> {@suffix}
|
||||
"""
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user