running format

This commit is contained in:
Kelvin 2025-01-11 15:29:07 -03:00
parent 751ade8e43
commit 74c2870537
3 changed files with 23 additions and 18 deletions

View file

@ -136,4 +136,4 @@
"modal": {
"close": "دکمه‌ی خروج"
}
}
}

View file

@ -33,7 +33,8 @@ export class DatanodesApi {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36",
},
maxRedirects: 0, validateStatus: (status: number) => status === 302 || status < 400,
maxRedirects: 0,
validateStatus: (status: number) => status === 302 || status < 400,
}
);

View file

@ -32,8 +32,6 @@ const filterCategoryColors = {
publishers: "hsl(200deg 50% 30%)",
};
const PAGE_SIZE = 20;
const TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM = 10;
const LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTON = 500;
@ -87,24 +85,26 @@ export default function Catalogue() {
).current;
const isGoUpButtonVisible = (results: any[], scrollTop: number) => {
const withinLimit = results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM;
const withinLimit =
results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM;
return withinLimit && scrollTop >= LIMIT_SCROLL_TO_DISAPEAR_GO_UP_BUTTON;
};
useEffect(() => {
const withinLimit = results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM;
const withinLimit =
results.length > 0 && results.length <= TOTAL_ITEMS_TO_SHOW_GO_UP_BUTTOM;
setWantGoUpButtonIsVisible(withinLimit);
}, [results])
}, [results]);
useEffect(() => {
const handleScroll = debounce(() => {
if (cataloguePageRef.current) {
const scrollTop = cataloguePageRef.current.scrollTop
setWantGoUpButtonIsVisible(isGoUpButtonVisible(results, scrollTop))
const scrollTop = cataloguePageRef.current.scrollTop;
setWantGoUpButtonIsVisible(isGoUpButtonVisible(results, scrollTop));
}
}, 100)
const ref = cataloguePageRef.current
}, 100);
const ref = cataloguePageRef.current;
if (ref) {
ref.addEventListener("scroll", handleScroll);
}
@ -378,12 +378,16 @@ export default function Catalogue() {
</div>
{wantGoUpButtonIsVisible && (
<Button onClick={handleWantGoUpButtonClick} theme="outline" style={{ position: "fixed", bottom: 16, left: 16 }}>
{t("result_count", {
resultCount: formatNumber(itemsCount),
})}
, {t('go_up_button')} <ArrowUpIcon />
</Button>
<Button
onClick={handleWantGoUpButtonClick}
theme="outline"
style={{ position: "fixed", bottom: 16, left: 16 }}
>
{t("result_count", {
resultCount: formatNumber(itemsCount),
})}
, {t("go_up_button")} <ArrowUpIcon />
</Button>
)}
</div>