Skip to content

Commit 1146ccc

Browse files
PAS-448 | update module style in reports (#581)
* update top modules to use the panel component * fixing nAn render * update spec
1 parent 73e1d87 commit 1146ccc

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/AdminConsole/Components/Pages/App/Reporting.razor

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@
107107
if (lastActiveUserReport != null)
108108
{
109109
double totalUsers = lastActiveUserReport.TotalUsers;
110-
SummaryItems.Add(new TrendingCardsStats.Item("Daily Active Users", lastActiveUserReport.DailyActiveUsers, TrendingCardsStats.ValueTypes.Integer, "({0} of total)", lastActiveUserReport.DailyActiveUsers / totalUsers, TrendingCardsStats.ValueTypes.Percentage));
111-
SummaryItems.Add(new TrendingCardsStats.Item("Weekly Active Users", lastActiveUserReport.WeeklyActiveUsers, TrendingCardsStats.ValueTypes.Integer, "({0} of total)", lastActiveUserReport.WeeklyActiveUsers / totalUsers, TrendingCardsStats.ValueTypes.Percentage));
110+
SummaryItems.Add(new TrendingCardsStats.Item("Daily Active Users", lastActiveUserReport.DailyActiveUsers, TrendingCardsStats.ValueTypes.Integer, "({0} of total)", totalUsers == 0 ? 0 : lastActiveUserReport.DailyActiveUsers / totalUsers, TrendingCardsStats.ValueTypes.Percentage));
111+
SummaryItems.Add(new TrendingCardsStats.Item("Weekly Active Users", lastActiveUserReport.WeeklyActiveUsers, TrendingCardsStats.ValueTypes.Integer, "({0} of total)", totalUsers == 0 ? 0 : lastActiveUserReport.WeeklyActiveUsers / totalUsers, TrendingCardsStats.ValueTypes.Percentage));
112112
}
113113
return true;
114114
}

src/AdminConsole/Components/Shared/Stats/TrendingCardsStats.razor

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
@using System.Globalization
22
@inherits BaseCardStats
33

4+
45
@if (Items.Count > 0)
56
{
67
<dl class="@Class">
78
@foreach (var item in Items)
89
{
9-
<div class="flex flex-wrap items-baseline justify-between gap-x-4 gap-y-2 bg-white px-4 py-10 sm:px-6 xl:px-8">
10-
<dt class="text-sm font-medium leading-6 text-gray-500">@item.Label</dt>
11-
<dd class="text-xs font-medium text-gray-700">@string.Format(item.SubLabel, item.GetSubValue())</dd>
12-
<dd class="w-full flex-none text-3xl font-medium leading-10 tracking-tight text-gray-900">@item.GetValue()</dd>
13-
</div>
10+
<Panel>
11+
<div class="flex flex-wrap items-baseline justify-between">
12+
<dt class="text-sm font-medium leading-6 text-gray-500">@item.Label</dt>
13+
<dd class="text-xs font-medium text-gray-700">@string.Format(item.SubLabel, item.GetSubValue())</dd>
14+
<dd class="w-full flex-none text-3xl font-medium leading-10 tracking-tight text-gray-900">@item.GetValue()</dd>
15+
</div>
16+
</Panel>
1417
}
1518
</dl>
1619
}
@@ -39,7 +42,7 @@
3942
public string GetValue() => Format(Value, Type);
4043

4144
public string GetSubValue() => Format(SubValue, SubType);
42-
45+
4346
private string Format(double value, ValueTypes type)
4447
{
4548
switch (type)
@@ -49,7 +52,7 @@
4952
case ValueTypes.Integer:
5053
return value.ToString("N0", CultureInfo.InvariantCulture);
5154
case ValueTypes.Percentage:
52-
return value.ToString("P2", CultureInfo.InvariantCulture);
55+
return value.ToString("P2", CultureInfo.InvariantCulture).Replace(" ", string.Empty);
5356
default:
5457
throw new ArgumentOutOfRangeException();
5558
}

tests/AdminConsole.Tests/Components/Shared/Stats/TrendingCardsStatsTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public void TrendingCardsStats_Renders_ExpectedCardsWithExpectedContent()
5656

5757
// Assert
5858
var cards = cut.Nodes[0].ChildNodes;
59-
cards[0].MarkupMatches("<div diff:ignoreAttributes><dt diff:ignoreAttributes>Title 1</dt><dd diff:ignoreAttributes>Sub 4.00 %</dd><dd diff:ignoreAttributes>1</dd></div>");
60-
cards[1].MarkupMatches("<div diff:ignoreAttributes><dt diff:ignoreAttributes>Title 2</dt><dd diff:ignoreAttributes>Sub 2.00 %</dd><dd diff:ignoreAttributes>2.00</dd></div>");
61-
cards[2].MarkupMatches("<div diff:ignoreAttributes><dt diff:ignoreAttributes>Title 3</dt><dd diff:ignoreAttributes>Sub 1</dd><dd diff:ignoreAttributes>300.00 %</dd></div>");
59+
cards[0].MarkupMatches("<div diff:ignoreAttributes><div diff:ignoreAttributes><div diff:ignoreAttributes><dt diff:ignoreAttributes>Title 1</dt><dd diff:ignoreAttributes>Sub 4.00%</dd><dd diff:ignoreAttributes>1</dd></div></div></div>");
60+
cards[1].MarkupMatches("<div diff:ignoreAttributes><div diff:ignoreAttributes><div diff:ignoreAttributes><dt diff:ignoreAttributes>Title 2</dt><dd diff:ignoreAttributes>Sub 2.00%</dd><dd diff:ignoreAttributes>2.00</dd></div></div></div>");
61+
cards[2].MarkupMatches("<div diff:ignoreAttributes><div diff:ignoreAttributes><div diff:ignoreAttributes><dt diff:ignoreAttributes>Title 3</dt><dd diff:ignoreAttributes>Sub 1</dd><dd diff:ignoreAttributes>300.00%</dd></div></div></div>");
6262
}
6363

6464
[Fact]

0 commit comments

Comments
 (0)