styling of next/prev buttons

This commit is contained in:
Ilion Beyst 2022-08-15 20:46:13 +02:00
parent 4dcccb589d
commit a1c7866f87
5 changed files with 49 additions and 19 deletions

View file

View file

@ -118,6 +118,7 @@
</div> </div>
<style lang="scss"> <style lang="scss">
@import "src/styles/variables.scss";
.container { .container {
width: 800px; width: 800px;
max-width: 80%; max-width: 80%;
@ -146,18 +147,16 @@
margin-bottom: $header-space-above-line; margin-bottom: $header-space-above-line;
} }
$borderColor: rgba(27, 31, 36, 0.25);
.btn-container { .btn-container {
padding: 24px; padding: 24px;
text-align: center; text-align: center;
} }
.btn-view-more { .btn-view-more {
color: rgb(9, 105, 218); color: $btn-text-color;
font-size: 14px; font-size: 14px;
text-decoration: none; text-decoration: none;
padding: 6px 16px; padding: 6px 16px;
border: 1px solid $borderColor; border: 1px solid $btn-border-color;
border-radius: 5px; border-radius: 5px;
} }

View file

@ -16,6 +16,7 @@
async function createBot() { async function createBot() {
saveErrors = []; saveErrors = [];
// TODO: how can we handle this with the new ApiClient?
let response = await fetch("/api/bots", { let response = await fetch("/api/bots", {
method: "POST", method: "POST",
headers: { headers: {

View file

@ -70,40 +70,67 @@
return `?${params}`; return `?${params}`;
} }
async function loadNewer() { function olderMatchesLink(matches: object[]): string {
if (matches.length == 0) { if (matches.length == 0) {
return; return null;
}
const firstTimestamp = matches[0]["timestamp"];
goto(pageLink({ after: firstTimestamp }));
}
async function loadOlder() {
if (matches.length == 0) {
return;
} }
const lastTimestamp = matches[matches.length - 1]["timestamp"]; const lastTimestamp = matches[matches.length - 1]["timestamp"];
goto(pageLink({ before: lastTimestamp })); return pageLink({ before: lastTimestamp });
}
function newerMatchesLink(matches: object[]): string {
if (matches.length == 0) {
return null;
}
const firstTimestamp = matches[0]["timestamp"];
return pageLink({ after: firstTimestamp });
} }
</script> </script>
<div class="container"> <div class="container">
<MatchList {matches} /> <MatchList {matches} />
<div class="page-controls"> <div class="page-controls">
<button on:click={loadNewer}>newer</button> <div class="btn-group">
<button on:click={loadOlder}>older</button> <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>
</div> </div>
<style lang="scss"> <style lang="scss">
@import "src/styles/variables.scss";
.container { .container {
width: 800px; width: 800px;
margin: 0 auto; 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 { .page-controls {
display: flex; display: flex;
justify-content: space-between; justify-content: center;
margin: 12px; margin: 24px 0;
} }
</style> </style>

View file

@ -1 +1,4 @@
$bg-color: rgb(41, 41, 41); $bg-color: rgb(41, 41, 41);
$btn-text-color: rgb(9, 105, 218);
$btn-border-color: rgba(27, 31, 36, 0.25);