From 5f0d68002de887c350ad1bdd5b7162ca9f14d34f Mon Sep 17 00:00:00 2001 From: sulimanbenhalim Date: Sun, 29 Nov 2026 05:45:20 +0200 Subject: [PATCH] Draw the Sweet Tooth, Whoopsie and git blame badges with their own icons, as the web does --- app/Devnull/Data/Badge.php | 8 ++++++++ app/Icons/Lucide.php | 10 +++++++--- resources/icons/cookie.svg | 1 - resources/icons/git-commit-horizontal.svg | 1 + resources/icons/mushroom-cloud.svg | 1 + .../partials/achievements-sheet.blade.php | 6 +++++- .../native/partials/achievements.blade.php | 6 +++++- .../Feature/Screens/AchievementsSheetTest.php | 20 ++++++++++++++++++- 8 files changed, 46 insertions(+), 7 deletions(-) delete mode 100644 resources/icons/cookie.svg create mode 100644 resources/icons/git-commit-horizontal.svg create mode 100644 resources/icons/mushroom-cloud.svg diff --git a/app/Devnull/Data/Badge.php b/app/Devnull/Data/Badge.php index 6f9057c2..c9e5e4f1 100644 --- a/app/Devnull/Data/Badge.php +++ b/app/Devnull/Data/Badge.php @@ -33,6 +33,14 @@ public static function fromArray(array $data): self ); } + /** + * The picture the web draws in place of the badge's icon: the pastel de nata for Sweet Tooth. Null for the rest. + */ + public function image(): ?string + { + return $this->icon === 'pastel-de-nata' ? Pasteis::Image : null; + } + /** * The web only counts progress on a locked badge that takes more than one step: "(3/10)". */ diff --git a/app/Icons/Lucide.php b/app/Icons/Lucide.php index f018a626..25306218 100644 --- a/app/Icons/Lucide.php +++ b/app/Icons/Lucide.php @@ -90,11 +90,13 @@ enum Lucide case GitMerge; case Maximize; case Key; - case Cookie; case BotOff; case Bomb; /** Lucide has no dragon ball, so this is the web's own drawing, from its dragon-ball-icon.tsx. */ case DragonBall; + /** Lucide has no mushroom cloud either, so this is the web's mushroom-cloud-icon.tsx. */ + case MushroomCloud; + case GitCommitHorizontal; case PinOff; case BellOff; case LogOut; @@ -150,10 +152,11 @@ public static function forBadge(string $icon): self 'git-merge' => self::GitMerge, 'maximize' => self::Maximize, 'key' => self::Key, - 'cookie' => self::Cookie, 'bot-off' => self::BotOff, 'bomb' => self::Bomb, 'dragon-ball' => self::DragonBall, + 'mushroom-cloud' => self::MushroomCloud, + 'git-commit-horizontal' => self::GitCommitHorizontal, default => self::Terminal, }; } @@ -232,10 +235,11 @@ public function custom(bool $filled = false): string self::GitMerge => 'git-merge', self::Maximize => 'maximize', self::Key => 'key', - self::Cookie => 'cookie', self::BotOff => 'bot-off', self::Bomb => 'bomb', self::DragonBall => 'dragon-ball', + self::MushroomCloud => 'mushroom-cloud', + self::GitCommitHorizontal => 'git-commit-horizontal', self::Pin => $filled ? 'pin-filled' : 'pin', self::PinOff => 'pin-off', self::BellOff => 'bell-off', diff --git a/resources/icons/cookie.svg b/resources/icons/cookie.svg deleted file mode 100644 index 72745718..00000000 --- a/resources/icons/cookie.svg +++ /dev/null @@ -1 +0,0 @@ - diff --git a/resources/icons/git-commit-horizontal.svg b/resources/icons/git-commit-horizontal.svg new file mode 100644 index 00000000..5e20767c --- /dev/null +++ b/resources/icons/git-commit-horizontal.svg @@ -0,0 +1 @@ + diff --git a/resources/icons/mushroom-cloud.svg b/resources/icons/mushroom-cloud.svg new file mode 100644 index 00000000..4b814997 --- /dev/null +++ b/resources/icons/mushroom-cloud.svg @@ -0,0 +1 @@ + diff --git a/resources/views/native/partials/achievements-sheet.blade.php b/resources/views/native/partials/achievements-sheet.blade.php index 9d7ae925..869661a4 100644 --- a/resources/views/native/partials/achievements-sheet.blade.php +++ b/resources/views/native/partials/achievements-sheet.blade.php @@ -59,7 +59,11 @@ - + @if ($badge->image() !== null) + + @else + + @endif {{ $badge->name }} @if ($badge->unlocked) diff --git a/resources/views/native/partials/achievements.blade.php b/resources/views/native/partials/achievements.blade.php index 24db5c91..a0177e3e 100644 --- a/resources/views/native/partials/achievements.blade.php +++ b/resources/views/native/partials/achievements.blade.php @@ -37,7 +37,11 @@ @php($icon = \App\Icons\Lucide::forBadge($badge->icon)) - + @if ($badge->image() !== null) + + @else + + @endif {{ $badge->name }} diff --git a/tests/Feature/Screens/AchievementsSheetTest.php b/tests/Feature/Screens/AchievementsSheetTest.php index e00ff962..ab543205 100644 --- a/tests/Feature/Screens/AchievementsSheetTest.php +++ b/tests/Feature/Screens/AchievementsSheetTest.php @@ -1,5 +1,6 @@ ($node['type'] ?? null) === 'icon')['props']['name'] ?? null)->toBe("custom:{$icon}"); })->with([ - 'sweet tooth' => ['sweet_tooth', 'cookie'], 'luddite' => ['luddite', 'bot-off'], 'shell shocked' => ['shell_shocked', 'bomb'], 'super-saiyan' => ['super_saiyan', 'dragon-ball'], + 'whoopsie' => ['whoopsie', 'mushroom-cloud'], + 'git blame' => ['git_blame', 'git-commit-horizontal'], ]); +it('draws sweet tooth with the pastel de nata on the profile and in the sheet, as the web does', function () { + $json = achievementsProfileJson(); + $json['achievements']['badges'][] = ['id' => 'sweet_tooth', 'name' => 'Sweet Tooth', 'description' => '', 'icon' => 'pastel-de-nata', 'unlocked' => true, 'progress' => 1, 'target' => 1]; + + fakeApi(['GET /api/v1/users/ada' => [$json], 'GET /api/v1/users/ada/commits' => [pageJson([])]]); + + $pastel = fn (array $node): bool => ($node['type'] ?? null) === 'image' && ($node['props']['src'] ?? null) === Pasteis::Image; + $screen = Native::visit('/log/users/ada', platform: 'ios'); + + expect(findNode(nodeByRef($screen, 'badge-sweet_tooth'), $pastel))->not->toBeNull(); + + $screen->tap('achievements-open'); + + expect(findNode(nodeByRef($screen, 'sheet-badge-sweet_tooth'), $pastel))->not->toBeNull(); +}); + it('marks the badge it was opened on in the owner\'s lane', function () { $screen = adaWithAchievements();