From 38cc21ce73e2a5d2073531fbebc964dbab64d404 Mon Sep 17 00:00:00 2001 From: Lennart Bank Date: Mon, 16 Oct 2023 14:36:44 +0200 Subject: [PATCH 1/2] REFACTOR Pagination implementation --- pwa/src/templates/landing/LandingTemplate.tsx | 50 +++---------------- 1 file changed, 6 insertions(+), 44 deletions(-) diff --git a/pwa/src/templates/landing/LandingTemplate.tsx b/pwa/src/templates/landing/LandingTemplate.tsx index e5a60302..fd8e27be 100644 --- a/pwa/src/templates/landing/LandingTemplate.tsx +++ b/pwa/src/templates/landing/LandingTemplate.tsx @@ -15,53 +15,11 @@ import { useTranslation } from "react-i18next"; export const LandingTemplate: React.FC = () => { const { currentPage, setCurrentPage } = usePaginationContext(); const { filters } = useFiltersContext(); - const { t, i18n } = useTranslation(); + const { t } = useTranslation(); const queryClient = new QueryClient(); const getItems = useOpenWoo(queryClient).getAll(filters, currentPage); - React.useEffect(() => { - if (!getItems.data?.results.length) return; - - //Updates aria-label of previous and next pagination buttons to translatable aria-labels - document - .querySelectorAll('[class*="Pagination-module--previous"]')[0] - ?.children[0].setAttribute("aria-label", `${t("Previous page")}`); - document - .querySelectorAll('[class*="Pagination-module--next"]')[0] - ?.children[0].setAttribute("aria-label", `${t("Next page")}`); - - //Adds tabindex of -1 to all disabled and unused pagination buttons - document.querySelectorAll('[class*="Pagination-module--disabled"]')[0]?.children[0].setAttribute("tabindex", "-1"); - document.querySelectorAll('[class*="Pagination-module--disabled"]')[0]?.setAttribute("tabindex", "-1"); - document - .querySelectorAll('[class*="Pagination-module--previous"]')[0] - ?.children[0].children[0].setAttribute("tabindex", "-1"); - document - .querySelectorAll('[class*="Pagination-module--next"]')[0] - ?.children[0].children[0].setAttribute("tabindex", "-1"); - - //Updates aria-label of all page pagination buttons to translatable aria-labels - let pageNumbers = Array.from(document.querySelectorAll('[class*="Pagination-module--container"]')[0].children); - var removeStr = ["Pagination-module--previous", "Pagination-module--next"]; - pageNumbers = pageNumbers.filter(function (val) { - var found = false; - for (var i = 0; i < removeStr.length; i++) { - var str = removeStr[i]; - if (val.className.indexOf(str) > -1) { - return false; - } - } - return true; - }); - pageNumbers.map((value: any) => { - const label = value.children[0].ariaLabel; - const lastSpaceIndex = label.lastIndexOf(" "); - const pageNumber = label.substring(lastSpaceIndex + 1); - value.children[0].setAttribute("aria-label", `${t("Page")} ${pageNumber}`); - }); - }, [getItems.isSuccess, i18n.language]); - return ( <>

@@ -76,7 +34,11 @@ export const LandingTemplate: React.FC = () => {
- +
)} {getItems.isLoading && } From fed6a9b06ea8d459e0d8741ba20da119c48a6d50 Mon Sep 17 00:00:00 2001 From: Lennart Bank Date: Mon, 16 Oct 2023 14:37:03 +0200 Subject: [PATCH 2/2] UP version --- pwa/package.json | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/pwa/package.json b/pwa/package.json index 25e129f6..eb7eb869 100644 --- a/pwa/package.json +++ b/pwa/package.json @@ -4,9 +4,7 @@ "private": true, "description": "Product Website Template", "author": "Conduction", - "keywords": [ - "gatsby" - ], + "keywords": ["gatsby"], "scripts": { "develop": "gatsby develop", "start": "gatsby develop", @@ -24,7 +22,7 @@ "prepare": "cd .. && husky install" }, "dependencies": { - "@conduction/components": "2.2.16", + "@conduction/components": "2.2.17", "@conduction/theme": "1.0.48", "@fortawesome/fontawesome-svg-core": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.4.0",