Skip to content

Commit

Permalink
Stats section: support for icon option
Browse files Browse the repository at this point in the history
Fixes #6006
  • Loading branch information
distantnative committed Nov 29, 2023
1 parent 40eae8e commit 525f2b6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/sections/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
$value = $report['value'] ?? null;

$reports[] = [
'icon' => $toString($report['icon'] ?? null),
'info' => $toString(I18n::translate($info, $info)),
'label' => $toString(I18n::translate($label, $label)),
'link' => $toString(I18n::translate($link, $link)),
Expand Down
9 changes: 8 additions & 1 deletion tests/Cms/Sections/StatsSectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public function reports()
{
return [
[
'icon' => 'heart',
'info' => 'Info A',
'label' => 'A',
'link' => 'https://getkirby.com',
'theme' => null,
'value' => 'Value A',
],
[
'icon' => null,
'info' => null,
'label' => 'B',
'link' => null,
Expand Down Expand Up @@ -138,7 +140,10 @@ public function testReportsTranslatedInfo()
{
$section = new Section('stats', [
'name' => 'test',
'model' => Page::factory(['slug' => 'test']),
'model' => Page::factory([
'slug' => 'test',
'content' => ['icon' => 'heart']
]),
'reports' => [
[
'label' => 'C',
Expand All @@ -147,6 +152,7 @@ public function testReportsTranslatedInfo()
'en' => 'Extra information',
'de' => 'Zusatzinformation'
],
'icon' => '{{ page.icon }}',
'link' => null,
'theme' => null,
]
Expand All @@ -158,5 +164,6 @@ public function testReportsTranslatedInfo()
$this->assertSame('C', $report['label']);
$this->assertSame('Value C', $report['value']);
$this->assertSame('Extra information', $report['info']);
$this->assertSame('heart', $report['icon']);
}
}

0 comments on commit 525f2b6

Please sign in to comment.