From 88f974c97a93509c9cad796c308907adb333f667 Mon Sep 17 00:00:00 2001 From: Christopher Ross Hind Date: Thu, 31 Dec 2020 06:51:36 +0000 Subject: [PATCH] Add icon lookup table --- app/Knockout/Thread.php | 82 ++++++++++++++++++++++++ resources/views/partial/thread.blade.php | 2 +- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/app/Knockout/Thread.php b/app/Knockout/Thread.php index 94de16a..7d5a5e9 100644 --- a/app/Knockout/Thread.php +++ b/app/Knockout/Thread.php @@ -9,6 +9,7 @@ class Thread { // meta public $id; + public $icon; public $title; public $postCount; @@ -18,11 +19,92 @@ class Thread { public Post $lastPost; public User $user; + private static function getIcon(int $iconId) + { + $icons = [ + 0 => 'default', + 1 => 'drama', + 2 => 'games', + 3 => 'life', + 4 => 'money', + 5 => 'announcement', + 6 => 'arcade-cabinet', + 7 => 'blog', + 8 => 'bomb', + 9 => 'bug', + 10 => 'code', + 11 => 'combo-chart', + 12 => 'cooker', + 13 => 'crying-baby', + 14 => 'dota', + 15 => 'europe-news', + 16 => 'gallery', + 17 => 'grocery-bag', + 18 => 'gun', + 19 => 'heart-with-pulse', + 20 => 'help', + 21 => 'hot-article', + 22 => 'news', + 23 => 'nintendo-entertainment-system', + 24 => 'pin', + 25 => 'planner', + 26 => 'tv-show', + 27 => 'uk-news', + 28 => 'us-music', + 29 => 'us-news', + 30 => 'retro-tv', + 31 => 'smiling', + 32 => 'vomited', + 33 => 'test-tube', + 34 => 'easel', + 35 => 'banana', + 36 => 'heart-with-arrow', + 37 => 'radio-active', + 38 => 'poison', + 39 => 'invisible', + 40 => 'visible', + 41 => 'controller', + 42 => 'boring', + 43 => 'swearing-male', + 44 => 'idea', + 45 => 'megaphone', + 46 => 'banknotes', + 47 => 'robot-3', + 48 => 'phonelink-ring', + 49 => 'thriller', + 50 => 'hamburger', + 51 => 'sakura', + 52 => 'sushi', + 53 => 'lifebuoy', + 54 => 'handshake', + 55 => 'clenched-fist', + 56 => 'anonymous-mask', + 57 => 'rocket', + 58 => 'vodka', + 59 => 'poo', + 60 => 'sedan', + 61 => 'tesla-model-x', + 62 => 'memory-slot', + 63 => 'processor', + 64 => 'fire-element', + 65 => 'firework', + 66 => 'siren', + 67 => 'confetti', + 68 => 'campfire', + 69 => 'panties', + 70 => 'mushroom-cloud', + 71 => 'bomb-with-timer' + ]; + + return $icons[$iconId] ?? 'poo'; + } + public static function unwrap($thread) { $s = new self(); $s->id = $thread->id; + $s->icon = self::getIcon($thread->iconId); $s->title = $thread->title; $s->postCount = $thread->postCount; diff --git a/resources/views/partial/thread.blade.php b/resources/views/partial/thread.blade.php index 0acf355..a2a3a89 100644 --- a/resources/views/partial/thread.blade.php +++ b/resources/views/partial/thread.blade.php @@ -1,5 +1,5 @@
- tv-show + {{ $thread->icon }} {{ $thread->title }}