Skip to content

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
el3um4s committed Mar 4, 2024
1 parent 8b50679 commit 34c9ae7
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 14 deletions.
12 changes: 12 additions & 0 deletions src/css/tailwind.pcss
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@
}
}

.pagination {
@apply flex justify-between items-center px-4 py-3;

.showing-text {
@apply hidden sm:block;
}

.buttons {
@apply flex gap-2;
}
}

header {
@apply bg-white shadow-md sticky top-0 left-0 right-0 z-50 dark:bg-gray-800;
nav {
Expand Down
30 changes: 30 additions & 0 deletions src/lib/components/custom/pagination.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<script lang="ts">
// let { data } = $props();
export let currentPage: number;
export let nextPage: number;
export let start: number;
export let end: number;
export let url: string;
</script>

<section class="pagination">
<div class="showing-text">
Showing <span class="semibold">{start}</span> to
<span class="semibold">{end}</span> results
</div>
<div class="buttons">
{#if currentPage >= 1}
<a href="{url}/{currentPage - 1}">Previous</a>
{/if}

{#if nextPage >= 1}
<a href="{url}/{nextPage}">Next</a>
{/if}
</div>
</section>

<style>
.semibold {
font-weight: 600;
}
</style>
13 changes: 5 additions & 8 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as config from '$lib/config';
import PostPreview from '$lib/components/custom/post-preview.svelte';
import Pagination from '$lib/components/custom/pagination.svelte';
import type { Post } from '$lib/types';
// export let data;
Expand Down Expand Up @@ -42,20 +43,16 @@
</section>

<!-- Pagination -->
<section class=" flex justify-between items-center px-4 py-3">
<Pagination currentPage={0} nextPage={1} start={1} end={config.pagination} url="{config.url}/page"
></Pagination>
<!-- <section class=" flex justify-between items-center px-4 py-3">
<div class="hidden sm:block">
Showing <span class="font-semibold">1</span> to
<span class="font-semibold">{config.pagination}</span> results
</div>
<div class="flex gap-2">
<!-- {#if previousPage >= 0}
<button on:click={() => currentPage--}>Previous</button>
{/if}
{#if nextPage >= 0}
<button on:click={() => currentPage++}>Next</button>
{/if} -->
{#if nextPage}
<a href="{config.url}/page/1">Next</a>
{/if}
</div>
</section>
</section> -->
12 changes: 10 additions & 2 deletions src/routes/category/[category]/[[page]]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as config from '$lib/config';
import PostPreview from '$lib/components/custom/post-preview.svelte';
import Pagination from '$lib/components/custom/pagination.svelte';
// export let data;
let { data } = $props();
Expand All @@ -27,7 +28,14 @@
</section>

<!-- Pagination -->
<section class=" flex justify-between items-center px-4 py-3">
<Pagination
currentPage={data.currentPage}
nextPage={data.nextPage}
start={data.start + 1}
end={data.end + 1}
url="{config.url}/category/{data.category}"
></Pagination>
<!-- <section class=" flex justify-between items-center px-4 py-3">
<div class="hidden sm:block">
Showing <span class="font-semibold">{data.start + 1}</span> to
<span class="font-semibold">{data.end + 1}</span> results
Expand All @@ -41,5 +49,5 @@
<a href="{config.url}/category/{data.category}/{data.nextPage}">Next</a>
{/if}
</div>
</section>
</section> -->
{/if}
13 changes: 11 additions & 2 deletions src/routes/column/[column]/[[page]]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { slide } from 'svelte/transition';
import * as config from '$lib/config';
import PostPreview from '$lib/components/custom/post-preview.svelte';
import Pagination from '$lib/components/custom/pagination.svelte';
// export let data;
let { data } = $props();
Expand All @@ -26,7 +27,15 @@
</section>

<!-- Pagination -->
<section class=" flex justify-between items-center px-4 py-3">
<Pagination
currentPage={data.currentPage}
nextPage={data.nextPage}
start={data.start + 1}
end={data.end + 1}
url="{config.url}/column/{data.column}"
></Pagination>

<!-- <section class=" flex justify-between items-center px-4 py-3">
<div class="hidden sm:block">
Showing <span class="font-semibold">{data.start + 1}</span> to
<span class="font-semibold">{data.end + 1}</span> results
Expand All @@ -40,5 +49,5 @@
<a href="{config.url}/column/{data.column}/{data.nextPage}">Next</a>
{/if}
</div>
</section>
</section> -->
{/if}
12 changes: 10 additions & 2 deletions src/routes/page/[page]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import * as config from '$lib/config';
import PostPreview from '$lib/components/custom/post-preview.svelte';
import Pagination from '$lib/components/custom/pagination.svelte';
// export let data;
let { data } = $props();
Expand All @@ -24,7 +25,14 @@
</section>

<!-- Pagination -->
<section class=" flex justify-between items-center px-4 py-3">
<Pagination
currentPage={data.currentPage}
nextPage={data.nextPage}
start={data.start + 1}
end={data.end + 1}
url="{config.url}/page"
></Pagination>
<!-- <section class=" flex justify-between items-center px-4 py-3">
<div class="hidden sm:block">
Showing <span class="font-semibold">{data.start + 1}</span> to
<span class="font-semibold">{data.end + 1}</span> results
Expand All @@ -40,4 +48,4 @@
<a href="{config.url}/page/{data.nextPage}">Next</a>
{/if}
</div>
</section>
</section> -->

0 comments on commit 34c9ae7

Please sign in to comment.