Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Sorting icon for table update [MDS-971] #825

9 changes: 8 additions & 1 deletion lib/moon/design/table.ex
phgrey marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ defmodule Moon.Design.Table do
@doc "Additional attributes for tbody tag"
prop(body_attrs, :map, default: %{})

@doc "Icon for sorting"
prop(sorting_icon, :string, default: "controls_chevron_up_small")

@doc "Icon color for sorting"
prop(sorting_icon_color, :string)

def render(assigns) do
import Moon.Light.Table.Helper

Expand Down Expand Up @@ -105,11 +111,12 @@ defmodule Moon.Design.Table do
<Icon
:if={col[:name] && col[:sortable]}
class={
@sorting_icon_color,
"text-[1.5em] transition-transform transition-200",
"rotate-180": @sort[:"#{col[:name]}"] != "ASC",
"opacity-0": !@sort[:"#{col[:name]}"]
}
name="arrows_up"
name={@sorting_icon}
/>
</th>
{/for}
Expand Down
6 changes: 6 additions & 0 deletions lib/moon/parts/table.ex
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,11 @@ defmodule Moon.Parts.Table do
@doc "Additional attributes for tbody tag"
prop(body_attrs, :map, default: %{})

@doc "Icon for sorting"
prop(sorting_icon, :string, default: "controls_chevron_up_small")

@doc "Icon color for sorting"
prop(sorting_icon_color, :string, default: "text-bulma")

defdelegate render(assigns), to: Moon.Design.Table
end