From a1c7866f87872e83e7766f76eae443fd5af59fd7 Mon Sep 17 00:00:00 2001
From: Ilion Beyst <ilion.beyst@gmail.com>
Date: Mon, 15 Aug 2022 20:46:13 +0200
Subject: styling of next/prev buttons

---
 web/pw-server/src/routes/matches/index.svelte | 51 ++++++++++++++++++++-------
 1 file changed, 39 insertions(+), 12 deletions(-)

(limited to 'web/pw-server/src/routes/matches/index.svelte')

diff --git a/web/pw-server/src/routes/matches/index.svelte b/web/pw-server/src/routes/matches/index.svelte
index 393d513..8de375b 100644
--- a/web/pw-server/src/routes/matches/index.svelte
+++ b/web/pw-server/src/routes/matches/index.svelte
@@ -70,40 +70,67 @@
     return `?${params}`;
   }
 
-  async function loadNewer() {
+  function olderMatchesLink(matches: object[]): string {
     if (matches.length == 0) {
-      return;
+      return null;
     }
-    const firstTimestamp = matches[0]["timestamp"];
-    goto(pageLink({ after: firstTimestamp }));
+    const lastTimestamp = matches[matches.length - 1]["timestamp"];
+    return pageLink({ before: lastTimestamp });
   }
 
-  async function loadOlder() {
+  function newerMatchesLink(matches: object[]): string {
     if (matches.length == 0) {
-      return;
+      return null;
     }
-    const lastTimestamp = matches[matches.length - 1]["timestamp"];
-    goto(pageLink({ before: lastTimestamp }));
+    const firstTimestamp = matches[0]["timestamp"];
+    return pageLink({ after: firstTimestamp });
   }
 </script>
 
 <div class="container">
   <MatchList {matches} />
   <div class="page-controls">
-    <button on:click={loadNewer}>newer</button>
-    <button on:click={loadOlder}>older</button>
+    <div class="btn-group">
+      <a class="btn btn-page-prev" href={newerMatchesLink(matches)}>newer</a>
+      <a class="btn btn-page-next" href={olderMatchesLink(matches)}>older</a>
+    </div>
   </div>
 </div>
 
 <style lang="scss">
+  @import "src/styles/variables.scss";
   .container {
     width: 800px;
     margin: 0 auto;
   }
+  .btn {
+    color: $btn-text-color;
+    font-size: 14px;
+    text-decoration: none;
+    padding: 6px 16px;
+    border: 1px solid $btn-border-color;
+    border-radius: 5px;
+  }
+
+  .btn-group {
+    display: flex;
+  }
+
+  .btn-group .btn:not(:last-child) {
+    border-right: none;
+  }
+
+  .btn-group .btn:first-child {
+    border-radius: 5px 0 0 5px;
+  }
+
+  .btn-group .btn:last-child {
+    border-radius: 0 5px 5px 0;
+  }
 
   .page-controls {
     display: flex;
-    justify-content: space-between;
-    margin: 12px;
+    justify-content: center;
+    margin: 24px 0;
   }
 </style>
-- 
cgit v1.2.3

