@@ -5,6 +5,9 @@ defmodule AlgoraWeb.Components.UI.StatCard do
5
5
import AlgoraWeb.CoreComponents
6
6
7
7
attr :href , :string , default: nil
8
+ attr :navigate , :string , default: nil
9
+ attr :patch , :string , default: nil
10
+ attr :replace , :boolean , default: false
8
11
attr :title , :string
9
12
attr :value , :string , default: nil
10
13
attr :subtext , :string , default: nil
@@ -14,8 +17,8 @@ defmodule AlgoraWeb.Components.UI.StatCard do
14
17
15
18
def stat_card ( assigns ) do
16
19
~H"""
17
- <%= if @ href do %>
18
- < . link href = { @ href } >
20
+ <%= if link? ( assigns ) do %>
21
+ < . link href = { @ href } navigate = { @ navigate } patch = { @ patch } replace = { @ replace } >
19
22
< . stat_card_content { assigns } />
20
23
</ . link >
21
24
<% else %>
@@ -29,7 +32,7 @@ defmodule AlgoraWeb.Components.UI.StatCard do
29
32
< div class = {
30
33
classes ( [
31
34
"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"
33
36
] )
34
37
} >
35
38
< 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
51
54
</ div >
52
55
"""
53
56
end
57
+
58
+ defp link? ( assigns ) do
59
+ Enum . any? ( [ assigns [ :href ] , assigns [ :navigate ] , assigns [ :patch ] ] )
60
+ end
54
61
end
0 commit comments