Skip to content

Commit 387ee93

Browse files
committed
update stat card links
1 parent 58782ed commit 387ee93

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

lib/algora_web/components/ui/stat_card.ex

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ defmodule AlgoraWeb.Components.UI.StatCard do
55
import AlgoraWeb.CoreComponents
66

77
attr :href, :string, default: nil
8+
attr :navigate, :string, default: nil
9+
attr :patch, :string, default: nil
10+
attr :replace, :boolean, default: false
811
attr :title, :string
912
attr :value, :string, default: nil
1013
attr :subtext, :string, default: nil
@@ -14,8 +17,8 @@ defmodule AlgoraWeb.Components.UI.StatCard do
1417

1518
def stat_card(assigns) do
1619
~H"""
17-
<%= if @href do %>
18-
<.link href={@href}>
20+
<%= if link?(assigns) do %>
21+
<.link href={@href} navigate={@navigate} patch={@patch} replace={@replace}>
1922
<.stat_card_content {assigns} />
2023
</.link>
2124
<% else %>
@@ -29,7 +32,7 @@ defmodule AlgoraWeb.Components.UI.StatCard do
2932
<div class={
3033
classes([
3134
"group/card relative rounded-lg border bg-card text-card-foreground transition-colors duration-75",
32-
@href && "hover:bg-accent"
35+
link?(assigns) && "hover:bg-accent"
3336
])
3437
}>
3538
<div class="flex flex-row items-center justify-between space-y-0 p-6 pb-2">
@@ -51,4 +54,8 @@ defmodule AlgoraWeb.Components.UI.StatCard do
5154
</div>
5255
"""
5356
end
57+
58+
defp link?(assigns) do
59+
Enum.any?([assigns[:href], assigns[:navigate], assigns[:patch]])
60+
end
5461
end

lib/algora_web/live/org/dashboard_public_live.ex

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,28 +79,27 @@ defmodule AlgoraWeb.Org.DashboardPublicLive do
7979
title="Open Bounties"
8080
value={Money.to_string!(@stats.open_bounties_amount)}
8181
subtext={"#{@stats.open_bounties_count} bounties"}
82-
href={~p"/org/#{@org.handle}/bounties?status=open"}
82+
navigate={~p"/org/#{@org.handle}/bounties?status=open"}
8383
icon="tabler-diamond"
8484
/>
8585
<.stat_card
8686
title="Total Awarded"
8787
value={Money.to_string!(@stats.total_awarded)}
8888
subtext={"#{@stats.completed_bounties_count} bounties"}
89-
href={~p"/org/#{@org.handle}/bounties?status=completed"}
89+
navigate={~p"/org/#{@org.handle}/bounties?status=completed"}
9090
icon="tabler-gift"
9191
/>
9292
<.stat_card
9393
title="Solvers"
9494
value={@stats.solvers_count}
9595
subtext={"+#{@stats.solvers_diff} from last month"}
96-
href="#"
9796
icon="tabler-user-code"
9897
/>
9998
<.stat_card
10099
title="Members"
101100
value={@stats.members_count}
102101
subtext=""
103-
href="#"
102+
navigate={~p"/org/#{@org.handle}/team"}
104103
icon="tabler-users"
105104
/>
106105
</div>

0 commit comments

Comments
 (0)