From a9072370ca1eb9a5cce928b1d487db0f307edea6 Mon Sep 17 00:00:00 2001
From: ivarlovlie <git@ivarlovlie.no>
Date: Tue, 20 Sep 2022 15:24:27 +0800
Subject: feat: Move old apps into it's own directory

---
 .../app/pages/views/data-table-paginator.svelte    | 101 +++++++++++++++++++++
 1 file changed, 101 insertions(+)
 create mode 100644 old-apps/projects/src/app/pages/views/data-table-paginator.svelte

(limited to 'old-apps/projects/src/app/pages/views/data-table-paginator.svelte')

diff --git a/old-apps/projects/src/app/pages/views/data-table-paginator.svelte b/old-apps/projects/src/app/pages/views/data-table-paginator.svelte
new file mode 100644
index 0000000..b2649eb
--- /dev/null
+++ b/old-apps/projects/src/app/pages/views/data-table-paginator.svelte
@@ -0,0 +1,101 @@
+<script>
+	import LL from "$app/lib/i18n/i18n-svelte";
+	import {createEventDispatcher, onMount} from "svelte";
+	import {restrict_input_to_numbers} from "$shared/lib/helpers";
+
+	const dispatch = createEventDispatcher();
+	export let page = 1;
+	export let pageCount = 1;
+	let prevCount = page;
+	let canIncrement = false;
+	let canDecrement = false;
+	$: canIncrement = page < pageCount;
+	$: canDecrement = page > 1;
+
+	onMount(() => {
+		restrict_input_to_numbers(document.querySelector("#curr-page"));
+	});
+
+	function increment() {
+		if (canIncrement) {
+			page++;
+		}
+	}
+
+	function decrement() {
+		if (canDecrement) {
+			page--;
+		}
+	}
+
+	$: if (page) {
+		handle_change();
+	}
+
+	function handle_change() {
+		if (page === prevCount) {
+			return;
+		}
+		prevCount = page;
+		if (page > pageCount) {
+			page = pageCount;
+		}
+		dispatch("value_change", {
+			newValue: page,
+		});
+	}
+</script>
+
+<nav class="pagination"
+     aria-label="Pagination">
+    <ul class="pagination__list flex flex-wrap gap-xxxs justify-center justify-end@md">
+        <li>
+            <button on:click={decrement}
+                    class="reset pagination__item {canDecrement ? '' : 'c-disabled'}">
+                <svg class="icon icon--xs flip-x"
+                     viewBox="0 0 16 16">
+                    <title>{$LL.views.dataTablePaginator.goToPrevPage()}</title>
+                    <polyline
+                            points="6 2 12 8 6 14"
+                            fill="none"
+                            stroke="currentColor"
+                            stroke-linecap="round"
+                            stroke-linejoin="round"
+                            stroke-width="2"
+                    />
+                </svg>
+            </button>
+        </li>
+
+        <li>
+            <span class="pagination__jumper flex items-center">
+                <input aria-label="Page number"
+                       class="form-control"
+                       id="curr-page"
+                       type="text"
+                       on:change={handle_change}
+                       value={page}
+                />
+                <em>{$LL.views.dataTablePaginator.of()} {pageCount}</em>
+            </span>
+        </li>
+
+        <li>
+            <button on:click={increment}
+                    class="reset pagination__item {canIncrement ? '' : 'c-disabled'}">
+                <svg class="icon icon--xs"
+                     viewBox="0 0 16 16">
+                    <title>{$LL.views.dataTablePaginator.goToNextPage()}</title>
+                    <polyline
+                            points="6 2 12 8 6 14"
+                            fill="none"
+                            stroke="currentColor"
+                            stroke-linecap="round"
+                            stroke-linejoin="round"
+                            stroke-width="2"
+                    />
+                </svg>
+            </button>
+        </li>
+    </ul>
+</nav>
-- 
cgit v1.3

