aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2024-09-13 01:38:34 +0300
committerValentin Popov <valentin@popov.link>2024-09-13 01:38:34 +0300
commit65ee69c64569a65c5768a3ca7993153aafe21478 (patch)
treeaeb5568c7c0d4566f5151cbff8200ad6e86a2ddf /src/components
parentfd054f0fa494bfedf6fd8f9098a2a500be233afc (diff)
downloadpopov.link-65ee69c64569a65c5768a3ca7993153aafe21478.tar.xz
popov.link-65ee69c64569a65c5768a3ca7993153aafe21478.zip
Refactor Pagination component and add Next and Prev components
Diffstat (limited to 'src/components')
-rw-r--r--src/components/Pagination.astro36
-rw-r--r--src/components/Pagination/Next.astro18
-rw-r--r--src/components/Pagination/Prev.astro18
3 files changed, 43 insertions, 29 deletions
diff --git a/src/components/Pagination.astro b/src/components/Pagination.astro
index e9fbc69..cc85db7 100644
--- a/src/components/Pagination.astro
+++ b/src/components/Pagination.astro
@@ -1,4 +1,7 @@
---
+import Next from "./Pagination/Next.astro";
+import Prev from "./Pagination/Prev.astro";
+
type Props = {
readonly prevUrl?: string;
readonly nextUrl?: string;
@@ -8,39 +11,14 @@ const { prevUrl, nextUrl } = Astro.props;
---
<style lang="scss">
- .pagination {
+ div {
overflow: hidden;
padding: 3rem 0;
width: 100%;
}
-
- .prev,
- .next {
- max-width: 40%;
- }
-
- .prev {
- float: left;
- }
-
- .next {
- float: right;
- }
</style>
-<div class="pagination">
- {
- prevUrl && (
- <span class="prev">
- <a href={prevUrl}>&lt; Prev</a>
- </span>
- )
- }
- {
- nextUrl && (
- <span class="next">
- <a href={nextUrl}>Next &gt;</a>
- </span>
- )
- }
+<div>
+ {prevUrl && <Prev url={prevUrl} />}
+ {nextUrl && <Next url={nextUrl} />}
</div>
diff --git a/src/components/Pagination/Next.astro b/src/components/Pagination/Next.astro
new file mode 100644
index 0000000..1a95710
--- /dev/null
+++ b/src/components/Pagination/Next.astro
@@ -0,0 +1,18 @@
+---
+type Props = {
+ readonly url: string;
+};
+
+const { url } = Astro.props;
+---
+
+<style lang="scss">
+ span {
+ float: right;
+ max-width: 40%;
+ }
+</style>
+
+<span>
+ <a href={url}>Next &gt;</a>
+</span>
diff --git a/src/components/Pagination/Prev.astro b/src/components/Pagination/Prev.astro
new file mode 100644
index 0000000..2454876
--- /dev/null
+++ b/src/components/Pagination/Prev.astro
@@ -0,0 +1,18 @@
+---
+type Props = {
+ readonly url: string;
+};
+
+const { url } = Astro.props;
+---
+
+<style lang="scss">
+ span {
+ float: left;
+ max-width: 40%;
+ }
+</style>
+
+<span>
+ <a href={url}>&lt; Prev</a>
+</span>