From 77a13566343a7de2883ea3f06cf088b94476132b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr>
Date: Sat, 25 Sep 2021 13:44:57 +0200
Subject: [PATCH] Improve layout, add artists/playlists images

---
 public/index.php |  4 ++--
 template.php     | 10 ++++++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/public/index.php b/public/index.php
index 1ff8417..85f8731 100644
--- a/public/index.php
+++ b/public/index.php
@@ -165,8 +165,8 @@ if ($generatePlaylistFromPlaylist) {
     $playlistLink = '<a href="'.$newPlaylist->external_urls->spotify.'">'.$newPlaylistName.'</a>';
     $templateData['infos'][] = 'Ok created new playlist with '.count($pickedTrackIds).' tracks: '.$playlistLink;
 } else {
-    $templateData['topArtists'] = $api->getMyTop('artists', ['limit' => 16, 'time_range' => 'short_term'])->items;
-    $templateData['playlists'] = $api->getUserPlaylists($user->id, ['limit' => 30])->items;
+    $templateData['topArtists'] = $api->getMyTop('artists', ['limit' => 24, 'time_range' => 'short_term'])->items;
+    $templateData['playlists'] = $api->getUserPlaylists($user->id, ['limit' => 24])->items;
 }
 
 require '../template.php';
diff --git a/template.php b/template.php
index 308e98d..066f4de 100644
--- a/template.php
+++ b/template.php
@@ -14,7 +14,7 @@
 <body class="container mt-2">
 
   <div class="row">
-    <div class="col-3">
+    <div class="col-2">
 
       <div class="card">
         <?php if (count($templateData['user']->images)) { ?>
@@ -32,7 +32,7 @@
       </div>
 
     </div>
-    <div class="col-9">
+    <div class="col-10">
 
       <?php if (count($templateData['errors'])) { ?>
         <?php foreach ($templateData['errors'] as $message) { ?>
@@ -61,6 +61,9 @@
                     value="<?php echo $artist->id; ?>"
                   >
                   <label class="custom-control-label" for="check-top-artist-<?php echo $artist->id; ?>">
+                    <?php if (count($artist->images)) { ?>
+                      <img src="<?php echo $artist->images[count($artist->images) - 1]->url; ?>" style="max-height: 1rem;" />
+                    <?php } ?>
                     <?php echo $artist->name; ?>
                   </label>
                 </div>
@@ -103,6 +106,9 @@
                     value="<?php echo $playlist->id; ?>"
                   >
                   <label class="custom-control-label" for="check-playlist-<?php echo $playlist->id; ?>">
+                    <?php if (count($playlist->images)) { ?>
+                      <img src="<?php echo $playlist->images[count($playlist->images) - 1]->url; ?>" style="max-height: 1rem;" />
+                    <?php } ?>
                     <?php echo $playlist->name; ?>
                   </label>
                 </div>
-- 
GitLab