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": { "modal": {
"close": "دکمه‌ی خروج" "close": "دکمه‌ی خروج"
} }
} }

View file

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