mirror of
https://github.com/wah-su/wahs.wah.su.git
synced 2025-04-05 15:54:37 +00:00
add selecting of how many items are visible per page
This commit is contained in:
parent
5e30c48bac
commit
a30c9bb445
3 changed files with 88 additions and 22 deletions
|
@ -662,9 +662,6 @@
|
||||||
.grid-cols-\[repeat\(auto-fill\,minmax\(25\%\,1fr\)\)\] {
|
.grid-cols-\[repeat\(auto-fill\,minmax\(25\%\,1fr\)\)\] {
|
||||||
grid-template-columns: repeat(auto-fill,minmax(25%,1fr));
|
grid-template-columns: repeat(auto-fill,minmax(25%,1fr));
|
||||||
}
|
}
|
||||||
.grid-cols-\[repeat\(auto-fill\,minmax\(250px\,1fr\)\)\] {
|
|
||||||
grid-template-columns: repeat(auto-fill,minmax(250px,1fr));
|
|
||||||
}
|
|
||||||
.grid-cols-\[repeat\(auto-fill\,minmax\(25vw\,1fr\)\)\] {
|
.grid-cols-\[repeat\(auto-fill\,minmax\(25vw\,1fr\)\)\] {
|
||||||
grid-template-columns: repeat(auto-fill,minmax(25vw,1fr));
|
grid-template-columns: repeat(auto-fill,minmax(25vw,1fr));
|
||||||
}
|
}
|
||||||
|
@ -683,12 +680,18 @@
|
||||||
.grid-cols-\[repeat\(auto-fill\,minmax\(50vw\,1fr\)\)\] {
|
.grid-cols-\[repeat\(auto-fill\,minmax\(50vw\,1fr\)\)\] {
|
||||||
grid-template-columns: repeat(auto-fill,minmax(50vw,1fr));
|
grid-template-columns: repeat(auto-fill,minmax(50vw,1fr));
|
||||||
}
|
}
|
||||||
|
.grid-cols-\[repeat\(auto-fill\,minmax\(250px\,1fr\)\)\] {
|
||||||
|
grid-template-columns: repeat(auto-fill,minmax(250px,1fr));
|
||||||
|
}
|
||||||
.flex-col {
|
.flex-col {
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
}
|
}
|
||||||
.items-center {
|
.items-center {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
.justify-around {
|
||||||
|
justify-content: space-around;
|
||||||
|
}
|
||||||
.justify-between {
|
.justify-between {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
@ -698,6 +701,9 @@
|
||||||
.gap-4 {
|
.gap-4 {
|
||||||
gap: calc(var(--spacing) * 4);
|
gap: calc(var(--spacing) * 4);
|
||||||
}
|
}
|
||||||
|
.gap-6 {
|
||||||
|
gap: calc(var(--spacing) * 6);
|
||||||
|
}
|
||||||
.overflow-hidden {
|
.overflow-hidden {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
@ -736,6 +742,9 @@
|
||||||
.object-cover {
|
.object-cover {
|
||||||
object-fit: cover;
|
object-fit: cover;
|
||||||
}
|
}
|
||||||
|
.p-2 {
|
||||||
|
padding: calc(var(--spacing) * 2);
|
||||||
|
}
|
||||||
.p-4 {
|
.p-4 {
|
||||||
padding: calc(var(--spacing) * 4);
|
padding: calc(var(--spacing) * 4);
|
||||||
}
|
}
|
||||||
|
@ -752,16 +761,27 @@
|
||||||
font-size: var(--text-4xl);
|
font-size: var(--text-4xl);
|
||||||
line-height: var(--tw-leading, var(--text-4xl--line-height));
|
line-height: var(--tw-leading, var(--text-4xl--line-height));
|
||||||
}
|
}
|
||||||
|
.text-lg {
|
||||||
|
font-size: var(--text-lg);
|
||||||
|
line-height: var(--tw-leading, var(--text-lg--line-height));
|
||||||
|
}
|
||||||
.text-xl {
|
.text-xl {
|
||||||
font-size: var(--text-xl);
|
font-size: var(--text-xl);
|
||||||
line-height: var(--tw-leading, var(--text-xl--line-height));
|
line-height: var(--tw-leading, var(--text-xl--line-height));
|
||||||
}
|
}
|
||||||
|
.font-bold {
|
||||||
|
--tw-font-weight: var(--font-weight-bold);
|
||||||
|
font-weight: var(--font-weight-bold);
|
||||||
|
}
|
||||||
.text-\[\#140606\] {
|
.text-\[\#140606\] {
|
||||||
color: #140606;
|
color: #140606;
|
||||||
}
|
}
|
||||||
.text-\[\#f9ebeb\] {
|
.text-\[\#f9ebeb\] {
|
||||||
color: #f9ebeb;
|
color: #f9ebeb;
|
||||||
}
|
}
|
||||||
|
.text-orange-500 {
|
||||||
|
color: var(--color-orange-500);
|
||||||
|
}
|
||||||
.text-white {
|
.text-white {
|
||||||
color: var(--color-white);
|
color: var(--color-white);
|
||||||
}
|
}
|
||||||
|
@ -830,6 +850,17 @@
|
||||||
padding-inline: calc(var(--spacing) * 8);
|
padding-inline: calc(var(--spacing) * 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.md\:block {
|
||||||
|
@media (width >= 48rem) {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.md\:text-lg {
|
||||||
|
@media (width >= 48rem) {
|
||||||
|
font-size: var(--text-lg);
|
||||||
|
line-height: var(--tw-leading, var(--text-lg--line-height));
|
||||||
|
}
|
||||||
|
}
|
||||||
.lg\:text-xl {
|
.lg\:text-xl {
|
||||||
@media (width >= 64rem) {
|
@media (width >= 64rem) {
|
||||||
font-size: var(--text-xl);
|
font-size: var(--text-xl);
|
||||||
|
@ -946,6 +977,10 @@
|
||||||
inherits: false;
|
inherits: false;
|
||||||
initial-value: solid;
|
initial-value: solid;
|
||||||
}
|
}
|
||||||
|
@property --tw-font-weight {
|
||||||
|
syntax: "*";
|
||||||
|
inherits: false;
|
||||||
|
}
|
||||||
@property --tw-outline-style {
|
@property --tw-outline-style {
|
||||||
syntax: "*";
|
syntax: "*";
|
||||||
inherits: false;
|
inherits: false;
|
||||||
|
|
|
@ -40,16 +40,16 @@ function setImagesPerPage(count) {
|
||||||
localStorage.setItem("ImagesPP", count);
|
localStorage.setItem("ImagesPP", count);
|
||||||
}
|
}
|
||||||
function getImagesPerPage() {
|
function getImagesPerPage() {
|
||||||
const count = localStorage.getItem("ImagesPP");
|
let count = localStorage.getItem("ImagesPP");
|
||||||
const url = new URL(window.location.toString());
|
const url = new URL(window.location.toString());
|
||||||
const countParam = url.searchParams.get("ImagesPP");
|
const countParam = url.searchParams.get("ImagesPP");
|
||||||
|
|
||||||
if (!count && !countParam) {
|
if (!count && !countParam) {
|
||||||
setImagesPerPage(24);
|
setImagesPerPage(24);
|
||||||
url.searchParams.set("ImagesPP", 24);
|
url.searchParams.set("ImagesPP", 24);
|
||||||
return Number(24);
|
count = Number(24);
|
||||||
} else if (countParam) {
|
} else if (countParam) {
|
||||||
return Number(countParam);
|
count = Number(countParam);
|
||||||
} else if (count) {
|
} else if (count) {
|
||||||
url.searchParams.set("ImagesPP", count);
|
url.searchParams.set("ImagesPP", count);
|
||||||
window.history.pushState(
|
window.history.pushState(
|
||||||
|
@ -57,10 +57,20 @@ function getImagesPerPage() {
|
||||||
`Wah-Collection/Images`,
|
`Wah-Collection/Images`,
|
||||||
`?${url.searchParams.toString()}`
|
`?${url.searchParams.toString()}`
|
||||||
);
|
);
|
||||||
return Number(count);
|
count = Number(count);
|
||||||
} else {
|
} else {
|
||||||
return 24;
|
count = 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const active = document.querySelectorAll(`[data-ipp="${count}"]`);
|
||||||
|
if (active.length > 0) {
|
||||||
|
active.forEach((item) => {
|
||||||
|
item.classList.add("underline");
|
||||||
|
item.classList.add("text-orange-500");
|
||||||
|
item.classList.add("font-bold");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setOffset(offset) {
|
function setOffset(offset) {
|
||||||
|
@ -79,23 +89,32 @@ function getOffset() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableNav() {
|
function enableNav() {
|
||||||
|
|
||||||
function handleClickPrev() {
|
function handleClickPrev() {
|
||||||
setOffset(getOffset() - getImagesPerPage())
|
setOffset(getOffset() - getImagesPerPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleClickNext() {
|
function handleClickNext() {
|
||||||
setOffset(getOffset() + getImagesPerPage())
|
setOffset(getOffset() + getImagesPerPage());
|
||||||
}
|
}
|
||||||
|
|
||||||
const nav_prev = document.querySelectorAll("#nav_prev")
|
function handleClickIpp(ipp) {
|
||||||
const nav_next = document.querySelectorAll("#nav_next")
|
setImagesPerPage(ipp);
|
||||||
|
const url = new URL(window.location.toString());
|
||||||
|
url.searchParams.set("ImagesPP", ipp);
|
||||||
|
window.location.href = url.href;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nav_prev = document.querySelectorAll("#nav_prev");
|
||||||
|
const nav_next = document.querySelectorAll("#nav_next");
|
||||||
|
const nav_ipp = document.querySelectorAll("#nav_ipp");
|
||||||
|
|
||||||
nav_prev.forEach((item) => {
|
nav_prev.forEach((item) => {
|
||||||
item.addEventListener('click', handleClickPrev)
|
item.addEventListener("click", handleClickPrev);
|
||||||
})
|
});
|
||||||
nav_next.forEach((item) => {
|
nav_next.forEach((item) => {
|
||||||
item.addEventListener('click', handleClickNext)
|
item.addEventListener("click", handleClickNext);
|
||||||
})
|
});
|
||||||
|
nav_ipp.forEach((item) => {
|
||||||
}
|
item.addEventListener("click", () => handleClickIpp(item.dataset.ipp));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
|
@ -1,10 +1,22 @@
|
||||||
export default function PageNav() {
|
export default function PageNav() {
|
||||||
|
|
||||||
|
const ipp = [12,24,32,48,72,100,250,500,1000]
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="bg-orange-800/50 rounded-sm py-2 text-white flex justify-between gap-4 items-center">
|
<div className="bg-orange-800/50 rounded-sm p-2 text-white flex justify-between gap-4 items-center">
|
||||||
<button className="flex justify-center gap-4 items-center cursor-pointer" id="nav_prev">
|
<button className="flex justify-center items-center cursor-pointer" id="nav_prev">
|
||||||
<div className="material-symbols--navigate-before w-16 h-16"></div>
|
<div className="material-symbols--navigate-before w-16 h-16"></div>
|
||||||
</button>
|
</button>
|
||||||
<button className="flex justify-center gap-4 items-center cursor-pointer" id="nav_next">
|
<div className="flex gap-4">
|
||||||
|
{ipp.map((item, idx) => {
|
||||||
|
return <button key={`ipp_${item}`}
|
||||||
|
className={`${idx > 4 ? "hidden md:block" : ""} cursor-pointer md:text-lg lg:text-xl`}
|
||||||
|
id="nav_ipp"
|
||||||
|
data-ipp={item}
|
||||||
|
>{item}</button>
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
<button className="flex justify-center items-center cursor-pointer" id="nav_next">
|
||||||
<div className="material-symbols--navigate-next w-16 h-16"></div>
|
<div className="material-symbols--navigate-next w-16 h-16"></div>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue